Skip to contentSkip to conversation

hwmon: (gsc-hwmon) Call of_node_get() before of_find_xxx API

PATCH In review Liang He 2 participants 6 messages Sep 15, 2022 – Sep 16, 2022

Subsystems (2)
lore
Share & tools
lore

Liang He

author
#0 lore raw

PATCH v2 1/1 hwmon: (gsc-hwmon) Call of_node_get() before of_find_xxx API

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")

---

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

 drivers/hwmon/gsc-hwmon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hwmon/gsc-hwmon.c +1 -0
index d64be48f1ef6..b60ec95b5edb 100644
@@ -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);
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 8 lines · Liang He

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")

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

Guenter

Quoted 22 lines

---

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

 drivers/hwmon/gsc-hwmon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hwmon/gsc-hwmon.c +1 -0
index d64be48f1ef6..b60ec95b5edb 100644
@@ -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);
Signature · 1 line
2.25.1
author
#2 lore raw
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Liang He

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.

Quoted 8 lines
Quoted 4 lines
Fixes 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")

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

Quoted 23 lines
Quoted 23 lines

---

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

 drivers/hwmon/gsc-hwmon.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hwmon/gsc-hwmon.c +1 -0
index d64be48f1ef6..b60ec95b5edb 100644
@@ -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);
Signature · 1 line
2.25.1
maintainer
#3 lore raw
Quoted 19 lines · Liang He
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Liang He

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.

Quoted 8 lines
Quoted 4 lines
Fixes 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")

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

Guenter

Hi, Guenter

Quoted 8 lines

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

author
#4 lore raw
Quoted 29 lines · Guenter Roeck
Quoted 19 lines · Liang He
Quoted 5 lines · Guenter Roeck
Quoted 4 lines · Liang He

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.

Quoted 8 lines
Quoted 4 lines
Fixes 3bce5377ef66 ("hwmon: Add Gateworks System Controller support")

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

Guenter

Hi, Guenter

Quoted 8 lines

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

Quoted 7 lines

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")

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

Thanks again.

Liang