mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
power: reset: as3722-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> Link: https://lore.kernel.org/r/20240212162831.67838-16-afd@ti.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
parent
77b61173c2
commit
348fde771c
@ -11,6 +11,7 @@
|
|||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/reboot.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
|
||||||
struct as3722_poweroff {
|
struct as3722_poweroff {
|
||||||
@ -18,22 +19,18 @@ struct as3722_poweroff {
|
|||||||
struct as3722 *as3722;
|
struct as3722 *as3722;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct as3722_poweroff *as3722_pm_poweroff;
|
static int as3722_pm_power_off(struct sys_off_data *data)
|
||||||
|
|
||||||
static void as3722_pm_power_off(void)
|
|
||||||
{
|
{
|
||||||
|
struct as3722_poweroff *as3722_pm_poweroff = data->cb_data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!as3722_pm_poweroff) {
|
|
||||||
pr_err("AS3722 poweroff is not initialised\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = as3722_update_bits(as3722_pm_poweroff->as3722,
|
ret = as3722_update_bits(as3722_pm_poweroff->as3722,
|
||||||
AS3722_RESET_CONTROL_REG, AS3722_POWER_OFF, AS3722_POWER_OFF);
|
AS3722_RESET_CONTROL_REG, AS3722_POWER_OFF, AS3722_POWER_OFF);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(as3722_pm_poweroff->dev,
|
dev_err(as3722_pm_poweroff->dev,
|
||||||
"RESET_CONTROL_REG update failed, %d\n", ret);
|
"RESET_CONTROL_REG update failed, %d\n", ret);
|
||||||
|
|
||||||
|
return NOTIFY_DONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int as3722_poweroff_probe(struct platform_device *pdev)
|
static int as3722_poweroff_probe(struct platform_device *pdev)
|
||||||
@ -54,26 +51,21 @@ static int as3722_poweroff_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
as3722_poweroff->as3722 = dev_get_drvdata(pdev->dev.parent);
|
as3722_poweroff->as3722 = dev_get_drvdata(pdev->dev.parent);
|
||||||
as3722_poweroff->dev = &pdev->dev;
|
as3722_poweroff->dev = &pdev->dev;
|
||||||
as3722_pm_poweroff = as3722_poweroff;
|
|
||||||
if (!pm_power_off)
|
return devm_register_sys_off_handler(as3722_poweroff->dev,
|
||||||
pm_power_off = as3722_pm_power_off;
|
SYS_OFF_MODE_POWER_OFF,
|
||||||
|
SYS_OFF_PRIO_DEFAULT,
|
||||||
|
as3722_pm_power_off,
|
||||||
|
as3722_poweroff);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void as3722_poweroff_remove(struct platform_device *pdev)
|
|
||||||
{
|
|
||||||
if (pm_power_off == as3722_pm_power_off)
|
|
||||||
pm_power_off = NULL;
|
|
||||||
as3722_pm_poweroff = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct platform_driver as3722_poweroff_driver = {
|
static struct platform_driver as3722_poweroff_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "as3722-power-off",
|
.name = "as3722-power-off",
|
||||||
},
|
},
|
||||||
.probe = as3722_poweroff_probe,
|
.probe = as3722_poweroff_probe,
|
||||||
.remove_new = as3722_poweroff_remove,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module_platform_driver(as3722_poweroff_driver);
|
module_platform_driver(as3722_poweroff_driver);
|
||||||
|
Loading…
Reference in New Issue
Block a user