[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <52756d02-8bb2-42b6-b311-db9c28473623@linux.alibaba.com>
Date: Tue, 30 Sep 2025 11:23:26 +0800
From: Baolin Wang <baolin.wang@...ux.alibaba.com>
To: Otto Pflüger <otto.pflueger@...cue.de>,
Sebastian Reichel <sre@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
<conor+dt@...nel.org>, Orson Zhai <orsonzhai@...il.com>,
Chunyan Zhang <zhang.lyra@...il.com>, Lee Jones <lee@...nel.org>
Cc: linux-pm@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/5] power: reset: sc27xx: Use
devm_register_sys_off_handler
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@...cue.de>
> ---
LGTM. Thanks.
Reviewed-by: Baolin Wang <baolin.wang@...ux.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 = {
>
Powered by blists - more mailing lists