Skip to contentSkip to conversation

platform/chrome: cros_ec_typec: Use common error handling code in cros_typec_init_ports()

PATCH In review Markus Elfring 2 participants 2 messages Jun 29, 2024

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

PATCH 1/1 platform/chrome: cros_ec_typec: Use common error handling code in cros_typec_init_ports()

From: Markus Elfring <[email protected]>
Date: Sat, 29 Jun 2024 15:17:44 +0200

Add a jump target so that a bit of exception handling can be better reused at the end of this function implementation.

---
 drivers/platform/chrome/cros_ec_typec.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +4 -4
index 4d305876ec08..aff744a0b38f 100644
@@ -348,15 +348,13 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
 	port_prop = dev->of_node ? "reg" : "port-number";
 	device_for_each_child_node(dev, fwnode) {
 		if (fwnode_property_read_u32(fwnode, port_prop, &port_num)) {
-			ret = -EINVAL;
 			dev_err(dev, "No port-number for port, aborting.\n");
-			goto unregister_ports;
+			goto e_inval;
 		}
 
 		if (port_num >= typec->num_ports) {
 			dev_err(dev, "Invalid port number.\n");
-			ret = -EINVAL;
-			goto unregister_ports;
+			goto e_inval;
 		}
 
 		dev_dbg(dev, "Registering port %d\n", port_num);
@@ -408,6 +406,8 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
 
 	return 0;
 
+e_inval:
+	ret = -EINVAL;
 unregister_ports:
 	cros_unregister_ports(typec);
 	return ret;

--
2.45.2

#1 lore raw
Quoted 7 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 29 Jun 2024 15:17:44 +0200

Add a jump target so that a bit of exception handling can be better reused at the end of this function implementation.

I see no value in this patch.

Guenter

Quoted 39 lines
---
 drivers/platform/chrome/cros_ec_typec.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/platform/chrome/cros_ec_typec.c +4 -5
index 4d305876ec08..aff744a0b38f 100644
@@ -348,15 +348,13 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
        port_prop = dev->of_node ? "reg" : "port-number";
        device_for_each_child_node(dev, fwnode) {
                if (fwnode_property_read_u32(fwnode, port_prop, &port_num)) {
-                       ret = -EINVAL;
                        dev_err(dev, "No port-number for port, aborting.\n");
-                       goto unregister_ports;
+                       goto e_inval;
                }
 
                if (port_num >= typec->num_ports) {
                        dev_err(dev, "Invalid port number.\n");
-                       ret = -EINVAL;
-                       goto unregister_ports;
+                       goto e_inval;
                }
 
                dev_dbg(dev, "Registering port %d\n", port_num);
@@ -408,6 +406,8 @@ static int cros_typec_init_ports(struct cros_typec_data *typec)
 
        return 0;
 
+e_inval:
+       ret = -EINVAL;
 unregister_ports:
        cros_unregister_ports(typec);
        return ret;
--

2.45.2