Re: [PATCH v23 2/2] power: reset: reboot-mode: Expose sysfs for registered reboot_modes

From: Shivendra Pratap

Date: Fri Feb 06 2026 - 11:29:16 EST




On 2/6/2026 8:49 PM, Bartosz Golaszewski wrote:
> On Thu, 5 Feb 2026 18:17:14 +0100, Shivendra Pratap
> <shivendra.pratap@xxxxxxxxxxxxxxxx> said:
>> Currently, there is no standardized mechanism for userspace to discover
>> supported reboot modes on a platform. This limits userspace scripts, to
>> rely on hardcoded assumptions about the available reboot-modes.
>>
>> Create a class 'reboot-mode' and a device under it. Use the name of the
>> registering driver as device name. Expose a sysfs interface under this
>> device to show available reboot mode arguments.
>>
>> This results in the creation of:
>> /sys/class/reboot-mode/<driver>/reboot_modes
>>
>> This read-only sysfs file will exposes the supported reboot mode
>> arguments provided by the registering driver, enabling userspace to
>> query the list of arguments.
>>
>> Signed-off-by: Shivendra Pratap <shivendra.pratap@xxxxxxxxxxxxxxxx>
>> ---
>
> There are some nits from my side below but nothing serious so LGTM anyway.
>
> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
>
>> +
>> +static inline void reboot_mode_release_list(struct list_head *head)
>
> I would have passed priv here as passing list_head as argument looks a bit
> weird.

Ack. thanks. Will pass priv here.

>
>> +{
>> + struct mode_info *info;
>> + struct mode_info *next;
>> +
>
> These could be on the same line.

Ack. thanks.

>
>> + sysfs_info->mode = kstrdup_const(info->mode, GFP_KERNEL);
>> + if (!sysfs_info->mode) {
>> + kfree(sysfs_info);
>> + ret = -ENOMEM;
>> + goto error;
>> + }
>> +
>> + list_add_tail(&sysfs_info->list, &priv->head);
>> + }
>> +
>> + priv->reboot_mode_device = device_create(&reboot_mode_class, NULL, 0,
>> + (void *)priv, reboot->dev->driver->name);
>> +
>
> Stray newline.

Ack. will remove this.

>
>> + if (IS_ERR(priv->reboot_mode_device)) {
>> + ret = PTR_ERR(priv->reboot_mode_device);
>> + goto error;
>> + }
>> +
>> + return 0;
>
> As I said, these are nits so fix them or not but let's get this upstream after
> v7.0-rc1.

Ack.

thanks,
Shivendra