diff mbox series

pinctrl: th1520: Use common error handling code in th1520_pinctrl_dt_node_to_map()

Message ID 89844cfc-f349-4515-a683-572c09c4143a@web.de (mailing list archive)
State Handled Elsewhere
Headers show
Series pinctrl: th1520: Use common error handling code in th1520_pinctrl_dt_node_to_map() | expand

Checks

Context Check Description
conchuod/vmtest-fixes-PR fail merge-conflict

Commit Message

Markus Elfring Oct. 10, 2024, 6:33 a.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 10 Oct 2024 08:22:14 +0200

Add jump targets 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/pinctrl/pinctrl-th1520.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

--
2.46.1
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinctrl-th1520.c b/drivers/pinctrl/pinctrl-th1520.c
index c8d2ee6defa7..8556dd6b881e 100644
--- a/drivers/pinctrl/pinctrl-th1520.c
+++ b/drivers/pinctrl/pinctrl-th1520.c
@@ -464,23 +464,18 @@  static int th1520_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 			if (!muxtype) {
 				dev_err(thp->pctl->dev, "%pOFn.%pOFn: unknown function '%s'\n",
 					np, child, funcname);
-				ret = -EINVAL;
-				goto free_configs;
+				goto e_inval;
 			}

 			funcname = devm_kasprintf(thp->pctl->dev, GFP_KERNEL, "%pOFn.%pOFn",
 						  np, child);
-			if (!funcname) {
-				ret = -ENOMEM;
-				goto free_configs;
-			}
+			if (!funcname)
+				goto e_nomem;

 			npins = of_property_count_strings(child, "pins");
 			pgnames = devm_kcalloc(thp->pctl->dev, npins, sizeof(*pgnames), GFP_KERNEL);
-			if (!pgnames) {
-				ret = -ENOMEM;
-				goto free_configs;
-			}
+			if (!pgnames)
+				goto e_nomem;
 		} else {
 			funcname = NULL;
 		}
@@ -497,8 +492,7 @@  static int th1520_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 				nmaps = rollback;
 				dev_err(thp->pctl->dev, "%pOFn.%pOFn: unknown pin '%s'\n",
 					np, child, pinname);
-				ret = -EINVAL;
-				goto free_configs;
+				goto e_inval;
 			}

 			if (nconfigs) {
@@ -531,6 +525,12 @@  static int th1520_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 	*num_maps = nmaps;
 	return 0;

+e_nomem:
+	ret = -ENOMEM;
+	goto free_configs;
+
+e_inval:
+	ret = -EINVAL;
 free_configs:
 	kfree(configs);
 free_map: