Skip to contentSkip to conversation

gpu: ipu-v3: Removal of of_node_put with __free for auto cleanup

PATCH In review Abhinav Jain 2 participants 2 messages Jul 2, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpu: ipu-v3: Removal of of_node_put with __free for auto cleanup

Remove of_node_put from device node of_node.
Move declaration to initialization for ensuring scope sanity.

---
 drivers/gpu/ipu-v3/ipu-common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/ipu-v3/ipu-common.c +3 -3
index 71ec1e7f657a..f8cc3f721d2a 100644
@@ -1150,10 +1150,10 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
 	for (i = 0; i < ARRAY_SIZE(client_reg); i++) {
 		struct ipu_platform_reg *reg = &client_reg[i];
 		struct platform_device *pdev;
-		struct device_node *of_node;
-
 		/* Associate subdevice with the corresponding port node */
-		of_node = of_graph_get_port_by_id(dev->of_node, i);
+		struct device_node *of_node __free(device_node) =
+			of_graph_get_port_by_id(dev->of_node, i);
+
 		if (!of_node) {
 			dev_info(dev,
 				 "no port@%d node in %pOF, not using %s%d\n",
Signature · 1 line
2.34.1
#1 lore raw
Quoted 16 lines · Abhinav Jain

Remove of_node_put from device node of_node.
Move declaration to initialization for ensuring scope sanity.

---
 drivers/gpu/ipu-v3/ipu-common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/ipu-v3/ipu-common.c +0 -0
index 71ec1e7f657a..f8cc3f721d2a 100644
@@ -1150,10 +1150,10 @@ static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base)
 	for (i = 0; i < ARRAY_SIZE(client_reg); i++) {
 		struct ipu_platform_reg *reg = &client_reg[i];
 		struct platform_device *pdev;

drivers/gpu/ipu-v3/ipu-common.c static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base) · line 1159

Quoted 10 lines
drivers/gpu/ipu-v3/ipu-common.c +3 -3
-		struct device_node *of_node;
-
 		/* Associate subdevice with the corresponding port node */
-		of_node = of_graph_get_port_by_id(dev->of_node, i);
+		struct device_node *of_node __free(device_node) =
+			of_graph_get_port_by_id(dev->of_node, i);
+
 		if (!of_node) {
 			dev_info(dev,
 				 "no port@%d node in %pOF, not using %s%d\n",

Hi Abhinav,

1. You sent this patch twice.
2. The __free() macro removes the need for of_node_put(), but you kept the calls to that function.
3. If you are aiming for a code refactoring, do not apply the __free() macro to a single device_node, leaving the rest untouched.

Best regards,
Javier Carrasco