Re: [PATCH v17 02/12] power: reset: reboot-mode: Add firmware node based registration

Mukesh Ojha
2025-11-10T13:13:31Z

On Sun, Nov 09, 2025 at 08:07:15PM +0530, Shivendra Pratap wrote:
> The reboot-mode driver does not have a strict requirement for
> device-based registration. It primarily uses the device's of_node
> to read mode-<cmd> properties.
>
> Remove the dependency on struct device and introduce support for
> firmware node (fwnode) based registration. This enables drivers
> that are not associated with a struct device to leverage the
> reboot-mode framework.
>
> Signed-off-by: Shivendra Pratap <shivendra.pratap@oss.qualcomm.com>
> ---
> drivers/power/reset/reboot-mode.c | 19 ++++++++++++++++---
> include/linux/reboot-mode.h | 4 +++-
> 2 files changed, 19 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
> index ac4223794083f36960b2bd37a601b7e1f1872de5..eff60d6e04df2cb84ba59d38512654336f272f8a 100644
> --- a/drivers/power/reset/reboot-mode.c
> +++ b/drivers/power/reset/reboot-mode.c
> @@ -8,10 +8,12 @@
> #include <linux/device.h>
> #include <linux/init.h>
> #include <linux/kernel.h>
> +#include <linux/list.h>

nit: Looks like stray change and belongs to other patch

> #include <linux/module.h>
> #include <linux/of.h>
> #include <linux/reboot.h>
> #include <linux/reboot-mode.h>
> +#include <linux/slab.h>
>
> #define PREFIX "mode-"
>
> @@ -67,18 +69,26 @@ static int reboot_mode_notify(struct notifier_block *this,
> /**
> * reboot_mode_register - register a reboot mode driver
> * @reboot: reboot mode driver
> + * @fwnode: Firmware node with reboot-mode configuration
> *
> * Returns: 0 on success or a negative error code on failure.
> */
> -int reboot_mode_register(struct reboot_mode_driver *reboot)
> +int reboot_mode_register(struct reboot_mode_driver *reboot, struct fwnode_handle *fwnode)
> {
> struct mode_info *info;
> struct mode_info *next;
> + struct device_node *np;
> struct property *prop;
> - struct device_node *np = reboot->dev->of_node;
> size_t len = strlen(PREFIX);
> int ret;
>
> + if (!fwnode)
> + return -EINVAL;
> +
> + np = to_of_node(fwnode);
> + if (!np)
> + return -EINVAL;
> +
> INIT_LIST_HEAD(&reboot->head);
>
> for_each_property_of_node(np, prop) {
> @@ -168,11 +178,14 @@ int devm_reboot_mode_register(struct device *dev,
> struct reboot_mode_driver **dr;
> int rc;
>
> + if (!reboot->dev || !reboot->dev->of_node)
> + return -EINVAL;
> +
> dr = devres_alloc(devm_reboot_mode_release, sizeof(*dr), GFP_KERNEL);
> if (!dr)
> return -ENOMEM;
>
> - rc = reboot_mode_register(reboot);
> + rc = reboot_mode_register(reboot, of_fwnode_handle(reboot->dev->of_node));
> if (rc) {
> devres_free(dr);
> return rc;
> diff --git a/include/linux/reboot-mode.h b/include/linux/reboot-mode.h
> index 4a2abb38d1d612ec0fdf05eb18c98b210f631b7f..22f707ade4ba93592823ea8718d467dbfc5ffd7c 100644
> --- a/include/linux/reboot-mode.h
> +++ b/include/linux/reboot-mode.h
> @@ -2,6 +2,8 @@
> #ifndef __REBOOT_MODE_H__
> #define __REBOOT_MODE_H__
>
> +#include <linux/fwnode.h>
> +
> struct reboot_mode_driver {
> struct device *dev;
> struct list_head head;
> @@ -9,7 +11,7 @@ struct reboot_mode_driver {
> struct notifier_block reboot_notifier;
> };
>
> -int reboot_mode_register(struct reboot_mode_driver *reboot);
> +int reboot_mode_register(struct reboot_mode_driver *reboot, struct fwnode_handle *fwnode);
> int reboot_mode_unregister(struct reboot_mode_driver *reboot);
> int devm_reboot_mode_register(struct device *dev,
> struct reboot_mode_driver *reboot);
>
> --
> 2.34.1
>

--
-Mukesh Ojha