Commit 8e6a4396 authored by Andrew Davis's avatar Andrew Davis Committed by Mark Brown

spi: sprd: adi: Use devm_register_restart_handler()

Use device life-cycle managed register function to simplify probe error
path and eliminate need for explicit remove function.
Signed-off-by: default avatarAndrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20231117161006.87734-5-afd@ti.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4c3ff31a
...@@ -138,8 +138,7 @@ struct sprd_adi_data { ...@@ -138,8 +138,7 @@ struct sprd_adi_data {
u32 slave_offset; u32 slave_offset;
u32 slave_addr_size; u32 slave_addr_size;
int (*read_check)(u32 val, u32 reg); int (*read_check)(u32 val, u32 reg);
int (*restart)(struct notifier_block *this, int (*restart)(struct sys_off_data *data);
unsigned long mode, void *cmd);
void (*wdg_rst)(void *p); void (*wdg_rst)(void *p);
}; };
...@@ -150,7 +149,6 @@ struct sprd_adi { ...@@ -150,7 +149,6 @@ struct sprd_adi {
struct hwspinlock *hwlock; struct hwspinlock *hwlock;
unsigned long slave_vbase; unsigned long slave_vbase;
unsigned long slave_pbase; unsigned long slave_pbase;
struct notifier_block restart_handler;
const struct sprd_adi_data *data; const struct sprd_adi_data *data;
}; };
...@@ -370,11 +368,9 @@ static void sprd_adi_set_wdt_rst_mode(void *p) ...@@ -370,11 +368,9 @@ static void sprd_adi_set_wdt_rst_mode(void *p)
#endif #endif
} }
static int sprd_adi_restart(struct notifier_block *this, unsigned long mode, static int sprd_adi_restart(struct sprd_adi *sadi, unsigned long mode,
void *cmd, struct sprd_adi_wdg *wdg) const char *cmd, struct sprd_adi_wdg *wdg)
{ {
struct sprd_adi *sadi = container_of(this, struct sprd_adi,
restart_handler);
u32 val, reboot_mode = 0; u32 val, reboot_mode = 0;
if (!cmd) if (!cmd)
...@@ -448,8 +444,7 @@ static int sprd_adi_restart(struct notifier_block *this, unsigned long mode, ...@@ -448,8 +444,7 @@ static int sprd_adi_restart(struct notifier_block *this, unsigned long mode,
return NOTIFY_DONE; return NOTIFY_DONE;
} }
static int sprd_adi_restart_sc9860(struct notifier_block *this, static int sprd_adi_restart_sc9860(struct sys_off_data *data)
unsigned long mode, void *cmd)
{ {
struct sprd_adi_wdg wdg = { struct sprd_adi_wdg wdg = {
.base = PMIC_WDG_BASE, .base = PMIC_WDG_BASE,
...@@ -458,7 +453,7 @@ static int sprd_adi_restart_sc9860(struct notifier_block *this, ...@@ -458,7 +453,7 @@ static int sprd_adi_restart_sc9860(struct notifier_block *this,
.wdg_clk = PMIC_CLK_EN, .wdg_clk = PMIC_CLK_EN,
}; };
return sprd_adi_restart(this, mode, cmd, &wdg); return sprd_adi_restart(data->cb_data, data->mode, data->cmd, &wdg);
} }
static void sprd_adi_hw_init(struct sprd_adi *sadi) static void sprd_adi_hw_init(struct sprd_adi *sadi)
...@@ -590,9 +585,9 @@ static int sprd_adi_probe(struct platform_device *pdev) ...@@ -590,9 +585,9 @@ static int sprd_adi_probe(struct platform_device *pdev)
} }
if (sadi->data->restart) { if (sadi->data->restart) {
sadi->restart_handler.notifier_call = sadi->data->restart; ret = devm_register_restart_handler(&pdev->dev,
sadi->restart_handler.priority = 128; sadi->data->restart,
ret = register_restart_handler(&sadi->restart_handler); sadi);
if (ret) { if (ret) {
dev_err(&pdev->dev, "can not register restart handler\n"); dev_err(&pdev->dev, "can not register restart handler\n");
goto put_ctlr; goto put_ctlr;
...@@ -606,14 +601,6 @@ static int sprd_adi_probe(struct platform_device *pdev) ...@@ -606,14 +601,6 @@ static int sprd_adi_probe(struct platform_device *pdev)
return ret; return ret;
} }
static void sprd_adi_remove(struct platform_device *pdev)
{
struct spi_controller *ctlr = dev_get_drvdata(&pdev->dev);
struct sprd_adi *sadi = spi_controller_get_devdata(ctlr);
unregister_restart_handler(&sadi->restart_handler);
}
static struct sprd_adi_data sc9860_data = { static struct sprd_adi_data sc9860_data = {
.slave_offset = ADI_10BIT_SLAVE_OFFSET, .slave_offset = ADI_10BIT_SLAVE_OFFSET,
.slave_addr_size = ADI_10BIT_SLAVE_ADDR_SIZE, .slave_addr_size = ADI_10BIT_SLAVE_ADDR_SIZE,
...@@ -657,7 +644,6 @@ static struct platform_driver sprd_adi_driver = { ...@@ -657,7 +644,6 @@ static struct platform_driver sprd_adi_driver = {
.of_match_table = sprd_adi_of_match, .of_match_table = sprd_adi_of_match,
}, },
.probe = sprd_adi_probe, .probe = sprd_adi_probe,
.remove_new = sprd_adi_remove,
}; };
module_platform_driver(sprd_adi_driver); module_platform_driver(sprd_adi_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment