diff mbox series

[v2] hwmon: (gsc-hwmon) Call of_node_get() before of_find_xxx API

Message ID 20220915090627.4007728-1-windhl@126.com (mailing list archive)
State Superseded
Headers show
Series [v2] hwmon: (gsc-hwmon) Call of_node_get() before of_find_xxx API | expand

Commit Message

Liang He Sept. 15, 2022, 9:06 a.m. UTC
In gsc_hwmon_get_devtree_pdata(), we should call of_node_get() before
the of_find_compatible_node() which will automatically call
of_node_put() for the 'from' argument.

Fixes: 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")
Co-developed-by: Mengda Chen <chenmengda2009@163.com>
Signed-off-by: Mengda Chen <chenmengda2009@163.com>
Signed-off-by: Liang He <windhl@126.com>
---

 v2: use proper tags advised by Guenter and based on Kernel Doc

 drivers/hwmon/gsc-hwmon.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Guenter Roeck Sept. 15, 2022, 12:25 p.m. UTC | #1
On Thu, Sep 15, 2022 at 05:06:27PM +0800, Liang He wrote:
> In gsc_hwmon_get_devtree_pdata(), we should call of_node_get() before
> the of_find_compatible_node() which will automatically call
> of_node_put() for the 'from' argument.
> 
> Fixes: 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")
> Co-developed-by: Mengda Chen <chenmengda2009@163.com>
> Signed-off-by: Mengda Chen <chenmengda2009@163.com>
> Signed-off-by: Liang He <windhl@126.com>

Sigh. The first signer is supposed to be the author.

Guenter

