2023-11-17 16:10:54

by Andrew Davis

[permalink] [raw]
Subject: [PATCH RFC 0/5] Deprecate register_restart_handler()

Hello all,

Explanation is in patch #1.

The rest of this series is a set of representative examples of converting
away from the old API. They should be valid and can be taken by their
respective maintainers even if patch #1 doesn't find acceptance.

Thanks,
Andrew

Andrew Davis (5):
kernel/reboot: Deprecate register_restart_handler()
drivers/soc/litex: Use devm_register_restart_handler()
power: reset: gpio-restart: Use devm_register_sys_off_handler()
spi: sprd: adi: Use devm_register_restart_handler()
firmware: psci: Use register_sys_off_handler(SYS_OFF_MODE_RESTART)

drivers/firmware/psci/psci.c | 10 ++-------
drivers/power/reset/gpio-restart.c | 34 ++++++++----------------------
drivers/soc/litex/litex_soc_ctrl.c | 23 +++++---------------
drivers/spi/spi-sprd-adi.c | 30 +++++++-------------------
include/linux/reboot.h | 8 +++++--
kernel/reboot.c | 3 +++
6 files changed, 33 insertions(+), 75 deletions(-)

--
2.39.2


2023-11-17 16:11:17

by Andrew Davis

[permalink] [raw]
Subject: [PATCH RFC 5/5] firmware: psci: Use register_sys_off_handler(SYS_OFF_MODE_RESTART)

Function register_restart_handler() is deprecated. Using this new API
removes our need to keep and manage a struct notifier_block.

Signed-off-by: Andrew Davis <[email protected]>
---
drivers/firmware/psci/psci.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index d9629ff878619..767a5af5384b4 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -305,8 +305,7 @@ static int get_set_conduit_method(const struct device_node *np)
return 0;
}

-static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
- void *data)
+static int psci_sys_reset(struct sys_off_data *data)
{
if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
psci_system_reset2_supported) {
@@ -323,11 +322,6 @@ static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
return NOTIFY_DONE;
}

-static struct notifier_block psci_sys_reset_nb = {
- .notifier_call = psci_sys_reset,
- .priority = 129,
-};
-
static void psci_sys_poweroff(void)
{
invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
@@ -623,7 +617,7 @@ static void __init psci_0_2_set_functions(void)
.migrate_info_type = psci_migrate_info_type,
};

- register_restart_handler(&psci_sys_reset_nb);
+ register_sys_off_handler(SYS_OFF_MODE_RESTART, 129, psci_sys_reset, NULL);

pm_power_off = psci_sys_poweroff;
}
--
2.39.2

2023-11-17 16:11:32

by Andrew Davis

[permalink] [raw]
Subject: [PATCH RFC 2/5] 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 <[email protected]>
---
drivers/soc/litex/litex_soc_ctrl.c | 23 +++++------------------
1 file changed, 5 insertions(+), 18 deletions(-)

diff --git a/drivers/soc/litex/litex_soc_ctrl.c b/drivers/soc/litex/litex_soc_ctrl.c
index 10813299aa106..7a0096d93c73d 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;
@@ -107,11 +104,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);
@@ -120,20 +115,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 = of_match_ptr(litex_soc_ctrl_of_match)
},
.probe = litex_soc_ctrl_probe,
- .remove_new = litex_soc_ctrl_remove,
};

module_platform_driver(litex_soc_ctrl_driver);
--
2.39.2

2023-11-17 16:11:38

by Andrew Davis

[permalink] [raw]
Subject: [PATCH RFC 4/5] 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 <[email protected]>
---
drivers/spi/spi-sprd-adi.c | 30 ++++++++----------------------
1 file changed, 8 insertions(+), 22 deletions(-)

diff --git a/drivers/spi/spi-sprd-adi.c b/drivers/spi/spi-sprd-adi.c
index bf01feedbf93f..58c3badd9c79a 100644
--- a/drivers/spi/spi-sprd-adi.c
+++ b/drivers/spi/spi-sprd-adi.c
@@ -138,8 +138,7 @@ struct sprd_adi_data {
u32 slave_offset;
u32 slave_addr_size;
int (*read_check)(u32 val, u32 reg);
- int (*restart)(struct notifier_block *this,
- unsigned long mode, void *cmd);
+ int (*restart)(struct sys_off_data *data);
void (*wdg_rst)(void *p);
};

