power: reset: gemini-poweroff: Use devm_register_sys_off_handler(POWER_OFF)

Use device life-cycle managed register function to simplify probe.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20240212162831.67838-17-afd@ti.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
Andrew Davis 2024-02-12 10:28:28 -06:00 committed by Sebastian Reichel
parent 348fde771c
commit b6475c3f81

View File

@ -70,12 +70,9 @@ static irqreturn_t gemini_powerbutton_interrupt(int irq, void *data)
return IRQ_HANDLED;
}
/* This callback needs this static local as it has void as argument */
static struct gemini_powercon *gpw_poweroff;
static void gemini_poweroff(void)
static int gemini_poweroff(struct sys_off_data *data)
{
struct gemini_powercon *gpw = gpw_poweroff;
struct gemini_powercon *gpw = data->cb_data;
u32 val;
dev_crit(gpw->dev, "Gemini power off\n");
@ -86,6 +83,8 @@ static void gemini_poweroff(void)
val &= ~GEMINI_CTRL_ENABLE;
val |= GEMINI_CTRL_SHUTDOWN;
writel(val, gpw->base + GEMINI_PWC_CTRLREG);
return NOTIFY_DONE;
}
static int gemini_poweroff_probe(struct platform_device *pdev)
@ -148,8 +147,11 @@ static int gemini_poweroff_probe(struct platform_device *pdev)
if (ret)
return ret;
pm_power_off = gemini_poweroff;
gpw_poweroff = gpw;
ret = devm_register_sys_off_handler(dev, SYS_OFF_MODE_POWER_OFF,
SYS_OFF_PRIO_DEFAULT,
gemini_poweroff, gpw);
if (ret)
return ret;
dev_info(dev, "Gemini poweroff driver registered\n");