diff options
author | Andrew Davis <afd@ti.com> | 2024-01-23 19:44:41 +0300 |
---|---|---|
committer | Gabriel Somlo <gsomlo@gmail.com> | 2025-01-19 22:05:35 +0300 |
commit | c7345869aa382b1e22691d51cbbd218d7f488a55 (patch) | |
tree | 954acd448d397a01b7a3a87d3bf0eded1e474b81 | |
parent | 40384c840ea1944d7c5a392e8975ed088ecf0b37 (diff) | |
download | linux-c7345869aa382b1e22691d51cbbd218d7f488a55.tar.xz |
drivers/soc/litex: 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>
Reviewed-by: Gabriel Somlo <gsomlo@gmail.com>
Link: https://lore.kernel.org/all/20240123164443.394642-3-afd@ti.com
Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
-rw-r--r-- | drivers/soc/litex/litex_soc_ctrl.c | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/drivers/soc/litex/litex_soc_ctrl.c b/drivers/soc/litex/litex_soc_ctrl.c index d08bfc8ef7be..104a5f9bfd26 100644 --- a/drivers/soc/litex/litex_soc_ctrl.c +++ b/drivers/soc/litex/litex_soc_ctrl.c @@ -69,14 +69,11 @@ static int litex_check_csr_access(void __iomem *reg_addr) struct litex_soc_ctrl_device { void __iomem *base; - struct notifier_block reset_nb; }; -static int litex_reset_handler(struct notifier_block *this, unsigned long mode, - void *cmd) +static int litex_reset_handler(struct sys_off_data *data) { - struct litex_soc_ctrl_device *soc_ctrl_dev = - container_of(this, struct litex_soc_ctrl_device, reset_nb); + struct litex_soc_ctrl_device *soc_ctrl_dev = data->cb_data; litex_write32(soc_ctrl_dev->base + RESET_REG_OFF, RESET_REG_VALUE); return NOTIFY_DONE; @@ -105,11 +102,9 @@ static int litex_soc_ctrl_probe(struct platform_device *pdev) if (error) return error; - platform_set_drvdata(pdev, soc_ctrl_dev); - - soc_ctrl_dev->reset_nb.notifier_call = litex_reset_handler; - soc_ctrl_dev->reset_nb.priority = 128; - error = register_restart_handler(&soc_ctrl_dev->reset_nb); + error = devm_register_restart_handler(&pdev->dev, + litex_reset_handler, + soc_ctrl_dev); if (error) { dev_warn(&pdev->dev, "cannot register restart handler: %d\n", error); @@ -118,20 +113,12 @@ static int litex_soc_ctrl_probe(struct platform_device *pdev) return 0; } -static void litex_soc_ctrl_remove(struct platform_device *pdev) -{ - struct litex_soc_ctrl_device *soc_ctrl_dev = platform_get_drvdata(pdev); - - unregister_restart_handler(&soc_ctrl_dev->reset_nb); -} - static struct platform_driver litex_soc_ctrl_driver = { .driver = { .name = "litex-soc-controller", .of_match_table = litex_soc_ctrl_of_match, }, .probe = litex_soc_ctrl_probe, - .remove = litex_soc_ctrl_remove, }; module_platform_driver(litex_soc_ctrl_driver); |