From 5dcbbb0881a0c4a52a7ab0fdac5ddadc21afa4dd Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Thu, 6 Jun 2024 15:11:13 +0200 Subject: [PATCH] usb: typec-mux: ptn36502: unregister typec switch on probe error and remove BugLink: https://bugs.launchpad.net/bugs/2083196 [ Upstream commit 2be53b0436fda455e1bf6968ebae53f5d4f3cb0b ] Add the missing call to typec_switch_put() when probe fails and the ptn36502_remove() call is called. Fixes: 8e99dc783648 ("usb: typec: add support for PTN36502 redriver") Signed-off-by: Neil Armstrong Reviewed-by: Heikki Krogerus Reviewed-by: Dmitry Baryshkov Link: https://lore.kernel.org/r/20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-1-c6f6eae479c3@linaro.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Portia Stephens Signed-off-by: Roxana Nicolescu --- drivers/usb/typec/mux/ptn36502.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/mux/ptn36502.c b/drivers/usb/typec/mux/ptn36502.c index 72ae38a1b2be..a643584f80b4 100644 --- a/drivers/usb/typec/mux/ptn36502.c +++ b/drivers/usb/typec/mux/ptn36502.c @@ -362,8 +362,10 @@ static int ptn36502_probe(struct i2c_client *client) "Failed to acquire orientation-switch\n"); ret = regulator_enable(ptn->vdd18_supply); - if (ret) - return dev_err_probe(dev, ret, "Failed to enable vdd18\n"); + if (ret) { + ret = dev_err_probe(dev, ret, "Failed to enable vdd18\n"); + goto err_switch_put; + } ret = ptn36502_detect(ptn); if (ret) @@ -403,6 +405,9 @@ err_switch_unregister: err_disable_regulator: regulator_disable(ptn->vdd18_supply); +err_switch_put: + typec_switch_put(ptn->typec_switch); + return ret; } @@ -414,6 +419,8 @@ static void ptn36502_remove(struct i2c_client *client) typec_switch_unregister(ptn->sw); regulator_disable(ptn->vdd18_supply); + + typec_switch_put(ptn->typec_switch); } static const struct i2c_device_id ptn36502_table[] = {