Skip to content

Commit 8e6a439

Browse files
glneobroonie
authored andcommitted
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: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20231117161006.87734-5-afd@ti.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4c3ff31 commit 8e6a439

1 file changed

Lines changed: 8 additions & 22 deletions

File tree

drivers/spi/spi-sprd-adi.c

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ struct sprd_adi_data {
138138
u32 slave_offset;
139139
u32 slave_addr_size;
140140
int (*read_check)(u32 val, u32 reg);
141-
int (*restart)(struct notifier_block *this,
142-
unsigned long mode, void *cmd);
141+
int (*restart)(struct sys_off_data *data);
143142
void (*wdg_rst)(void *p);
144143
};
145144

@@ -150,7 +149,6 @@ struct sprd_adi {
150149
struct hwspinlock *hwlock;
151150
unsigned long slave_vbase;
152151
unsigned long slave_pbase;
153-
struct notifier_block restart_handler;
154152
const struct sprd_adi_data *data;
155153
};
156154

@@ -370,11 +368,9 @@ static void sprd_adi_set_wdt_rst_mode(void *p)
370368
#endif
371369
}
372370

373-
static int sprd_adi_restart(struct notifier_block *this, unsigned long mode,
374-
void *cmd, struct sprd_adi_wdg *wdg)
371+
static int sprd_adi_restart(struct sprd_adi *sadi, unsigned long mode,
372+
const char *cmd, struct sprd_adi_wdg *wdg)
375373
{
376-
struct sprd_adi *sadi = container_of(this, struct sprd_adi,
377-
restart_handler);
378374
u32 val, reboot_mode = 0;
379375

380376
if (!cmd)
@@ -448,8 +444,7 @@ static int sprd_adi_restart(struct notifier_block *this, unsigned long mode,
448444
return NOTIFY_DONE;
449445
}
450446

451-
static int sprd_adi_restart_sc9860(struct notifier_block *this,
452-
unsigned long mode, void *cmd)
447+
static int sprd_adi_restart_sc9860(struct sys_off_data *data)
453448
{
454449
struct sprd_adi_wdg wdg = {
455450
.base = PMIC_WDG_BASE,
@@ -458,7 +453,7 @@ static int sprd_adi_restart_sc9860(struct notifier_block *this,
458453
.wdg_clk = PMIC_CLK_EN,
459454
};
460455

461-
return sprd_adi_restart(this, mode, cmd, &wdg);
456+
return sprd_adi_restart(data->cb_data, data->mode, data->cmd, &wdg);
462457
}
463458

464459
static void sprd_adi_hw_init(struct sprd_adi *sadi)
@@ -590,9 +585,9 @@ static int sprd_adi_probe(struct platform_device *pdev)
590585
}
591586

592587
if (sadi->data->restart) {
593-
sadi->restart_handler.notifier_call = sadi->data->restart;
594-
sadi->restart_handler.priority = 128;
595-
ret = register_restart_handler(&sadi->restart_handler);
588+
ret = devm_register_restart_handler(&pdev->dev,
589+
sadi->data->restart,
590+
sadi);
596591
if (ret) {
597592
dev_err(&pdev->dev, "can not register restart handler\n");
598593
goto put_ctlr;
@@ -606,14 +601,6 @@ static int sprd_adi_probe(struct platform_device *pdev)
606601
return ret;
607602
}
608603

609-
static void sprd_adi_remove(struct platform_device *pdev)
610-
{
611-
struct spi_controller *ctlr = dev_get_drvdata(&pdev->dev);
612-
struct sprd_adi *sadi = spi_controller_get_devdata(ctlr);
613-
614-
unregister_restart_handler(&sadi->restart_handler);
615-
}
616-
617604
static struct sprd_adi_data sc9860_data = {
618605
.slave_offset = ADI_10BIT_SLAVE_OFFSET,
619606
.slave_addr_size = ADI_10BIT_SLAVE_ADDR_SIZE,
@@ -657,7 +644,6 @@ static struct platform_driver sprd_adi_driver = {
657644
.of_match_table = sprd_adi_of_match,
658645
},
659646
.probe = sprd_adi_probe,
660-
.remove_new = sprd_adi_remove,
661647
};
662648
module_platform_driver(sprd_adi_driver);
663649

0 commit comments

Comments
 (0)