Skip to contentSkip to conversation

usb: typec: mux: replace of_node_put() with __free [linux-next]

PATCH In review R SUNDAR 2 participants 4 messages Apr 10, 2024 – May 5, 2024

Subsystems (2)
lore
Share & tools
lore

R SUNDAR

author
#0 lore raw

PATCH v2 1/1 usb: typec: mux: replace of_node_put() with __free [linux-next]

use the new cleanup magic to replace of_node_put() with __free(device_node) marking to auto release and to simplify the error paths.

---

Link to v1 - https://lore.kernel.org/all/CAA8EJppfzXEzzrQ_11O94MVn2dhcF2kGd9RR8ctJ1GmK=6C+ZQ@mail.gmail.com/

Changes in v2: reverted the structure declaration to top of the function.

---
 drivers/usb/typec/mux/nb7vpq904m.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)
drivers/usb/typec/mux/nb7vpq904m.c +8 -17
index b17826713753..3009a6fc7fdb 100644
@@ -315,29 +315,27 @@ static const int supported_data_lane_mapping[][DATA_LANES_COUNT] = {
 
 static int nb7vpq904m_parse_data_lanes_mapping(struct nb7vpq904m *nb7)
 {
-	struct device_node *ep;
+	struct device_node *ep __free(device_node) =
+		of_graph_get_endpoint_by_regs(nb7->client->dev.of_node, 1, 0);
 	u32 data_lanes[4];
 	int ret, i, j;
 
-	ep = of_graph_get_endpoint_by_regs(nb7->client->dev.of_node, 1, 0);
-
 	if (ep) {
 		ret = of_property_count_u32_elems(ep, "data-lanes");
 		if (ret == -EINVAL)
 			/* Property isn't here, consider default mapping */
-			goto out_done;
+			return 0;
 		if (ret < 0)
-			goto out_error;
+			return ret;
 
 		if (ret != DATA_LANES_COUNT) {
 			dev_err(&nb7->client->dev, "expected 4 data lanes\n");
-			ret = -EINVAL;
-			goto out_error;
+			return -EINVAL;
 		}
 
 		ret = of_property_read_u32_array(ep, "data-lanes", data_lanes, DATA_LANES_COUNT);
 		if (ret)
-			goto out_error;
+			return ret;
 
 		for (i = 0; i < ARRAY_SIZE(supported_data_lane_mapping); i++) {
 			for (j = 0; j < DATA_LANES_COUNT; j++) {
@@ -358,18 +356,11 @@ static int nb7vpq904m_parse_data_lanes_mapping(struct nb7vpq904m *nb7)
 			break;
 		default:
 			dev_err(&nb7->client->dev, "invalid data lanes mapping\n");
-			ret = -EINVAL;
-			goto out_error;
+			return -EINVAL;
 		}
 	}
 
-out_done:
-	ret = 0;
-
-out_error:
-	of_node_put(ep);
-
-	return ret;
+	return 0;
 }
 
 static int nb7vpq904m_probe(struct i2c_client *client)
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 6 lines · R SUNDAR

use the new cleanup magic to replace of_node_put() with __free(device_node) marking to auto release and to simplify the error paths.

Please fix your name up for the next version.

Quoted 5 lines

---

Link to v1 - https://lore.kernel.org/all/CAA8EJppfzXEzzrQ_11O94MVn2dhcF2kGd9RR8ctJ1GmK=6C+ZQ@mail.gmail.com/

Changes in v2: reverted the structure declaration to top of the function.

How was this tested?

thanks,

greg k-h

author
#2 lore raw
Quoted 4 lines · Greg KH
Quoted 1 line · R SUNDAR

Please fix your name up for the next version.

Hi,

This version of patch is sent before comments provided for naming in patch v1.

The name and nitpick was fixed after suggestion provided in patch v1.

https://lore.kernel.org/all/2024041103-doornail-professor-7c1e@gregkh/

Link for patch after fixing name and nitpick:

https://lore.kernel.org/all/[email protected]/

Thanks,
Sundar

author
#3 lore raw
Quoted 15 lines · R Sundar
Quoted 4 lines · Greg KH
Quoted 1 line · R SUNDAR

Please fix your name up for the next version.

Hi,

This version of patch is sent  before comments provided for naming in patch v1.

The name and nitpick was fixed after suggestion provided in patch v1.

https://lore.kernel.org/all/2024041103-doornail-professor-7c1e@gregkh/

Quoted 8 lines

Link for patch after fixing name and nitpick:

https://lore.kernel.org/all/[email protected]/

Thanks,
Sundar

Little more explanation on previous mail:

Nitpick mentioned above , referring to is , suggestion to rewrite a "nit in code" related to indentation in common path.

https://lore.kernel.org/all/2024041103-doornail-professor-7c1e@gregkh/

So along with fixing name , I fixed that indentations also as suggested.

https://lore.kernel.org/all/[email protected]/

Thanks,
Sundar