Skip to content

Commit c734586

Browse files
glneogsomlo
authored andcommitted
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>
1 parent 40384c8 commit c734586

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

drivers/soc/litex/litex_soc_ctrl.c

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,11 @@ static int litex_check_csr_access(void __iomem *reg_addr)
6969

7070
struct litex_soc_ctrl_device {
7171
void __iomem *base;
72-
struct notifier_block reset_nb;
7372
};
7473

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)
7775
{
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;
8077

8178
litex_write32(soc_ctrl_dev->base + RESET_REG_OFF, RESET_REG_VALUE);
8279
return NOTIFY_DONE;
@@ -105,11 +102,9 @@ static int litex_soc_ctrl_probe(struct platform_device *pdev)
105102
if (error)
106103
return error;
107104

108-
platform_set_drvdata(pdev, soc_ctrl_dev);
109-
110-
soc_ctrl_dev->reset_nb.notifier_call = litex_reset_handler;
111-
soc_ctrl_dev->reset_nb.priority = 128;
112-
error = register_restart_handler(&soc_ctrl_dev->reset_nb);
105+
error = devm_register_restart_handler(&pdev->dev,
106+
litex_reset_handler,
107+
soc_ctrl_dev);
113108
if (error) {
114109
dev_warn(&pdev->dev, "cannot register restart handler: %d\n",
115110
error);
@@ -118,20 +113,12 @@ static int litex_soc_ctrl_probe(struct platform_device *pdev)
118113
return 0;
119114
}
120115

121-
static void litex_soc_ctrl_remove(struct platform_device *pdev)
122-
{
123-
struct litex_soc_ctrl_device *soc_ctrl_dev = platform_get_drvdata(pdev);
124-
125-
unregister_restart_handler(&soc_ctrl_dev->reset_nb);
126-
}
127-
128116
static struct platform_driver litex_soc_ctrl_driver = {
129117
.driver = {
130118
.name = "litex-soc-controller",
131119
.of_match_table = litex_soc_ctrl_of_match,
132120
},
133121
.probe = litex_soc_ctrl_probe,
134-
.remove = litex_soc_ctrl_remove,
135122
};
136123

137124
module_platform_driver(litex_soc_ctrl_driver);

0 commit comments

Comments
 (0)