mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/chrome: cros_ec_typec: Use common error handling code in cros_typec_init_ports()
@ 2024-06-29 13:33 Markus Elfring
  2024-06-29 14:30 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2024-06-29 13:33 UTC (permalink / raw)
  To: chrome-platform, kernel-janitors, Benson Leung,
	Günter Röck, Prashant Malani, Tzung-Bi Shih
  Cc: LKML, Heikki Krogerus

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/platform/chrome/cros_ec_typec.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
index 4d305876ec08..aff744a0b38f 100644
--- a/drivers/platform/chrome/cros_ec_typec.c
+++ b/drivers/platform/chrome/cros_ec_typec.c
@@ -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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] platform/chrome: cros_ec_typec: Use common error handling code in cros_typec_init_ports()
  2024-06-29 13:33 [PATCH] platform/chrome: cros_ec_typec: Use common error handling code in cros_typec_init_ports() Markus Elfring
@ 2024-06-29 14:30 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2024-06-29 14:30 UTC (permalink / raw)
  To: Markus Elfring
  Cc: chrome-platform, kernel-janitors, Benson Leung,
	Günter Röck, Prashant Malani, Tzung-Bi Shih, LKML,
	Heikki Krogerus

On Sat, Jun 29, 2024 at 6:33 AM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/platform/chrome/cros_ec_typec.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/platform/chrome/cros_ec_typec.c b/drivers/platform/chrome/cros_ec_typec.c
> index 4d305876ec08..aff744a0b38f 100644
> --- a/drivers/platform/chrome/cros_ec_typec.c
> +++ b/drivers/platform/chrome/cros_ec_typec.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-29 14:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-29 13:33 [PATCH] platform/chrome: cros_ec_typec: Use common error handling code in cros_typec_init_ports() Markus Elfring
2024-06-29 14:30 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®