linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] usb: chipidea: ci_hdrc_imx: fix some issues in probe/remove
@ 2025-03-16 10:26 Fedor Pchelkin
  2025-03-16 10:26 ` [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: fix usbmisc handling Fedor Pchelkin
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Fedor Pchelkin @ 2025-03-16 10:26 UTC (permalink / raw)
  To: Peter Chen, Frank Li
  Cc: Fedor Pchelkin, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Joe Hattori,
	Sebastian Reichel, Fabien Lahoudere, linux-usb, imx,
	linux-arm-kernel, linux-kernel, lvc-project

The first patch fixes a rather recently introduced bug leading to the
driver oopsing on removal in case of non-usbmisc devices.

The other ones perform error path fixes in the probe function.

Link to v1
https://lore.kernel.org/linux-usb/20250309175805.661684-1-pchelkin@ispras.ru/t/#u

Fedor Pchelkin (3):
  usb: chipidea: ci_hdrc_imx: fix usbmisc handling
  usb: chipidea: ci_hdrc_imx: fix call balance of regulator routines
  usb: chipidea: ci_hdrc_imx: implement usb_phy_init() error handling

 drivers/usb/chipidea/ci_hdrc_imx.c | 44 +++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 13 deletions(-)

-- 
2.48.1



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: fix usbmisc handling
  2025-03-16 10:26 [PATCH v2 0/3] usb: chipidea: ci_hdrc_imx: fix some issues in probe/remove Fedor Pchelkin
@ 2025-03-16 10:26 ` Fedor Pchelkin
  2025-03-17  1:53   ` Peter Chen (CIX)
  2025-03-16 10:26 ` [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: fix call balance of regulator routines Fedor Pchelkin
  2025-03-16 10:26 ` [PATCH v2 3/3] usb: chipidea: ci_hdrc_imx: implement usb_phy_init() error handling Fedor Pchelkin
  2 siblings, 1 reply; 7+ messages in thread
From: Fedor Pchelkin @ 2025-03-16 10:26 UTC (permalink / raw)
  To: Peter Chen, Frank Li
  Cc: Fedor Pchelkin, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Joe Hattori,
	Sebastian Reichel, Fabien Lahoudere, linux-usb, imx,
	linux-arm-kernel, linux-kernel, lvc-project, stable

usbmisc is an optional device property so it is totally valid for the
corresponding data->usbmisc_data to have a NULL value.

Check that before dereferencing the pointer.

Found by Linux Verification Center (linuxtesting.org) with Svace static
analysis tool.

Fixes: 74adad500346 ("usb: chipidea: ci_hdrc_imx: decrement device's refcount in .remove() and in the error path of .probe()")
Cc: stable@vger.kernel.org
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 1a7fc638213e..619779eef333 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -534,7 +534,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 		cpu_latency_qos_remove_request(&data->pm_qos_req);
 	data->ci_pdev = NULL;
 err_put:
-	put_device(data->usbmisc_data->dev);
+	if (data->usbmisc_data)
+		put_device(data->usbmisc_data->dev);
 	return ret;
 }
 
@@ -559,7 +560,8 @@ static void ci_hdrc_imx_remove(struct platform_device *pdev)
 		if (data->hsic_pad_regulator)
 			regulator_disable(data->hsic_pad_regulator);
 	}
-	put_device(data->usbmisc_data->dev);
+	if (data->usbmisc_data)
+		put_device(data->usbmisc_data->dev);
 }
 
 static void ci_hdrc_imx_shutdown(struct platform_device *pdev)
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: fix call balance of regulator routines
  2025-03-16 10:26 [PATCH v2 0/3] usb: chipidea: ci_hdrc_imx: fix some issues in probe/remove Fedor Pchelkin
  2025-03-16 10:26 ` [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: fix usbmisc handling Fedor Pchelkin
@ 2025-03-16 10:26 ` Fedor Pchelkin
  2025-03-17  1:54   ` Peter Chen (CIX)
  2025-03-16 10:26 ` [PATCH v2 3/3] usb: chipidea: ci_hdrc_imx: implement usb_phy_init() error handling Fedor Pchelkin
  2 siblings, 1 reply; 7+ messages in thread
From: Fedor Pchelkin @ 2025-03-16 10:26 UTC (permalink / raw)
  To: Peter Chen, Frank Li
  Cc: Fedor Pchelkin, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Joe Hattori,
	Sebastian Reichel, Fabien Lahoudere, linux-usb, imx,
	linux-arm-kernel, linux-kernel, lvc-project, stable

Upon encountering errors during the HSIC pinctrl handling section the
regulator should be disabled.

Use devm_add_action_or_reset() to let the regulator-disabling routine be
handled by device resource management stack.

Found by Linux Verification Center (linuxtesting.org).

Fixes: 4d6141288c33 ("usb: chipidea: imx: pinctrl for HSIC is optional")
Cc: stable@vger.kernel.org
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---
v2: simplify the patch taking advantage of devm-helper (Frank Li)

It looks like devm_regulator_get_enable_optional() exists for this very
use case utilized in the driver but it's not present in old supported
stable kernels and I may say those dependency-patches wouldn't apply there
cleanly. So fix the problem first, further code simplification is a
subject to cleanup patch.

 drivers/usb/chipidea/ci_hdrc_imx.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 619779eef333..d942b3c72640 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -336,6 +336,13 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned int event)
 	return ret;
 }
 
+static void ci_hdrc_imx_disable_regulator(void *arg)
+{
+	struct ci_hdrc_imx_data *data = arg;
+
+	regulator_disable(data->hsic_pad_regulator);
+}
+
 static int ci_hdrc_imx_probe(struct platform_device *pdev)
 {
 	struct ci_hdrc_imx_data *data;
@@ -394,6 +401,13 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 					"Failed to enable HSIC pad regulator\n");
 				goto err_put;
 			}
+			ret = devm_add_action_or_reset(dev,
+					ci_hdrc_imx_disable_regulator, data);
+			if (ret) {
+				dev_err(dev,
+					"Failed to add regulator devm action\n");
+				goto err_put;
+			}
 		}
 	}
 
@@ -432,11 +446,11 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 
 	ret = imx_get_clks(dev);
 	if (ret)
-		goto disable_hsic_regulator;
+		goto qos_remove_request;
 
 	ret = imx_prepare_enable_clks(dev);
 	if (ret)
-		goto disable_hsic_regulator;
+		goto qos_remove_request;
 
 	ret = clk_prepare_enable(data->clk_wakeup);
 	if (ret)
@@ -526,10 +540,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 	clk_disable_unprepare(data->clk_wakeup);
 err_wakeup_clk:
 	imx_disable_unprepare_clks(dev);
-disable_hsic_regulator:
-	if (data->hsic_pad_regulator)
-		/* don't overwrite original ret (cf. EPROBE_DEFER) */
-		regulator_disable(data->hsic_pad_regulator);
+qos_remove_request:
 	if (pdata.flags & CI_HDRC_PMQOS)
 		cpu_latency_qos_remove_request(&data->pm_qos_req);
 	data->ci_pdev = NULL;
@@ -557,8 +568,6 @@ static void ci_hdrc_imx_remove(struct platform_device *pdev)
 		clk_disable_unprepare(data->clk_wakeup);
 		if (data->plat_data->flags & CI_HDRC_PMQOS)
 			cpu_latency_qos_remove_request(&data->pm_qos_req);
-		if (data->hsic_pad_regulator)
-			regulator_disable(data->hsic_pad_regulator);
 	}
 	if (data->usbmisc_data)
 		put_device(data->usbmisc_data->dev);
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/3] usb: chipidea: ci_hdrc_imx: implement usb_phy_init() error handling
  2025-03-16 10:26 [PATCH v2 0/3] usb: chipidea: ci_hdrc_imx: fix some issues in probe/remove Fedor Pchelkin
  2025-03-16 10:26 ` [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: fix usbmisc handling Fedor Pchelkin
  2025-03-16 10:26 ` [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: fix call balance of regulator routines Fedor Pchelkin
@ 2025-03-16 10:26 ` Fedor Pchelkin
  2025-03-17  1:56   ` Peter Chen (CIX)
  2 siblings, 1 reply; 7+ messages in thread
From: Fedor Pchelkin @ 2025-03-16 10:26 UTC (permalink / raw)
  To: Peter Chen, Frank Li
  Cc: Fedor Pchelkin, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Joe Hattori,
	Sebastian Reichel, Fabien Lahoudere, linux-usb, imx,
	linux-arm-kernel, linux-kernel, lvc-project, stable

usb_phy_init() may return an error code if e.g. its implementation fails
to prepare/enable some clocks. And properly rollback on probe error path
by calling the counterpart usb_phy_shutdown().

Found by Linux Verification Center (linuxtesting.org).

Fixes: be9cae2479f4 ("usb: chipidea: imx: Fix ULPI on imx53")
Cc: stable@vger.kernel.org
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---
 drivers/usb/chipidea/ci_hdrc_imx.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index d942b3c72640..4f8bfd242b59 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -484,7 +484,11 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 	    of_usb_get_phy_mode(np) == USBPHY_INTERFACE_MODE_ULPI) {
 		pdata.flags |= CI_HDRC_OVERRIDE_PHY_CONTROL;
 		data->override_phy_control = true;
-		usb_phy_init(pdata.usb_phy);
+		ret = usb_phy_init(pdata.usb_phy);
+		if (ret) {
+			dev_err(dev, "Failed to init phy\n");
+			goto err_clk;
+		}
 	}
 
 	if (pdata.flags & CI_HDRC_SUPPORTS_RUNTIME_PM)
@@ -493,7 +497,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 	ret = imx_usbmisc_init(data->usbmisc_data);
 	if (ret) {
 		dev_err(dev, "usbmisc init failed, ret=%d\n", ret);
-		goto err_clk;
+		goto phy_shutdown;
 	}
 
 	data->ci_pdev = ci_hdrc_add_device(dev,
@@ -502,7 +506,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 	if (IS_ERR(data->ci_pdev)) {
 		ret = PTR_ERR(data->ci_pdev);
 		dev_err_probe(dev, ret, "ci_hdrc_add_device failed\n");
-		goto err_clk;
+		goto phy_shutdown;
 	}
 
 	if (data->usbmisc_data) {
@@ -536,6 +540,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
 
 disable_device:
 	ci_hdrc_remove_device(data->ci_pdev);
+phy_shutdown:
+	if (data->override_phy_control)
+		usb_phy_shutdown(data->phy);
 err_clk:
 	clk_disable_unprepare(data->clk_wakeup);
 err_wakeup_clk:
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: fix usbmisc handling
  2025-03-16 10:26 ` [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: fix usbmisc handling Fedor Pchelkin
@ 2025-03-17  1:53   ` Peter Chen (CIX)
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Chen (CIX) @ 2025-03-17  1:53 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: Frank Li, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Joe Hattori,
	Sebastian Reichel, Fabien Lahoudere, linux-usb, imx,
	linux-arm-kernel, linux-kernel, lvc-project, stable

On 25-03-16 13:26:54, Fedor Pchelkin wrote:
> usbmisc is an optional device property so it is totally valid for the
> corresponding data->usbmisc_data to have a NULL value.
> 
> Check that before dereferencing the pointer.
> 
> Found by Linux Verification Center (linuxtesting.org) with Svace static
> analysis tool.
> 
> Fixes: 74adad500346 ("usb: chipidea: ci_hdrc_imx: decrement device's refcount in .remove() and in the error path of .probe()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>

Acked-by: Peter Chen <peter.chen@kernel.org>

Peter
> ---
>  drivers/usb/chipidea/ci_hdrc_imx.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index 1a7fc638213e..619779eef333 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -534,7 +534,8 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  		cpu_latency_qos_remove_request(&data->pm_qos_req);
>  	data->ci_pdev = NULL;
>  err_put:
> -	put_device(data->usbmisc_data->dev);
> +	if (data->usbmisc_data)
> +		put_device(data->usbmisc_data->dev);
>  	return ret;
>  }
>  
> @@ -559,7 +560,8 @@ static void ci_hdrc_imx_remove(struct platform_device *pdev)
>  		if (data->hsic_pad_regulator)
>  			regulator_disable(data->hsic_pad_regulator);
>  	}
> -	put_device(data->usbmisc_data->dev);
> +	if (data->usbmisc_data)
> +		put_device(data->usbmisc_data->dev);
>  }
>  
>  static void ci_hdrc_imx_shutdown(struct platform_device *pdev)
> -- 
> 2.48.1
> 

-- 

Best regards,
Peter


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: fix call balance of regulator routines
  2025-03-16 10:26 ` [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: fix call balance of regulator routines Fedor Pchelkin
@ 2025-03-17  1:54   ` Peter Chen (CIX)
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Chen (CIX) @ 2025-03-17  1:54 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: Frank Li, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Joe Hattori,
	Sebastian Reichel, Fabien Lahoudere, linux-usb, imx,
	linux-arm-kernel, linux-kernel, lvc-project, stable

On 25-03-16 13:26:55, Fedor Pchelkin wrote:
> Upon encountering errors during the HSIC pinctrl handling section the
> regulator should be disabled.
> 
> Use devm_add_action_or_reset() to let the regulator-disabling routine be
> handled by device resource management stack.
> 
> Found by Linux Verification Center (linuxtesting.org).
> 
> Fixes: 4d6141288c33 ("usb: chipidea: imx: pinctrl for HSIC is optional")
> Cc: stable@vger.kernel.org
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>

Acked-by: Peter Chen <peter.chen@kernel.org>


> ---
> v2: simplify the patch taking advantage of devm-helper (Frank Li)
> 
> It looks like devm_regulator_get_enable_optional() exists for this very
> use case utilized in the driver but it's not present in old supported
> stable kernels and I may say those dependency-patches wouldn't apply there
> cleanly. So fix the problem first, further code simplification is a
> subject to cleanup patch.
> 
>  drivers/usb/chipidea/ci_hdrc_imx.c | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index 619779eef333..d942b3c72640 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -336,6 +336,13 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned int event)
>  	return ret;
>  }
>  
> +static void ci_hdrc_imx_disable_regulator(void *arg)
> +{
> +	struct ci_hdrc_imx_data *data = arg;
> +
> +	regulator_disable(data->hsic_pad_regulator);
> +}
> +
>  static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  {
>  	struct ci_hdrc_imx_data *data;
> @@ -394,6 +401,13 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  					"Failed to enable HSIC pad regulator\n");
>  				goto err_put;
>  			}
> +			ret = devm_add_action_or_reset(dev,
> +					ci_hdrc_imx_disable_regulator, data);
> +			if (ret) {
> +				dev_err(dev,
> +					"Failed to add regulator devm action\n");
> +				goto err_put;
> +			}
>  		}
>  	}
>  
> @@ -432,11 +446,11 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  
>  	ret = imx_get_clks(dev);
>  	if (ret)
> -		goto disable_hsic_regulator;
> +		goto qos_remove_request;
>  
>  	ret = imx_prepare_enable_clks(dev);
>  	if (ret)
> -		goto disable_hsic_regulator;
> +		goto qos_remove_request;
>  
>  	ret = clk_prepare_enable(data->clk_wakeup);
>  	if (ret)
> @@ -526,10 +540,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  	clk_disable_unprepare(data->clk_wakeup);
>  err_wakeup_clk:
>  	imx_disable_unprepare_clks(dev);
> -disable_hsic_regulator:
> -	if (data->hsic_pad_regulator)
> -		/* don't overwrite original ret (cf. EPROBE_DEFER) */
> -		regulator_disable(data->hsic_pad_regulator);
> +qos_remove_request:
>  	if (pdata.flags & CI_HDRC_PMQOS)
>  		cpu_latency_qos_remove_request(&data->pm_qos_req);
>  	data->ci_pdev = NULL;
> @@ -557,8 +568,6 @@ static void ci_hdrc_imx_remove(struct platform_device *pdev)
>  		clk_disable_unprepare(data->clk_wakeup);
>  		if (data->plat_data->flags & CI_HDRC_PMQOS)
>  			cpu_latency_qos_remove_request(&data->pm_qos_req);
> -		if (data->hsic_pad_regulator)
> -			regulator_disable(data->hsic_pad_regulator);
>  	}
>  	if (data->usbmisc_data)
>  		put_device(data->usbmisc_data->dev);
> -- 
> 2.48.1
> 

-- 

Best regards,
Peter


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 3/3] usb: chipidea: ci_hdrc_imx: implement usb_phy_init() error handling
  2025-03-16 10:26 ` [PATCH v2 3/3] usb: chipidea: ci_hdrc_imx: implement usb_phy_init() error handling Fedor Pchelkin
@ 2025-03-17  1:56   ` Peter Chen (CIX)
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Chen (CIX) @ 2025-03-17  1:56 UTC (permalink / raw)
  To: Fedor Pchelkin
  Cc: Frank Li, Greg Kroah-Hartman, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Joe Hattori,
	Sebastian Reichel, Fabien Lahoudere, linux-usb, imx,
	linux-arm-kernel, linux-kernel, lvc-project, stable

On 25-03-16 13:26:56, Fedor Pchelkin wrote:
> usb_phy_init() may return an error code if e.g. its implementation fails
> to prepare/enable some clocks. And properly rollback on probe error path
> by calling the counterpart usb_phy_shutdown().
> 
> Found by Linux Verification Center (linuxtesting.org).
> 
> Fixes: be9cae2479f4 ("usb: chipidea: imx: Fix ULPI on imx53")
> Cc: stable@vger.kernel.org
> Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>

Acked-by: Peter Chen <peter.chen@kernel.org>

> ---
>  drivers/usb/chipidea/ci_hdrc_imx.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
> index d942b3c72640..4f8bfd242b59 100644
> --- a/drivers/usb/chipidea/ci_hdrc_imx.c
> +++ b/drivers/usb/chipidea/ci_hdrc_imx.c
> @@ -484,7 +484,11 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  	    of_usb_get_phy_mode(np) == USBPHY_INTERFACE_MODE_ULPI) {
>  		pdata.flags |= CI_HDRC_OVERRIDE_PHY_CONTROL;
>  		data->override_phy_control = true;
> -		usb_phy_init(pdata.usb_phy);
> +		ret = usb_phy_init(pdata.usb_phy);
> +		if (ret) {
> +			dev_err(dev, "Failed to init phy\n");
> +			goto err_clk;
> +		}
>  	}
>  
>  	if (pdata.flags & CI_HDRC_SUPPORTS_RUNTIME_PM)
> @@ -493,7 +497,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  	ret = imx_usbmisc_init(data->usbmisc_data);
>  	if (ret) {
>  		dev_err(dev, "usbmisc init failed, ret=%d\n", ret);
> -		goto err_clk;
> +		goto phy_shutdown;
>  	}
>  
>  	data->ci_pdev = ci_hdrc_add_device(dev,
> @@ -502,7 +506,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  	if (IS_ERR(data->ci_pdev)) {
>  		ret = PTR_ERR(data->ci_pdev);
>  		dev_err_probe(dev, ret, "ci_hdrc_add_device failed\n");
> -		goto err_clk;
> +		goto phy_shutdown;
>  	}
>  
>  	if (data->usbmisc_data) {
> @@ -536,6 +540,9 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
>  
>  disable_device:
>  	ci_hdrc_remove_device(data->ci_pdev);
> +phy_shutdown:
> +	if (data->override_phy_control)
> +		usb_phy_shutdown(data->phy);
>  err_clk:
>  	clk_disable_unprepare(data->clk_wakeup);
>  err_wakeup_clk:
> -- 
> 2.48.1
> 

-- 

Best regards,
Peter


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-03-17  1:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-16 10:26 [PATCH v2 0/3] usb: chipidea: ci_hdrc_imx: fix some issues in probe/remove Fedor Pchelkin
2025-03-16 10:26 ` [PATCH v2 1/3] usb: chipidea: ci_hdrc_imx: fix usbmisc handling Fedor Pchelkin
2025-03-17  1:53   ` Peter Chen (CIX)
2025-03-16 10:26 ` [PATCH v2 2/3] usb: chipidea: ci_hdrc_imx: fix call balance of regulator routines Fedor Pchelkin
2025-03-17  1:54   ` Peter Chen (CIX)
2025-03-16 10:26 ` [PATCH v2 3/3] usb: chipidea: ci_hdrc_imx: implement usb_phy_init() error handling Fedor Pchelkin
2025-03-17  1:56   ` Peter Chen (CIX)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).