[PATCH] pinctrl: th1520: Use common error handling code in th1520_pinctrl_dt_node_to_map()
Markus Elfring
Markus.Elfring at web.de
Wed Oct 9 23:33:36 PDT 2024
From: Markus Elfring <elfring at 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 at users.sourceforge.net>
---
drivers/pinctrl/pinctrl-th1520.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
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:
--
2.46.1
More information about the linux-riscv
mailing list