Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2064181rwl; Thu, 13 Apr 2023 00:49:00 -0700 (PDT) X-Google-Smtp-Source: AKy350Zsw93o6KrQzsue7zhnHv8sSW2vGcBC18s5aSNRv40nW27R4RRfRA84/n2APs9JD++dELFW X-Received: by 2002:a17:906:c02:b0:94d:fd61:e90b with SMTP id s2-20020a1709060c0200b0094dfd61e90bmr2078795ejf.65.1681372140659; Thu, 13 Apr 2023 00:49:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681372140; cv=none; d=google.com; s=arc-20160816; b=MtZ88fxpu9GcSMSVXmYO4kILRMw95BzNaz2mTTlvL4qFyiETzpC1ttquzjVIrAHB3N YNfyyN8/mzAPwrJ1UF9LZZ/e6JcNFjrzp7ihLhhNUR4XmPzoVCpic3vukIbnqTOw7TLy NKQzaSox7Wx34kWg7gDj1tHN+KkwF1mX3GPB3uqRfOlUGHR3PhZl9P4lwJglR1aizX9a 29cCLDMo6ylBNuXd+/zLk5cz4NL6bBvp5h1PgpAm6pBJBkOJk68BGr1tfKqfKqYVKXht d36sFc9g3TYMa1HOyhqhKm21b8Wbms6UlFMfaphLdroEbSxPPDmv32U51ZxTyOv0dH/s n39w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=ioXGAt8o8PuPvrOurTdEUEqeCkOKi03aaJ3rgZH9M80=; b=VIAlmVhaGAi6aIZ8y8JJ+Zf32iKbKAcLIyr35Bre0ZYpmNqmVwSwxd/MSUEcRB+1zT WjDZcg5Uw8fqtkX6zve/9Raj8omfNwsGjGCSFNi4DWogbin+iikuLzU0GPIEL1H1cg+0 /xacztmwwfqsv+gMgAvTQtHhIOWi84sz4vB+/8dorD6eLuwXJKYbVFpWUG9s9LwAj2uD Uf9BPOv5qaesCJ51ppq8rbKcR4XP9mnJAdr3m2W7zlfoM/kwv3P+WpYF0bzHxMxSRnic 8Y1DjCAsGwmMXPJHtMGrwuFDDpNdlKXbg2cbDFM2ljlwz+EVlByqQifqndZjioahixfQ s+iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Rqa5To0W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id iy19-20020a170907819300b0094a8ff932aesi1259760ejc.670.2023.04.13.00.48.36; Thu, 13 Apr 2023 00:49:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Rqa5To0W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230213AbjDMHrX (ORCPT + 99 others); Thu, 13 Apr 2023 03:47:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230143AbjDMHrM (ORCPT ); Thu, 13 Apr 2023 03:47:12 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A62D9014; Thu, 13 Apr 2023 00:47:07 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id si1so5005899ejb.10; Thu, 13 Apr 2023 00:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681372025; x=1683964025; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ioXGAt8o8PuPvrOurTdEUEqeCkOKi03aaJ3rgZH9M80=; b=Rqa5To0WIIjF/pWxoOXNzA5fatbZDAp8wifSZNVfu9O3Eg3efRAI4MVKg9rI9pqvft iCmOsEQQwVqLAYTUPN1qz0ShF+A436Fl4Dq4Uee8lq3su8PFwj1U61G7GFH6MYFoIsF0 yuQbfSX7bAtVCEH1KtTmSt8p/Co2EXsm86sQA0xSd02DipV3B95ymswmMOIOYji6wxoF borzJrHYS8cDZCAlnUYrbCZGfiJ4XacnLfAQ7u6fcv1UE1ahG+EK+5reFOWcR3DqVtC0 aahjfbf4U7i2plcvjecjF187S34n87gDa3MDtN81AqfVA78kCa/RTM+HBOae51AVrx0l xOmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681372025; x=1683964025; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ioXGAt8o8PuPvrOurTdEUEqeCkOKi03aaJ3rgZH9M80=; b=j1AI0OP0jegaseYew3aFY+InUO/bx3j+ss+tXq6mm3oRSyg+fghS3C2cLuVvscjykM mwVtm9cz+V/gjP1I2Oy7fwrUdeRBqDCoJ9W/xm8/8HHT/vFVSshE2V+hnNgUjDNXQtdu JScyIjtXs/XvNlV76wzMJrOoNauvSW9Y9g0KG0I/nXHG4/3MVFzoozWk1jdIbhKGCeh1 6DB3mv5LWrxrR4cNUxqTYhLOYpN6IBtmfP+pInU6vSJROjRMkMMEj2Yyfk390bltwf2l JbQkEjJVN34IpBGyc0GK7UZzTTp/M+ESRZ5tpvoEhFzDXi1gdZQVJl5yUxfYvl4tCClN 8l2g== X-Gm-Message-State: AAQBX9fXsil6RQV2B3aiCXHP8pCqNj0TolAW0Dal1PRp9i7+IDr5wJLN OlDoHbrUKFh8XYXYaKUNxaW4Bth5gWCRRg== X-Received: by 2002:a17:906:a1ca:b0:933:1702:a12b with SMTP id bx10-20020a170906a1ca00b009331702a12bmr2131835ejb.17.1681372025185; Thu, 13 Apr 2023 00:47:05 -0700 (PDT) Received: from [127.0.1.1] ([91.230.2.244]) by smtp.gmail.com with ESMTPSA id q16-20020a1709060f9000b0094e954fd015sm565620ejj.175.2023.04.13.00.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Apr 2023 00:47:04 -0700 (PDT) From: Benjamin Bara Date: Thu, 13 Apr 2023 09:46:41 +0200 Subject: [PATCH v4 3/4] mfd: tps6586x: use devm-based power off handler MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230327-tegra-pmic-reboot-v4-3-b24af219fb47@skidata.com> References: <20230327-tegra-pmic-reboot-v4-0-b24af219fb47@skidata.com> In-Reply-To: <20230327-tegra-pmic-reboot-v4-0-b24af219fb47@skidata.com> To: Wolfram Sang , Lee Jones , rafael.j.wysocki@intel.com Cc: dmitry.osipenko@collabora.com, peterz@infradead.org, jonathanh@nvidia.com, richard.leitner@linux.dev, treding@nvidia.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-tegra@vger.kernel.org, Benjamin Bara X-Mailer: b4 0.12.2 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Benjamin Bara Convert the power off handler to a devm-based power off handler. Reviewed-by: Dmitry Osipenko Signed-off-by: Benjamin Bara --- drivers/mfd/tps6586x.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index 2d947f3f606a..93f1bf440191 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -457,13 +458,16 @@ static const struct regmap_config tps6586x_regmap_config = { .cache_type = REGCACHE_RBTREE, }; -static struct device *tps6586x_dev; -static void tps6586x_power_off(void) +static int tps6586x_power_off_handler(struct sys_off_data *data) { - if (tps6586x_clr_bits(tps6586x_dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT)) - return; + struct device *tps6586x_dev = data->cb_data; + int ret; + + ret = tps6586x_clr_bits(tps6586x_dev, TPS6586X_SUPPLYENE, EXITSLREQ_BIT); + if (ret) + return ret; - tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT); + return tps6586x_set_bits(tps6586x_dev, TPS6586X_SUPPLYENE, SLEEP_MODE_BIT); } static void tps6586x_print_version(struct i2c_client *client, int version) @@ -559,9 +563,13 @@ static int tps6586x_i2c_probe(struct i2c_client *client) goto err_add_devs; } - if (pdata->pm_off && !pm_power_off) { - tps6586x_dev = &client->dev; - pm_power_off = tps6586x_power_off; + if (pdata->pm_off) { + ret = devm_register_power_off_handler(&client->dev, &tps6586x_power_off_handler, + &client->dev); + if (ret) { + dev_err(&client->dev, "register power off handler failed: %d\n", ret); + goto err_add_devs; + } } return 0; -- 2.34.1