[PATCH] soc: qcom: pmic_glink_altmode: Use common error handling code in pmic_glink_altmode_probe()
Markus Elfring
Markus.Elfring at web.de
Wed Feb 28 10:05:20 PST 2024
From: Markus Elfring <elfring at users.sourceforge.net>
Date: Wed, 28 Feb 2024 18:45:13 +0100
Add a jump target so that a bit of exception handling can be better reused
at the end of this function implementation.
This issue was transformed by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring at users.sourceforge.net>
---
drivers/soc/qcom/pmic_glink_altmode.c | 57 +++++++++++++--------------
1 file changed, 27 insertions(+), 30 deletions(-)
diff --git a/drivers/soc/qcom/pmic_glink_altmode.c b/drivers/soc/qcom/pmic_glink_altmode.c
index b3808fc24c69..c987a45e1703 100644
--- a/drivers/soc/qcom/pmic_glink_altmode.c
+++ b/drivers/soc/qcom/pmic_glink_altmode.c
@@ -434,8 +434,7 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
ret = fwnode_property_read_u32(fwnode, "reg", &port);
if (ret < 0) {
dev_err(dev, "missing reg property of %pOFn\n", fwnode);
- fwnode_handle_put(fwnode);
- return ret;
+ goto put_fwnode;
}
if (port >= ARRAY_SIZE(altmode->ports)) {
@@ -445,8 +444,8 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
if (altmode->ports[port].altmode) {
dev_err(dev, "multiple connector definition for port %u\n", port);
- fwnode_handle_put(fwnode);
- return -EINVAL;
+ ret = -EINVAL;
+ goto put_fwnode;
}
alt_port = &altmode->ports[port];
@@ -456,8 +455,8 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
alt_port->bridge = devm_drm_dp_hpd_bridge_alloc(dev, to_of_node(fwnode));
if (IS_ERR(alt_port->bridge)) {
- fwnode_handle_put(fwnode);
- return PTR_ERR(alt_port->bridge);
+ ret = PTR_ERR(alt_port->bridge);
+ goto put_fwnode;
}
alt_port->dp_alt.svid = USB_TYPEC_DP_SID;
@@ -466,48 +465,42 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
alt_port->typec_mux = fwnode_typec_mux_get(fwnode);
if (IS_ERR(alt_port->typec_mux)) {
- fwnode_handle_put(fwnode);
- return dev_err_probe(dev, PTR_ERR(alt_port->typec_mux),
- "failed to acquire mode-switch for port: %d\n",
- port);
+ ret = dev_err_probe(dev, PTR_ERR(alt_port->typec_mux),
+ "failed to acquire mode-switch for port: %d\n",
+ port);
+ goto put_fwnode;
}
ret = devm_add_action_or_reset(dev, pmic_glink_altmode_put_mux,
alt_port->typec_mux);
- if (ret) {
- fwnode_handle_put(fwnode);
- return ret;
- }
+ if (ret)
+ goto put_fwnode;
alt_port->typec_retimer = fwnode_typec_retimer_get(fwnode);
if (IS_ERR(alt_port->typec_retimer)) {
- fwnode_handle_put(fwnode);
- return dev_err_probe(dev, PTR_ERR(alt_port->typec_retimer),
- "failed to acquire retimer-switch for port: %d\n",
- port);
+ ret = dev_err_probe(dev, PTR_ERR(alt_port->typec_retimer),
+ "failed to acquire retimer-switch for port: %d\n",
+ port);
+ goto put_fwnode;
}
ret = devm_add_action_or_reset(dev, pmic_glink_altmode_put_retimer,
alt_port->typec_retimer);
- if (ret) {
- fwnode_handle_put(fwnode);
- return ret;
- }
+ if (ret)
+ goto put_fwnode;
alt_port->typec_switch = fwnode_typec_switch_get(fwnode);
if (IS_ERR(alt_port->typec_switch)) {
- fwnode_handle_put(fwnode);
- return dev_err_probe(dev, PTR_ERR(alt_port->typec_switch),
- "failed to acquire orientation-switch for port: %d\n",
- port);
+ ret = dev_err_probe(dev, PTR_ERR(alt_port->typec_switch),
+ "failed to acquire orientation-switch for port: %d\n",
+ port);
+ goto put_fwnode;
}
ret = devm_add_action_or_reset(dev, pmic_glink_altmode_put_switch,
alt_port->typec_switch);
- if (ret) {
- fwnode_handle_put(fwnode);
- return ret;
- }
+ if (ret)
+ goto put_fwnode;
}
for (port = 0; port < ARRAY_SIZE(altmode->ports); port++) {
@@ -526,6 +519,10 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev,
pmic_glink_altmode_pdr_notify,
altmode);
return PTR_ERR_OR_ZERO(altmode->client);
+
+put_fwnode:
+ fwnode_handle_put(fwnode);
+ return ret;
}
static const struct auxiliary_device_id pmic_glink_altmode_id_table[] = {
--
2.43.2
More information about the linux-phy
mailing list