* [PATCH] backlight: sky81452-backlight: replace of_node_put with __free
@ 2024-05-01 12:51 R Sundar
2024-05-01 14:01 ` Daniel Thompson
0 siblings, 1 reply; 4+ messages in thread
From: R Sundar @ 2024-05-01 12:51 UTC (permalink / raw
To: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller
Cc: dri-devel, linux-fbdev, linux-kernel, skhan, javier.carrasco.cruz,
R Sundar, Julia Lawall
Use the new cleanup magic to replace of_node_put() with
__free(device_node) marking to auto release when they get out of scope.
Suggested-by: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: R Sundar <prosunofficial@gmail.com>
---
drivers/video/backlight/sky81452-backlight.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
index eb18c6eb0ff0..54095872a33a 100644
--- a/drivers/video/backlight/sky81452-backlight.c
+++ b/drivers/video/backlight/sky81452-backlight.c
@@ -182,7 +182,7 @@ static const struct attribute_group sky81452_bl_attr_group = {
static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
struct device *dev)
{
- struct device_node *np = of_node_get(dev->of_node);
+ struct device_node *np __free(device_node) = of_node_get(dev->of_node);
struct sky81452_bl_platform_data *pdata;
int num_entry;
unsigned int sources[6];
@@ -194,10 +194,8 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
}
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
- if (!pdata) {
- of_node_put(np);
+ if (!pdata)
return ERR_PTR(-ENOMEM);
- }
of_property_read_string(np, "name", &pdata->name);
pdata->ignore_pwm = of_property_read_bool(np, "skyworks,ignore-pwm");
@@ -217,7 +215,6 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
num_entry);
if (ret < 0) {
dev_err(dev, "led-sources node is invalid.\n");
- of_node_put(np);
return ERR_PTR(-EINVAL);
}
@@ -237,7 +234,6 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
if (ret < 0)
pdata->boost_current_limit = 2750;
- of_node_put(np);
return pdata;
}
#else
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] backlight: sky81452-backlight: replace of_node_put with __free
2024-05-01 12:51 [PATCH] backlight: sky81452-backlight: replace of_node_put with __free R Sundar
@ 2024-05-01 14:01 ` Daniel Thompson
2024-05-01 14:19 ` Julia Lawall
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Thompson @ 2024-05-01 14:01 UTC (permalink / raw
To: R Sundar
Cc: Lee Jones, Jingoo Han, Helge Deller, dri-devel, linux-fbdev,
linux-kernel, skhan, javier.carrasco.cruz, Julia Lawall,
Shresth Prasad
On Wed, May 01, 2024 at 06:21:46PM +0530, R Sundar wrote:
> Use the new cleanup magic to replace of_node_put() with
> __free(device_node) marking to auto release when they get out of scope.
>
> Suggested-by: Julia Lawall <julia.lawall@inria.fr>
> Signed-off-by: R Sundar <prosunofficial@gmail.com>
Thanks for the patch but I think this one is a more appropriate
solution to this issue:
https://lore.kernel.org/all/20240421104916.312588-2-shresthprasad7@gmail.com/
Daniel.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] backlight: sky81452-backlight: replace of_node_put with __free
2024-05-01 14:01 ` Daniel Thompson
@ 2024-05-01 14:19 ` Julia Lawall
2024-05-02 6:19 ` Shresth Prasad
0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2024-05-01 14:19 UTC (permalink / raw
To: Daniel Thompson
Cc: R Sundar, Lee Jones, Jingoo Han, Helge Deller, dri-devel,
linux-fbdev, linux-kernel, skhan, javier.carrasco.cruz,
Julia Lawall, Shresth Prasad
On Wed, 1 May 2024, Daniel Thompson wrote:
> On Wed, May 01, 2024 at 06:21:46PM +0530, R Sundar wrote:
> > Use the new cleanup magic to replace of_node_put() with
> > __free(device_node) marking to auto release when they get out of scope.
> >
> > Suggested-by: Julia Lawall <julia.lawall@inria.fr>
> > Signed-off-by: R Sundar <prosunofficial@gmail.com>
>
> Thanks for the patch but I think this one is a more appropriate
> solution to this issue:
> https://lore.kernel.org/all/20240421104916.312588-2-shresthprasad7@gmail.com/
Maybe neither one is perfect? The one I see at that link has:
if (!pdata) {
- of_node_put(np);
return ERR_PTR(-ENOMEM);
}
which has unneeded {}
julia
>
>
> Daniel.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] backlight: sky81452-backlight: replace of_node_put with __free
2024-05-01 14:19 ` Julia Lawall
@ 2024-05-02 6:19 ` Shresth Prasad
0 siblings, 0 replies; 4+ messages in thread
From: Shresth Prasad @ 2024-05-02 6:19 UTC (permalink / raw
To: Julia Lawall
Cc: Daniel Thompson, R Sundar, Lee Jones, Jingoo Han, Helge Deller,
dri-devel, linux-fbdev, linux-kernel, skhan, javier.carrasco.cruz
I'll remove the unnecessary braces and resend the patch.
Regards,
Shresth
On Wed, May 1, 2024 at 7:49 PM Julia Lawall <julia.lawall@inria.fr> wrote:
>
>
>
> On Wed, 1 May 2024, Daniel Thompson wrote:
>
> > On Wed, May 01, 2024 at 06:21:46PM +0530, R Sundar wrote:
> > > Use the new cleanup magic to replace of_node_put() with
> > > __free(device_node) marking to auto release when they get out of scope.
> > >
> > > Suggested-by: Julia Lawall <julia.lawall@inria.fr>
> > > Signed-off-by: R Sundar <prosunofficial@gmail.com>
> >
> > Thanks for the patch but I think this one is a more appropriate
> > solution to this issue:
> > https://lore.kernel.org/all/20240421104916.312588-2-shresthprasad7@gmail.com/
>
> Maybe neither one is perfect? The one I see at that link has:
>
> if (!pdata) {
> - of_node_put(np);
> return ERR_PTR(-ENOMEM);
> }
>
> which has unneeded {}
>
> julia
>
>
> >
> >
> > Daniel.
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-02 6:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-01 12:51 [PATCH] backlight: sky81452-backlight: replace of_node_put with __free R Sundar
2024-05-01 14:01 ` Daniel Thompson
2024-05-01 14:19 ` Julia Lawall
2024-05-02 6:19 ` Shresth Prasad
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.