Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andrew Davis and committed by
Gabriel Somlo
c7345869 40384c84

+5 -18
+5 -18
drivers/soc/litex/litex_soc_ctrl.c
··· 69 69 70 70 struct litex_soc_ctrl_device { 71 71 void __iomem *base; 72 - struct notifier_block reset_nb; 73 72 }; 74 73 75 - static int litex_reset_handler(struct notifier_block *this, unsigned long mode, 76 - void *cmd) 74 + static int litex_reset_handler(struct sys_off_data *data) 77 75 { 78 - struct litex_soc_ctrl_device *soc_ctrl_dev = 79 - container_of(this, struct litex_soc_ctrl_device, reset_nb); 76 + struct litex_soc_ctrl_device *soc_ctrl_dev = data->cb_data; 80 77 81 78 litex_write32(soc_ctrl_dev->base + RESET_REG_OFF, RESET_REG_VALUE); 82 79 return NOTIFY_DONE; ··· 102 105 if (error) 103 106 return error; 104 107 105 - platform_set_drvdata(pdev, soc_ctrl_dev); 106 - 107 - soc_ctrl_dev->reset_nb.notifier_call = litex_reset_handler; 108 - soc_ctrl_dev->reset_nb.priority = 128; 109 - error = register_restart_handler(&soc_ctrl_dev->reset_nb); 108 + error = devm_register_restart_handler(&pdev->dev, 109 + litex_reset_handler, 110 + soc_ctrl_dev); 110 111 if (error) { 111 112 dev_warn(&pdev->dev, "cannot register restart handler: %d\n", 112 113 error); ··· 113 118 return 0; 114 119 } 115 120 116 - static void litex_soc_ctrl_remove(struct platform_device *pdev) 117 - { 118 - struct litex_soc_ctrl_device *soc_ctrl_dev = platform_get_drvdata(pdev); 119 - 120 - unregister_restart_handler(&soc_ctrl_dev->reset_nb); 121 - } 122 - 123 121 static struct platform_driver litex_soc_ctrl_driver = { 124 122 .driver = { 125 123 .name = "litex-soc-controller", 126 124 .of_match_table = litex_soc_ctrl_of_match, 127 125 }, 128 126 .probe = litex_soc_ctrl_probe, 129 - .remove = litex_soc_ctrl_remove, 130 127 }; 131 128 132 129 module_platform_driver(litex_soc_ctrl_driver);