From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: "Otto Pflüger" <otto.pflueger@abscue.de>,
"Sebastian Reichel" <sre@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Orson Zhai" <orsonzhai@gmail.com>,
"Chunyan Zhang" <zhang.lyra@gmail.com>,
"Lee Jones" <lee@kernel.org>
Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/5] power: reset: sc27xx: Use devm_register_sys_off_handler
Date: Tue, 30 Sep 2025 11:23:26 +0800 [thread overview]
Message-ID: <52756d02-8bb2-42b6-b311-db9c28473623@linux.alibaba.com> (raw)
In-Reply-To: <20250926-sc2730-reboot-v1-3-62ebfd3d31bb@abscue.de>
On 2025/9/27 00:23, Otto Pflüger wrote:
> Use the new device life-cycle managed register function to remove the
> need for global variables in the driver.
>
> Signed-off-by: Otto Pflüger <otto.pflueger@abscue.de>
> ---
LGTM. Thanks.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> drivers/power/reset/sc27xx-poweroff.c | 24 +++++++++++++++++-------
> 1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/power/reset/sc27xx-poweroff.c b/drivers/power/reset/sc27xx-poweroff.c
> index 90287c31992c4889f9241e82a21a1949ecca7702..20eb9f32cb2b99adeb16502172adf9d6257cd05f 100644
> --- a/drivers/power/reset/sc27xx-poweroff.c
> +++ b/drivers/power/reset/sc27xx-poweroff.c
> @@ -9,6 +9,7 @@
> #include <linux/module.h>
> #include <linux/platform_device.h>
> #include <linux/pm.h>
> +#include <linux/reboot.h>
> #include <linux/regmap.h>
> #include <linux/syscore_ops.h>
>
> @@ -17,8 +18,6 @@
> #define SC27XX_SLP_CTRL 0xdf0
> #define SC27XX_LDO_XTL_EN BIT(3)
>
> -static struct regmap *regmap;
> -
> /*
> * On Spreadtrum platform, we need power off system through external SC27xx
> * series PMICs, and it is one similar SPI bus mapped by regmap to access PMIC,
> @@ -44,26 +43,37 @@ static struct syscore_ops poweroff_syscore_ops = {
> .shutdown = sc27xx_poweroff_shutdown,
> };
>
> -static void sc27xx_poweroff_do_poweroff(void)
> +static int sc27xx_poweroff_do_poweroff(struct sys_off_data *off_data)
> {
> + struct regmap *regmap = off_data->cb_data;
> +
> /* Disable the external subsys connection's power firstly */
> regmap_write(regmap, SC27XX_SLP_CTRL, SC27XX_LDO_XTL_EN);
>
> regmap_write(regmap, SC27XX_PWR_PD_HW, SC27XX_PWR_OFF_EN);
> +
> + mdelay(1000);
> +
> + pr_emerg("Unable to poweroff system\n");
> +
> + return NOTIFY_DONE;
> }
>
> static int sc27xx_poweroff_probe(struct platform_device *pdev)
> {
> - if (regmap)
> - return -EINVAL;
> + struct regmap *regmap;
>
> regmap = dev_get_regmap(pdev->dev.parent, NULL);
> if (!regmap)
> return -ENODEV;
>
> - pm_power_off = sc27xx_poweroff_do_poweroff;
> register_syscore_ops(&poweroff_syscore_ops);
> - return 0;
> +
> + return devm_register_sys_off_handler(&pdev->dev,
> + SYS_OFF_MODE_POWER_OFF,
> + SYS_OFF_PRIO_DEFAULT,
> + sc27xx_poweroff_do_poweroff,
> + regmap);
> }
>
> static struct platform_driver sc27xx_poweroff_driver = {
>
next prev parent reply other threads:[~2025-09-30 3:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 16:23 [PATCH 0/5] power: reset: sc27xx: Add SC2730 and reboot support Otto Pflüger
2025-09-26 16:23 ` [PATCH 1/5] dt-bindings: power: reset: Add SC27xx series PMIC poweroff Otto Pflüger
2025-09-26 16:23 ` [PATCH 2/5] dt-bindings: mfd: sc2731: Reference sprd,sc2731-poweroff Otto Pflüger
2025-10-02 2:53 ` Rob Herring
2025-09-26 16:23 ` [PATCH 3/5] power: reset: sc27xx: Use devm_register_sys_off_handler Otto Pflüger
2025-09-30 3:23 ` Baolin Wang [this message]
2025-09-26 16:23 ` [PATCH 4/5] power: reset: sc27xx: Add support for SC2730 and OF match table Otto Pflüger
2025-09-30 3:30 ` Baolin Wang
2025-09-30 5:30 ` Otto Pflüger
2025-10-14 1:44 ` Baolin Wang
2025-10-14 6:10 ` Otto Pflüger
2025-09-26 16:23 ` [PATCH 5/5] power: reset: sc27xx: Add reboot support for SC2730 Otto Pflüger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52756d02-8bb2-42b6-b311-db9c28473623@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=orsonzhai@gmail.com \
--cc=otto.pflueger@abscue.de \
--cc=robh@kernel.org \
--cc=sre@kernel.org \
--cc=zhang.lyra@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®