lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f5044987-2514-44cf-83d4-0976b37dc683@collabora.com>
Date: Tue, 6 Feb 2024 10:33:47 +0100
From: AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
To: Andrew Davis <afd@...com>, Sebastian Reichel <sre@...nel.org>,
 Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>,
 Cristian Ciocaltea <cristian.ciocaltea@...il.com>,
 Florian Fainelli <florian.fainelli@...adcom.com>, Ray Jui
 <rjui@...adcom.com>, Scott Branden <sbranden@...adcom.com>,
 Bjorn Andersson <andersson@...nel.org>,
 Konrad Dybcio <konrad.dybcio@...aro.org>, Sean Wang
 <sean.wang@...iatek.com>, Matthias Brugger <matthias.bgg@...il.com>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
 linux-actions@...ts.infradead.org, linux-arm-msm@...r.kernel.org,
 linux-arm-kernel@...ts.infradead.org, linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH v2 11/19] power: reset: mt6323-poweroff: Use
 devm_register_sys_off_handler(POWER_OFF)

Il 05/02/24 20:44, Andrew Davis ha scritto:
> Use device life-cycle managed register function to simplify probe and
> exit paths.
> 
> Signed-off-by: Andrew Davis <afd@...com>
> ---
>   drivers/power/reset/mt6323-poweroff.c | 28 ++++++++++++++-------------
>   1 file changed, 15 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/power/reset/mt6323-poweroff.c b/drivers/power/reset/mt6323-poweroff.c
> index 57a63c0ab7fb7..ca5d11b17ff03 100644
> --- a/drivers/power/reset/mt6323-poweroff.c
> +++ b/drivers/power/reset/mt6323-poweroff.c
> @@ -14,6 +14,7 @@
>   #include <linux/platform_device.h>
>   #include <linux/mfd/mt6397/core.h>
>   #include <linux/mfd/mt6397/rtc.h>
> +#include <linux/reboot.h>
>   
>   struct mt6323_pwrc {
>   	struct device *dev;
> @@ -21,11 +22,9 @@ struct mt6323_pwrc {
>   	u32 base;
>   };
>   
> -static struct mt6323_pwrc *mt_pwrc;
> -
> -static void mt6323_do_pwroff(void)
> +static int mt6323_do_pwroff(struct sys_off_data *data)
>   {
> -	struct mt6323_pwrc *pwrc = mt_pwrc;
> +	struct mt6323_pwrc *pwrc = data->cb_data;
>   	unsigned int val;
>   	int ret;
>   
> @@ -44,6 +43,8 @@ static void mt6323_do_pwroff(void)
>   	mdelay(1000);
>   
>   	WARN_ONCE(1, "Unable to power off system\n");
> +
> +	return NOTIFY_DONE;
>   }
>   
>   static int mt6323_pwrc_probe(struct platform_device *pdev)
> @@ -51,6 +52,7 @@ static int mt6323_pwrc_probe(struct platform_device *pdev)
>   	struct mt6397_chip *mt6397_chip = dev_get_drvdata(pdev->dev.parent);
>   	struct mt6323_pwrc *pwrc;
>   	struct resource *res;
> +	int ret;
>   
>   	pwrc = devm_kzalloc(&pdev->dev, sizeof(*pwrc), GFP_KERNEL);
>   	if (!pwrc)
> @@ -63,19 +65,20 @@ static int mt6323_pwrc_probe(struct platform_device *pdev)
>   	pwrc->base = res->start;
>   	pwrc->regmap = mt6397_chip->regmap;
>   	pwrc->dev = &pdev->dev;
> -	mt_pwrc = pwrc;
>   
> -	pm_power_off = &mt6323_do_pwroff;
> +	ret = devm_register_sys_off_handler(pwrc->dev,
> +					    SYS_OFF_MODE_POWER_OFF,
> +					    SYS_OFF_PRIO_DEFAULT,
> +					    mt6323_do_pwroff,
> +					    pwrc);

	if (ret)
		return dev_err_probe(....);

Regards,
Angelo

> +	if (ret) {
> +		dev_err(pwrc->dev, "failed to register power-off handler: %d\n", ret);
> +		return ret;
> +	}
>   


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