linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lvts_thermal.c: Fix error checking for debugfs_create_dir
@ 2023-05-17 16:03 Osama Muhammad
  2023-05-30 15:47 ` Daniel Lezcano
  0 siblings, 1 reply; 4+ messages in thread
From: Osama Muhammad @ 2023-05-17 16:03 UTC (permalink / raw)
  To: rafael, daniel.lezcano, amitk, rui.zhang, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst
  Cc: linux-pm, linux-kernel, Osama Muhammad

This patch fixes the error checking in lvts_thermal.c in
debugfs_create_dir. The correct way to check if an error occurred
is 'IS_ERR' inline function.

Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
---
 drivers/thermal/mediatek/lvts_thermal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index d0a3f95b7884..61386be78fa0 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -188,7 +188,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
 	int i;
 
 	lvts_td->dom_dentry = debugfs_create_dir(dev_name(dev), NULL);
-	if (!lvts_td->dom_dentry)
+	if (IS_ERR(lvts_td->dom_dentry))
 		return 0;
 
 	for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {
@@ -197,7 +197,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
 
 		sprintf(name, "controller%d", i);
 		dentry = debugfs_create_dir(name, lvts_td->dom_dentry);
-		if (!dentry)
+		if (IS_ERR(dentry))
 			continue;
 
 		regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] lvts_thermal.c: Fix error checking for debugfs_create_dir
  2023-05-17 16:03 [PATCH] lvts_thermal.c: Fix error checking for debugfs_create_dir Osama Muhammad
@ 2023-05-30 15:47 ` Daniel Lezcano
  2023-05-30 15:54   ` Osama Muhammad
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Lezcano @ 2023-05-30 15:47 UTC (permalink / raw)
  To: Osama Muhammad, rafael, amitk, rui.zhang, matthias.bgg,
	angelogioacchino.delregno, bchihi, wenst
  Cc: linux-pm, linux-kernel

On 17/05/2023 18:03, Osama Muhammad wrote:
> This patch fixes the error checking in lvts_thermal.c in
> debugfs_create_dir. The correct way to check if an error occurred
> is 'IS_ERR' inline function.

We do no longer check debugfs functions return values.

eg.

  https://www.spinics.net/lists/linux-spi/msg37903.html
  https://lore.kernel.org/lkml/2023052835-oxidant-doily-404f@gregkh/


> Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
> ---
>   drivers/thermal/mediatek/lvts_thermal.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
> index d0a3f95b7884..61386be78fa0 100644
> --- a/drivers/thermal/mediatek/lvts_thermal.c
> +++ b/drivers/thermal/mediatek/lvts_thermal.c
> @@ -188,7 +188,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
>   	int i;
>   
>   	lvts_td->dom_dentry = debugfs_create_dir(dev_name(dev), NULL);
> -	if (!lvts_td->dom_dentry)
> +	if (IS_ERR(lvts_td->dom_dentry))
>   		return 0;
>   
>   	for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {
> @@ -197,7 +197,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
>   
>   		sprintf(name, "controller%d", i);
>   		dentry = debugfs_create_dir(name, lvts_td->dom_dentry);
> -		if (!dentry)
> +		if (IS_ERR(dentry))
>   			continue;
>   
>   		regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);

-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lvts_thermal.c: Fix error checking for debugfs_create_dir
  2023-05-30 15:47 ` Daniel Lezcano
@ 2023-05-30 15:54   ` Osama Muhammad
  2023-05-30 16:15     ` Daniel Lezcano
  0 siblings, 1 reply; 4+ messages in thread
From: Osama Muhammad @ 2023-05-30 15:54 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: rafael, amitk, rui.zhang, matthias.bgg, angelogioacchino.delregno,
	bchihi, wenst, linux-pm, linux-kernel

Hi,

After Reading more about it I also learned about this and I was
planning to send a patch to remove the error checking for debugfs
API.Should I send the patch for it?

Thanks
osmten


