[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <06619e53-7260-7bd2-1954-dd10b92dc354@oss.qualcomm.com>
Date: Mon, 5 Jan 2026 23:23:56 +0530
From: Shivendra Pratap <shivendra.pratap@....qualcomm.com>
To: Bartosz Golaszewski <brgl@...nel.org>
Cc: Lorenzo Pieralisi <lpieralisi@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Bjorn Andersson <andersson@...nel.org>,
Sebastian Reichel <sre@...nel.org>, Rob Herring <robh@...nel.org>,
Sudeep Holla <sudeep.holla@....com>,
Souvik Chakravarty <Souvik.Chakravarty@....com>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Andy Yan
<andy.yan@...k-chips.com>,
John Stultz <john.stultz@...aro.org>,
Matthias Brugger <matthias.bgg@...il.com>,
Moritz Fischer <moritz.fischer@...us.com>,
Mark Rutland <mark.rutland@....com>,
Conor Dooley <conor+dt@...nel.org>,
Konrad Dybcio <konradybcio@...nel.org>,
Florian Fainelli <florian.fainelli@...adcom.com>,
Krzysztof Kozlowski <krzk@...nel.org>,
Dmitry Baryshkov <dmitry.baryshkov@....qualcomm.com>,
Mukesh Ojha <mukesh.ojha@....qualcomm.com>,
Andre Draszik <andre.draszik@...aro.org>,
Kathiravan Thirumoorthy <kathiravan.thirumoorthy@....qualcomm.com>,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-arm-msm@...r.kernel.org,
devicetree@...r.kernel.org, Srinivas Kandagatla <srini@...nel.org>
Subject: Re: [PATCH v19 01/10] power: reset: reboot-mode: Remove devres based
allocations
On 1/2/2026 3:35 PM, Bartosz Golaszewski wrote:
> On Sun, Dec 28, 2025 at 6:20 PM Shivendra Pratap
> <shivendra.pratap@....qualcomm.com> wrote:
>>
>> Devres APIs are intended for use in drivers, where the managed lifetime
>> of resources is tied directly to the driver attach/detach cycle. In
>> shared subsystem code, there is no guarantee that the subsystem
>> functions will only be called after a driver has been attached, nor that
>> they will not be referenced after the managed resources have been
>> released during driver detach.
[SNIP..]
>>
>> @@ -71,9 +74,11 @@ static int reboot_mode_notify(struct notifier_block *this,
>> int reboot_mode_register(struct reboot_mode_driver *reboot)
>> {
>> struct mode_info *info;
>> + struct mode_info *next;
>> struct property *prop;
>> struct device_node *np = reboot->dev->of_node;
>> size_t len = strlen(PREFIX);
>> + u32 magic;
>> int ret;
>>
>> INIT_LIST_HEAD(&reboot->head);
>> @@ -82,19 +87,17 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
>> if (strncmp(prop->name, PREFIX, len))
>> continue;
>>
>> - info = devm_kzalloc(reboot->dev, sizeof(*info), GFP_KERNEL);
>> + if (of_property_read_u32(np, prop->name, &magic)) {
>
> Please use device_property_read_u32() if you have access to a device struct.
Ack. Can it go in same patch with the fixes tag?
>
>> + pr_err("reboot mode %s without magic number\n", prop->name);
>
> If this is an error, shouldn't we bail out?
>
>> + continue;
>> + }
>> +
>> + info = kzalloc(sizeof(*info), GFP_KERNEL);
>> if (!info) {
>> ret = -ENOMEM;
>> goto error;
>> }
>>
>> - if (of_property_read_u32(np, prop->name, &info->magic)) {
>> - dev_err(reboot->dev, "reboot mode %s without magic number\n",
>> - info->mode);
>> - devm_kfree(reboot->dev, info);
>> - continue;
>> - }
>> -
>> info->mode = kstrdup_const(prop->name + len, GFP_KERNEL);
>> if (!info->mode) {
>> ret = -ENOMEM;
>> @@ -102,8 +105,7 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
>> } else if (info->mode[0] == '\0') {
>> kfree_const(info->mode);
>> ret = -EINVAL;
>> - dev_err(reboot->dev, "invalid mode name(%s): too short!\n",
>> - prop->name);
>> + pr_err("invalid mode name(%s): too short!\n", prop->name);
>> goto error;
>> }
>>
>> @@ -116,8 +118,12 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
>> return 0;
>>
>> error:
>> - list_for_each_entry(info, &reboot->head, list)
>> + kfree(info);
>> + list_for_each_entry_safe(info, next, &reboot->head, list) {
>> + list_del(&info->list);
>> kfree_const(info->mode);
>> + kfree(info);
>> + }
>>
>> return ret;
>> }
>> @@ -130,11 +136,15 @@ EXPORT_SYMBOL_GPL(reboot_mode_register);
>> int reboot_mode_unregister(struct reboot_mode_driver *reboot)
>> {
>> struct mode_info *info;
>> + struct mode_info *next;
>>
>> unregister_reboot_notifier(&reboot->reboot_notifier);
>>
>> - list_for_each_entry(info, &reboot->head, list)
>> + list_for_each_entry_safe(info, next, &reboot->head, list) {
>> + list_del(&info->list);
>> kfree_const(info->mode);
>> + kfree(info);
>> + }
>
> The code is repeated here, maybe factor it out into a separate function?
Ack. let me try that.
thanks,
Shivendra
Powered by blists - more mailing lists