mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-04 17:44:14 +08:00
power: reset: atc260x-poweroff: Use devm_register_sys_off_handler(POWER_OFF)
Use device life-cycle managed register function to simplify probe and exit paths. Signed-off-by: Andrew Davis <afd@ti.com> Reviewed-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Link: https://lore.kernel.org/r/20240212162831.67838-3-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
parent
f22e835028
commit
ab1439b051
@ -19,9 +19,6 @@ struct atc260x_pwrc {
|
||||
int (*do_poweroff)(const struct atc260x_pwrc *pwrc, bool restart);
|
||||
};
|
||||
|
||||
/* Global variable needed only for pm_power_off */
|
||||
static struct atc260x_pwrc *atc260x_pwrc_data;
|
||||
|
||||
static int atc2603c_do_poweroff(const struct atc260x_pwrc *pwrc, bool restart)
|
||||
{
|
||||
int ret, deep_sleep = 0;
|
||||
@ -164,11 +161,15 @@ static int atc2609a_init(const struct atc260x_pwrc *pwrc)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void atc260x_pwrc_pm_handler(void)
|
||||
static int atc260x_pwrc_pm_handler(struct sys_off_data *data)
|
||||
{
|
||||
atc260x_pwrc_data->do_poweroff(atc260x_pwrc_data, false);
|
||||
struct atc260x_pwrc *pwrc = data->cb_data;
|
||||
|
||||
pwrc->do_poweroff(pwrc, false);
|
||||
|
||||
WARN_ONCE(1, "Unable to power off system\n");
|
||||
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static int atc260x_pwrc_restart_handler(struct sys_off_data *data)
|
||||
@ -211,14 +212,14 @@ static int atc260x_pwrc_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
platform_set_drvdata(pdev, priv);
|
||||
|
||||
if (!pm_power_off) {
|
||||
atc260x_pwrc_data = priv;
|
||||
pm_power_off = atc260x_pwrc_pm_handler;
|
||||
} else {
|
||||
dev_warn(priv->dev, "Poweroff callback already assigned\n");
|
||||
}
|
||||
ret = devm_register_sys_off_handler(priv->dev,
|
||||
SYS_OFF_MODE_POWER_OFF,
|
||||
SYS_OFF_PRIO_DEFAULT,
|
||||
atc260x_pwrc_pm_handler,
|
||||
priv);
|
||||
if (ret)
|
||||
dev_err(priv->dev, "failed to register power-off handler: %d\n",
|
||||
ret);
|
||||
|
||||
ret = devm_register_sys_off_handler(priv->dev,
|
||||
SYS_OFF_MODE_RESTART,
|
||||
@ -232,19 +233,8 @@ static int atc260x_pwrc_probe(struct platform_device *pdev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void atc260x_pwrc_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct atc260x_pwrc *priv = platform_get_drvdata(pdev);
|
||||
|
||||
if (atc260x_pwrc_data == priv) {
|
||||
pm_power_off = NULL;
|
||||
atc260x_pwrc_data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static struct platform_driver atc260x_pwrc_driver = {
|
||||
.probe = atc260x_pwrc_probe,
|
||||
.remove_new = atc260x_pwrc_remove,
|
||||
.driver = {
|
||||
.name = "atc260x-pwrc",
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user