@@ -150,7 +149,6 @@ struct sprd_adi {
struct hwspinlock *hwlock;
unsigned long slave_vbase;
unsigned long slave_pbase;
- struct notifier_block restart_handler;
const struct sprd_adi_data *data;
};

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

-static int sprd_adi_restart(struct notifier_block *this, unsigned long mode,
- void *cmd, struct sprd_adi_wdg *wdg)
+static int sprd_adi_restart(struct sprd_adi *sadi, unsigned long mode,
+ 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;

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

-static int sprd_adi_restart_sc9860(struct notifier_block *this,
- unsigned long mode, void *cmd)
+static int sprd_adi_restart_sc9860(struct sys_off_data *data)
{
struct sprd_adi_wdg wdg = {
.base = PMIC_WDG_BASE,
@@ -458,7 +453,7 @@ static int sprd_adi_restart_sc9860(struct notifier_block *this,
.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)
@@ -590,9 +585,9 @@ static int sprd_adi_probe(struct platform_device *pdev)
}

if (sadi->data->restart) {
- sadi->restart_handler.notifier_call = sadi->data->restart;
- sadi->restart_handler.priority = 128;
- ret = register_restart_handler(&sadi->restart_handler);
+ ret = devm_register_restart_handler(&pdev->dev,
+ sadi->data->restart,
+ sadi);
if (ret) {
dev_err(&pdev->dev, "can not register restart handler\n");
goto put_ctlr;
@@ -606,14 +601,6 @@ static int sprd_adi_probe(struct platform_device *pdev)
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 = {
.slave_offset = ADI_10BIT_SLAVE_OFFSET,
.slave_addr_size = ADI_10BIT_SLAVE_ADDR_SIZE,
@@ -657,7 +644,6 @@ static struct platform_driver sprd_adi_driver = {
.of_match_table = sprd_adi_of_match,
},
.probe = sprd_adi_probe,
- .remove_new = sprd_adi_remove,
};
module_platform_driver(sprd_adi_driver);

--
2.39.2

2023-11-17 16:11:44

by Andrew Davis

[permalink] [raw]
Subject: [PATCH RFC 1/5] kernel/reboot: Deprecate register_restart_handler()

There are now two ways to add a handler to the restart_handler_list.
Two ways to do the same thing is bad design, so let's unify on using
the new method register_sys_off_handler() everywhere.

Reasons:
* The other register_*_handler functions take a callback, this old
API takes a notifier_block, which makes it confusing with the
register_*_notifier class of functions.
* register_sys_off_handler (new API) is a more unified API allowing for
registering several system off types.
* The new API has more helpers built around it now, including devm and
platform helpers.
* The new API manages the struct notifier_block for us, simplifying using
code.

Mark register_restart_handler() as deprecated to try to warn off new users
while we finish converting the remaining existing users.

Signed-off-by: Andrew Davis <[email protected]>
---
include/linux/reboot.h | 8 ++++++--
kernel/reboot.c | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/linux/reboot.h b/include/linux/reboot.h
index c4cc3b89ced1f..c5fff3157b191 100644
--- a/include/linux/reboot.h
+++ b/include/linux/reboot.h
@@ -46,8 +46,12 @@ extern int unregister_reboot_notifier(struct notifier_block *);

extern int devm_register_reboot_notifier(struct device *, struct notifier_block *);

-extern int register_restart_handler(struct notifier_block *);
-extern int unregister_restart_handler(struct notifier_block *);
+/*
+ * This function is deprecated, use register_sys_off_handler(SYS_OFF_MODE_RESTART)
+ * or devm_register_restart_handler() instead.
+ */
+extern int __deprecated register_restart_handler(struct notifier_block *);
+extern int __deprecated unregister_restart_handler(struct notifier_block *);
extern void do_kernel_restart(char *cmd);

/*
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 395a0ea3c7a8a..768ce97829f41 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -189,6 +189,9 @@ static ATOMIC_NOTIFIER_HEAD(restart_handler_list);
*
* Currently always returns zero, as atomic_notifier_chain_register()
* always returns zero.
+ *
+ * This function is deprecated, use register_sys_off_handler(SYS_OFF_MODE_RESTART)
+ * or devm_register_restart_handler() instead.
*/
int register_restart_handler(struct notifier_block *nb)
{
--
2.39.2

2023-11-17 16:11:56

by Andrew Davis

[permalink] [raw]
Subject: [PATCH RFC 3/5] power: reset: gpio-restart: Use devm_register_sys_off_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 <[email protected]>
---
drivers/power/reset/gpio-restart.c | 34 ++++++++----------------------
1 file changed, 9 insertions(+), 25 deletions(-)

diff --git a/drivers/power/reset/gpio-restart.c b/drivers/power/reset/gpio-restart.c
index 3aa19765772dc..d1e177176fa1f 100644
--- a/drivers/power/reset/gpio-restart.c
+++ b/drivers/power/reset/gpio-restart.c
@@ -17,17 +17,14 @@

struct gpio_restart {
struct gpio_desc *reset_gpio;
- struct notifier_block restart_handler;
u32 active_delay_ms;
u32 inactive_delay_ms;
u32 wait_delay_ms;
};

-static int gpio_restart_notify(struct notifier_block *this,
- unsigned long mode, void *cmd)
+static int gpio_restart_notify(struct sys_off_data *data)
{
- struct gpio_restart *gpio_restart =
- container_of(this, struct gpio_restart, restart_handler);
+ struct gpio_restart *gpio_restart = data->cb_data;

/* drive it active, also inactive->active edge */
gpiod_direction_output(gpio_restart->reset_gpio, 1);
@@ -52,6 +49,7 @@ static int gpio_restart_probe(struct platform_device *pdev)
{
struct gpio_restart *gpio_restart;
bool open_source = false;
+ int priority = 129;
u32 property;
int ret;

@@ -71,8 +69,6 @@ static int gpio_restart_probe(struct platform_device *pdev)
return ret;
}

- gpio_restart->restart_handler.notifier_call = gpio_restart_notify;
- gpio_restart->restart_handler.priority = 129;
gpio_restart->active_delay_ms = 100;
gpio_restart->inactive_delay_ms = 100;
gpio_restart->wait_delay_ms = 3000;
@@ -83,7 +79,7 @@ static int gpio_restart_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Invalid priority property: %u\n",
property);
else
- gpio_restart->restart_handler.priority = property;
+ priority = property;
}

of_property_read_u32(pdev->dev.of_node, "active-delay",
@@ -93,9 +89,11 @@ static int gpio_restart_probe(struct platform_device *pdev)
of_property_read_u32(pdev->dev.of_node, "wait-delay",
&gpio_restart->wait_delay_ms);

- platform_set_drvdata(pdev, gpio_restart);
-
- ret = register_restart_handler(&gpio_restart->restart_handler);
+ ret = devm_register_sys_off_handler(&pdev->dev,
+ SYS_OFF_MODE_RESTART,
+ priority,
+ gpio_restart_notify,
+ gpio_restart);
if (ret) {
dev_err(&pdev->dev, "%s: cannot register restart handler, %d\n",
__func__, ret);
@@ -105,19 +103,6 @@ static int gpio_restart_probe(struct platform_device *pdev)
return 0;
}

-static void gpio_restart_remove(struct platform_device *pdev)
-{
- struct gpio_restart *gpio_restart = platform_get_drvdata(pdev);
- int ret;
-
- ret = unregister_restart_handler(&gpio_restart->restart_handler);
- if (ret) {
- dev_err(&pdev->dev,
- "%s: cannot unregister restart handler, %d\n",
- __func__, ret);
- }
-}
-
static const struct of_device_id of_gpio_restart_match[] = {
{ .compatible = "gpio-restart", },
{},
@@ -125,7 +110,6 @@ static const struct of_device_id of_gpio_restart_match[] = {

static struct platform_driver gpio_restart_driver = {
.probe = gpio_restart_probe,
- .remove_new = gpio_restart_remove,
.driver = {
.name = "restart-gpio",
.of_match_table = of_gpio_restart_match,
--
2.39.2

2023-11-27 16:48:56

by Mark Brown

[permalink] [raw]
Subject: Re: (subset) [PATCH RFC 0/5] Deprecate register_restart_handler()

On Fri, 17 Nov 2023 10:10:01 -0600, Andrew Davis wrote:
> Explanation is in patch #1.
>
> The rest of this series is a set of representative examples of converting
> away from the old API. They should be valid and can be taken by their
> respective maintainers even if patch #1 doesn't find acceptance.
>
> Thanks,
> Andrew
>
> [...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[4/5] spi: sprd: adi: Use devm_register_restart_handler()
commit: 8e6a43961f24cf841d3c0d199521d0b284d948b9

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

2023-11-29 10:03:20

by Gabriel L. Somlo

[permalink] [raw]
Subject: Re: [PATCH RFC 2/5] drivers/soc/litex: Use devm_register_restart_handler()

On Fri, Nov 17, 2023 at 10:10:03AM -0600, Andrew Davis wrote:
> Use device life-cycle managed register function to simplify probe error
> path and eliminate need for explicit remove function.
>
> Signed-off-by: Andrew Davis <[email protected]>

Reviewed-by: Gabriel Somlo <[email protected]>

Thanks much,
--Gabriel
> ---
> drivers/soc/litex/litex_soc_ctrl.c | 23 +++++------------------
> 1 file changed, 5 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/soc/litex/litex_soc_ctrl.c b/drivers/soc/litex/litex_soc_ctrl.c
> index 10813299aa106..7a0096d93c73d 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;
> @@ -107,11 +104,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);
> @@ -120,20 +115,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 = of_match_ptr(litex_soc_ctrl_of_match)
> },
> .probe = litex_soc_ctrl_probe,
> - .remove_new = litex_soc_ctrl_remove,
> };
>
> module_platform_driver(litex_soc_ctrl_driver);
> --
> 2.39.2
>

2023-11-29 10:10:13

by Gabriel L. Somlo

[permalink] [raw]
Subject: Re: (subset) [PATCH RFC 0/5] Deprecate register_restart_handler()

Hi Mark,

On Mon, Nov 27, 2023 at 04:48:29PM +0000, Mark Brown wrote:
> On Fri, 17 Nov 2023 10:10:01 -0600, Andrew Davis wrote:
> > Explanation is in patch #1.
> >
> > The rest of this series is a set of representative examples of converting
> > away from the old API. They should be valid and can be taken by their
> > respective maintainers even if patch #1 doesn't find acceptance.
> >
> > Thanks,
> > Andrew
> >
> > [...]
>
> Applied to
>
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
>
> Thanks!
>
> [4/5] spi: sprd: adi: Use devm_register_restart_handler()
> commit: 8e6a43961f24cf841d3c0d199521d0b284d948b9

Any chance you can also pick up

[2/5] drivers/soc/litex: Use devm_register_restart_handler()

from this series?

I'm maintaining the LiteX (FPGA SoC) related drivers, but we don't as of
yet have a dedicated "path to upstream" of our own -- we've been mostly
going through specific subsystem trees (e.g. mmc, block, networking, etc.),
for mostly device drivers, up until now...

If not, no worries, I need to dedicate some time to figuring this out
eventually anyway :)

Thanks much,
--Gabriel

> All being well this means that it will be integrated into the linux-next
> tree (usually sometime in the next 24 hours) and sent to Linus during
> the next merge window (or sooner if it is a bug fix), however if
> problems are discovered then the patch may be dropped or reverted.
>
> You may get further e-mails resulting from automated or manual testing
> and review of the tree, please engage with people reporting problems and
> send followup patches addressing any issues that are reported if needed.
>
> If any updates are required or you are submitting further changes they
> should be sent as incremental updates against current git, existing
> patches will not be replaced.
>
> Please add any relevant lists and maintainers to the CCs when replying
> to this mail.
>
> Thanks,
> Mark
>

2023-12-20 20:35:43

by Gabriel L. Somlo

[permalink] [raw]
Subject: Re: [PATCH RFC 2/5] drivers/soc/litex: Use devm_register_restart_handler()

On Fri, Nov 17, 2023 at 10:10:03AM -0600, Andrew Davis wrote:
> Use device life-cycle managed register function to simplify probe error
> path and eliminate need for explicit remove function.
>
> Signed-off-by: Andrew Davis <[email protected]>

Reviewed-by: Gabriel Somlo <[email protected]>

Arnd: the original patch is available here for the purpose of pulling via
the soc tree:
https://lore.kernel.org/lkml/[email protected]/

Thanks,
--Gabriel

> ---
> drivers/soc/litex/litex_soc_ctrl.c | 23 +++++------------------
> 1 file changed, 5 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/soc/litex/litex_soc_ctrl.c b/drivers/soc/litex/litex_soc_ctrl.c
> index 10813299aa106..7a0096d93c73d 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;
> @@ -107,11 +104,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);
> @@ -120,20 +115,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 = of_match_ptr(litex_soc_ctrl_of_match)
> },
> .probe = litex_soc_ctrl_probe,
> - .remove_new = litex_soc_ctrl_remove,
> };
>
> module_platform_driver(litex_soc_ctrl_driver);
> --
> 2.39.2
>