[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <29b63eb4-2342-4ca8-a313-5de2a6ec6a83@web.de>
Date: Wed, 28 Feb 2024 19:05:20 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: linux-arm-msm@...r.kernel.org, kernel-janitors@...r.kernel.org,
Bjorn Andersson <andersson@...nel.org>,
Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Johan Hovold <johan+linaro@...nel.org>,
Konrad Dybcio <konrad.dybcio@...aro.org>
Cc: LKML <linux-kernel@...r.kernel.org>, freedreno@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org, linux-phy@...ts.infradead.org,
Abhinav Kumar <quic_abhinavk@...cinc.com>,
Andrzej Hajda <andrzej.hajda@...el.com>, Daniel Vetter <daniel@...ll.ch>,
David Airlie <airlied@...il.com>, Jernej Skrabec <jernej.skrabec@...il.com>,
Jonas Karlman <jonas@...boo.se>, Kishon Vijay Abraham I <kishon@...nel.org>,
Kuogee Hsieh <quic_khsieh@...cinc.com>,
Laurent Pinchart <Laurent.pinchart@...asonboard.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Neil Armstrong <neil.armstrong@...aro.org>, Rob Clark <robdclark@...il.com>,
Robert Foss <rfoss@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>
Subject: [PATCH] soc: qcom: pmic_glink_altmode: Use common error handling code
in pmic_glink_altmode_probe()
From: Markus Elfring <elfring@...rs.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@...rs.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
Powered by blists - more mailing lists