Re: [PATCH v12 1/8] power: reset: reboot-mode: Add device tree node-based registration

Shivendra Pratap
2025-07-22T16:17:31Z

On 7/22/2025 3:06 AM, Dmitry Baryshkov wrote:
> On Mon, Jul 21, 2025 at 11:58:48PM +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 and the device pointer for logging.
>>
>> Remove the dependency on struct device and introduce support for
>> Device Tree (DT) node-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 | 45 +++++++++++++++++++++++++++++----------
>> include/linux/reboot-mode.h | 6 +++++-
>> 2 files changed, 39 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
>> index fba53f638da04655e756b5f8b7d2d666d1379535..5dd3f06ca88cb28606d9fd2100ce03383c14d215 100644
>> --- a/drivers/power/reset/reboot-mode.c
>> +++ b/drivers/power/reset/reboot-mode.c
>> @@ -3,13 +3,17 @@
>> * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd
>> */
>>
>> +#define pr_fmt(fmt) "reboot-mode: " fmt
>> +
>> #include <linux/device.h>
>> #include <linux/init.h>
>> #include <linux/kernel.h>
>> +#include <linux/list.h>
>> #include <linux/module.h>
>> #include <linux/of.h>
>> #include <linux/reboot.h>
>> #include <linux/reboot-mode.h>
>> +#include <linux/slab.h>
>>
>> #define PREFIX "mode-"
>>
>> @@ -55,7 +59,9 @@ static int reboot_mode_notify(struct notifier_block *this,
>> unsigned int magic;
>>
>> reboot = container_of(this, struct reboot_mode_driver, reboot_notifier);
>> + mutex_lock(&reboot->rb_lock);
>
> This one should go into the get_reboot_mode_magic() function, otherwise
> it's not obvious why do you need it here.
sure. will update.
>
> Also, please split mutex addition to a separate patch.
Ack.
>
>> magic = get_reboot_mode_magic(reboot, cmd);
>> + mutex_unlock(&reboot->rb_lock);
>> if (magic)
>> reboot->write(reboot, magic);
>>
>