On Tue, 30 May 2023 at 20:47, Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
>
> On 17/05/2023 18:03, Osama Muhammad wrote:
> > This patch fixes the error checking in lvts_thermal.c in
> > debugfs_create_dir. The correct way to check if an error occurred
> > is 'IS_ERR' inline function.
>
> We do no longer check debugfs functions return values.
>
> eg.
>
>   https://www.spinics.net/lists/linux-spi/msg37903.html
>   https://lore.kernel.org/lkml/2023052835-oxidant-doily-404f@gregkh/
>
>
> > Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
> > ---
> >   drivers/thermal/mediatek/lvts_thermal.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
> > index d0a3f95b7884..61386be78fa0 100644
> > --- a/drivers/thermal/mediatek/lvts_thermal.c
> > +++ b/drivers/thermal/mediatek/lvts_thermal.c
> > @@ -188,7 +188,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
> >       int i;
> >
> >       lvts_td->dom_dentry = debugfs_create_dir(dev_name(dev), NULL);
> > -     if (!lvts_td->dom_dentry)
> > +     if (IS_ERR(lvts_td->dom_dentry))
> >               return 0;
> >
> >       for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {
> > @@ -197,7 +197,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
> >
> >               sprintf(name, "controller%d", i);
> >               dentry = debugfs_create_dir(name, lvts_td->dom_dentry);
> > -             if (!dentry)
> > +             if (IS_ERR(dentry))
> >                       continue;
> >
> >               regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);
>
> --
> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
>
> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lvts_thermal.c: Fix error checking for debugfs_create_dir
  2023-05-30 15:54   ` Osama Muhammad
@ 2023-05-30 16:15     ` Daniel Lezcano
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Lezcano @ 2023-05-30 16:15 UTC (permalink / raw)
  To: Osama Muhammad
  Cc: rafael, amitk, rui.zhang, matthias.bgg, angelogioacchino.delregno,
	bchihi, wenst, linux-pm, linux-kernel

On 30/05/2023 17:54, Osama Muhammad wrote:
> Hi,
> 
> After Reading more about it I also learned about this and I was
> planning to send a patch to remove the error checking for debugfs
> API.Should I send the patch for it?
> 

Yes, you can change also the prototype of the lvts_debugfs_init() 
function by returning void

And then replace the call site:

         return lvts_debugfs_init(dev, lvts_td);

  by:

	lvts_debugfs_init(dev, lvts_td);

	return 0;

> osmten
> 
> 
> On Tue, 30 May 2023 at 20:47, Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
>>
>> On 17/05/2023 18:03, Osama Muhammad wrote:
>>> This patch fixes the error checking in lvts_thermal.c in
>>> debugfs_create_dir. The correct way to check if an error occurred
>>> is 'IS_ERR' inline function.
>>
>> We do no longer check debugfs functions return values.
>>
>> eg.
>>
>>    https://www.spinics.net/lists/linux-spi/msg37903.html
>>    https://lore.kernel.org/lkml/2023052835-oxidant-doily-404f@gregkh/
>>
>>
>>> Signed-off-by: Osama Muhammad <osmtendev@gmail.com>
>>> ---
>>>    drivers/thermal/mediatek/lvts_thermal.c | 4 ++--
>>>    1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
>>> index d0a3f95b7884..61386be78fa0 100644
>>> --- a/drivers/thermal/mediatek/lvts_thermal.c
>>> +++ b/drivers/thermal/mediatek/lvts_thermal.c
>>> @@ -188,7 +188,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
>>>        int i;
>>>
>>>        lvts_td->dom_dentry = debugfs_create_dir(dev_name(dev), NULL);
>>> -     if (!lvts_td->dom_dentry)
>>> +     if (IS_ERR(lvts_td->dom_dentry))
>>>                return 0;
>>>
>>>        for (i = 0; i < lvts_td->num_lvts_ctrl; i++) {
>>> @@ -197,7 +197,7 @@ static int lvts_debugfs_init(struct device *dev, struct lvts_domain *lvts_td)
>>>
>>>                sprintf(name, "controller%d", i);
>>>                dentry = debugfs_create_dir(name, lvts_td->dom_dentry);
>>> -             if (!dentry)
>>> +             if (IS_ERR(dentry))
>>>                        continue;
>>>
>>>                regset = devm_kzalloc(dev, sizeof(*regset), GFP_KERNEL);
>>
>> --
>> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
>>
>> Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
>> <http://twitter.com/#!/linaroorg> Twitter |
>> <http://www.linaro.org/linaro-blog/> Blog
>>

-- 
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-30 16:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-17 16:03 [PATCH] lvts_thermal.c: Fix error checking for debugfs_create_dir Osama Muhammad
2023-05-30 15:47 ` Daniel Lezcano
2023-05-30 15:54   ` Osama Muhammad
2023-05-30 16:15     ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).