> ---
> 
>  v2: use proper tags advised by Guenter and based on Kernel Doc
> 
>  drivers/hwmon/gsc-hwmon.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/hwmon/gsc-hwmon.c b/drivers/hwmon/gsc-hwmon.c
> index d64be48f1ef6..b60ec95b5edb 100644
> --- a/drivers/hwmon/gsc-hwmon.c
> +++ b/drivers/hwmon/gsc-hwmon.c
> @@ -267,6 +267,7 @@ gsc_hwmon_get_devtree_pdata(struct device *dev)
>  	pdata->nchannels = nchannels;
>  
>  	/* fan controller base address */
> +	of_node_get(dev->parent->of_node);
>  	fan = of_find_compatible_node(dev->parent->of_node, NULL, "gw,gsc-fan");
>  	if (fan && of_property_read_u32(fan, "reg", &pdata->fan_base)) {
>  		of_node_put(fan);
> -- 
> 2.25.1
>
Liang He Sept. 15, 2022, 1:10 p.m. UTC | #2
At 2022-09-15 20:25:36, "Guenter Roeck" <linux@roeck-us.net> wrote:
>On Thu, Sep 15, 2022 at 05:06:27PM +0800, Liang He wrote:
>> In gsc_hwmon_get_devtree_pdata(), we should call of_node_get() before
>> the of_find_compatible_node() which will automatically call
>> of_node_put() for the 'from' argument.
>> 
>> Fixes: 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")
>> Co-developed-by: Mengda Chen <chenmengda2009@163.com>
>> Signed-off-by: Mengda Chen <chenmengda2009@163.com>
>> Signed-off-by: Liang He <windhl@126.com>
>
>Sigh. The first signer is supposed to be the author.
>
>Guenter

Hi, Guenter

I search the commit history and found several recent but different commits 

This one is same with mine: Co-developed-by: A & SOB First & SOB Author,  following the kernel doc 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc5&id=7e97cfed9929eaabc41829c395eb0d1350fccb9d

But, this one is consistent with your advise: SOB Author & Co-developed-by: A & SOB A
(https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc5&id=ef69aa3a986ef94f01ce8b5b619f550db54432fe

So please tell me what I should follow?

Thanks very much.

Liang






>
>> ---
>> 
>>  v2: use proper tags advised by Guenter and based on Kernel Doc
>> 
>>  drivers/hwmon/gsc-hwmon.c | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/drivers/hwmon/gsc-hwmon.c b/drivers/hwmon/gsc-hwmon.c
>> index d64be48f1ef6..b60ec95b5edb 100644
>> --- a/drivers/hwmon/gsc-hwmon.c
>> +++ b/drivers/hwmon/gsc-hwmon.c
>> @@ -267,6 +267,7 @@ gsc_hwmon_get_devtree_pdata(struct device *dev)
>>  	pdata->nchannels = nchannels;
>>  
>>  	/* fan controller base address */
>> +	of_node_get(dev->parent->of_node);
>>  	fan = of_find_compatible_node(dev->parent->of_node, NULL, "gw,gsc-fan");
>>  	if (fan && of_property_read_u32(fan, "reg", &pdata->fan_base)) {
>>  		of_node_put(fan);
>> -- 
>> 2.25.1
>>
Guenter Roeck Sept. 15, 2022, 4:43 p.m. UTC | #3
On Thu, Sep 15, 2022 at 09:10:00PM +0800, Liang He wrote:
> 
> 
> At 2022-09-15 20:25:36, "Guenter Roeck" <linux@roeck-us.net> wrote:
> >On Thu, Sep 15, 2022 at 05:06:27PM +0800, Liang He wrote:
> >> In gsc_hwmon_get_devtree_pdata(), we should call of_node_get() before
> >> the of_find_compatible_node() which will automatically call
> >> of_node_put() for the 'from' argument.
> >> 
> >> Fixes: 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")
> >> Co-developed-by: Mengda Chen <chenmengda2009@163.com>
> >> Signed-off-by: Mengda Chen <chenmengda2009@163.com>
> >> Signed-off-by: Liang He <windhl@126.com>
> >
> >Sigh. The first signer is supposed to be the author.
> >
> >Guenter
> 
> Hi, Guenter
> 
> I search the commit history and found several recent but different commits 
> 
> This one is same with mine: Co-developed-by: A & SOB First & SOB Author,  following the kernel doc 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc5&id=7e97cfed9929eaabc41829c395eb0d1350fccb9d
> 
> But, this one is consistent with your advise: SOB Author & Co-developed-by: A & SOB A
> (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc5&id=ef69aa3a986ef94f01ce8b5b619f550db54432fe
> 

Yes, I know, one can always find an example for everything
in the Linux kernel.

I expect the first signer to be the author, and the last signer
to be the person who sent me the patch.

Guenter
Liang He Sept. 16, 2022, 1:33 a.m. UTC | #4
At 2022-09-16 00:43:46, "Guenter Roeck" <linux@roeck-us.net> wrote:
>On Thu, Sep 15, 2022 at 09:10:00PM +0800, Liang He wrote:
>> 
>> 
>> At 2022-09-15 20:25:36, "Guenter Roeck" <linux@roeck-us.net> wrote:
>> >On Thu, Sep 15, 2022 at 05:06:27PM +0800, Liang He wrote:
>> >> In gsc_hwmon_get_devtree_pdata(), we should call of_node_get() before
>> >> the of_find_compatible_node() which will automatically call
>> >> of_node_put() for the 'from' argument.
>> >> 
>> >> Fixes: 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")
>> >> Co-developed-by: Mengda Chen <chenmengda2009@163.com>
>> >> Signed-off-by: Mengda Chen <chenmengda2009@163.com>
>> >> Signed-off-by: Liang He <windhl@126.com>
>> >
>> >Sigh. The first signer is supposed to be the author.
>> >
>> >Guenter
>> 
>> Hi, Guenter
>> 
>> I search the commit history and found several recent but different commits 
>> 
>> This one is same with mine: Co-developed-by: A & SOB First & SOB Author,  following the kernel doc 
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc5&id=7e97cfed9929eaabc41829c395eb0d1350fccb9d
>> 
>> But, this one is consistent with your advise: SOB Author & Co-developed-by: A & SOB A
>> (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v6.0-rc5&id=ef69aa3a986ef94f01ce8b5b619f550db54432fe
>> 
>
>Yes, I know, one can always find an example for everything
>in the Linux kernel.
>
>I expect the first signer to be the author, and the last signer
>to be the person who sent me the patch.
>
>Guenter

Thanks for your advice, so following tag order is acceptable?

Fixes: 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")
Signed-off-by: Liang He <windhl@126.com>
Co-developed-by: Mengda Chen <chenmengda2009@163.com>
Signed-off-by: Mengda Chen <chenmengda2009@163.com>

If there is no problem, I will send a new version patch.

Thanks again.

Liang
Guenter Roeck Sept. 16, 2022, 10:42 a.m. UTC | #5
On Fri, Sep 16, 2022 at 09:33:18AM +0800, Liang He wrote:
> 
> Thanks for your advice, so following tag order is acceptable?
> 
> Fixes: 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")
> Signed-off-by: Liang He <windhl@126.com>
> Co-developed-by: Mengda Chen <chenmengda2009@163.com>
> Signed-off-by: Mengda Chen <chenmengda2009@163.com>
> 
Yes, if the author is Liang He and I get the e-mail from Mengda Chen.

Guenter
diff mbox series

Patch

diff --git a/drivers/hwmon/gsc-hwmon.c b/drivers/hwmon/gsc-hwmon.c
index d64be48f1ef6..b60ec95b5edb 100644
--- a/drivers/hwmon/gsc-hwmon.c
+++ b/drivers/hwmon/gsc-hwmon.c
@@ -267,6 +267,7 @@  gsc_hwmon_get_devtree_pdata(struct device *dev)
 	pdata->nchannels = nchannels;
 
 	/* fan controller base address */
+	of_node_get(dev->parent->of_node);
 	fan = of_find_compatible_node(dev->parent->of_node, NULL, "gw,gsc-fan");
 	if (fan && of_property_read_u32(fan, "reg", &pdata->fan_base)) {
 		of_node_put(fan);