All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [PATCH 07/19] usb: ehci-mx6: Turn off Vbus on probe failure
Date: Fri,  2 Apr 2021 14:48:00 +0200	[thread overview]
Message-ID: <20210402124812.186761-7-marex@denx.de> (raw)
In-Reply-To: <20210402124812.186761-1-marex@denx.de>

The driver turns on Vbus regulator in probe, but fails to turn it back
off in case of probe failure. Add the missing code.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Ye Li <ye.li@nxp.com>
Cc: uboot-imx <uboot-imx@nxp.com>
---
 drivers/usb/host/ehci-mx6.c | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index aeea5399995..6fb596633a3 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -640,7 +640,32 @@ static int ehci_usb_probe(struct udevice *dev)
 	hcor = (struct ehci_hcor *)((uint32_t)hccr +
 			HC_LENGTH(ehci_readl(&(hccr)->cr_capbase)));
 
-	return ehci_register(dev, hccr, hcor, &mx6_ehci_ops, 0, priv->init_type);
+	ret = ehci_register(dev, hccr, hcor, &mx6_ehci_ops, 0, priv->init_type);
+	if (ret)
+		goto err_regulator;
+
+	return ret;
+
+err_regulator:
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
+	if (priv->vbus_supply)
+		regulator_set_enable(priv->vbus_supply, false);
+#endif
+	return ret;
+}
+
+int ehci_usb_remove(struct udevice *dev)
+{
+	struct ehci_mx6_priv_data *priv = dev_get_priv(dev);
+
+	ehci_deregister(dev);
+
+#if CONFIG_IS_ENABLED(DM_REGULATOR)
+	if (priv->vbus_supply)
+		regulator_set_enable(priv->vbus_supply, false);
+#endif
+
+	return 0;
 }
 
 static const struct udevice_id mx6_usb_ids[] = {
@@ -655,7 +680,7 @@ U_BOOT_DRIVER(usb_mx6) = {
 	.of_to_plat = ehci_usb_of_to_plat,
 	.bind	= ehci_usb_bind,
 	.probe	= ehci_usb_probe,
-	.remove = ehci_deregister,
+	.remove = ehci_usb_remove,
 	.ops	= &ehci_usb_ops,
 	.plat_auto	= sizeof(struct usb_plat),
 	.priv_auto	= sizeof(struct ehci_mx6_priv_data),
-- 
2.30.2

  parent reply	other threads:[~2021-04-02 12:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-02 12:47 [PATCH 01/19] phy: nop-phy: Add standard usb-nop-xceiv compat string Marek Vasut
2021-04-02 12:47 ` [PATCH 02/19] arc: emsdp/iotdk: Use standard compatible string for USB no-op PHY Marek Vasut
2021-04-02 12:47 ` [PATCH 03/19] ARM: dts: k2g-evm: " Marek Vasut
2021-04-02 12:47 ` [PATCH 04/19] ARM: dts: imx8mm: Replace deprecated fsl, usbphy DT props with phys Marek Vasut
2021-04-02 12:47 ` [PATCH 05/19] ARM: dts: imx8mm: Add power domain nodes Marek Vasut
2021-04-04 23:24   ` Jaehoon Chung
2021-04-02 12:47 ` [PATCH 06/19] imx: power-domain: Add fsl, imx8mm-gpc compatible string Marek Vasut
2021-04-04 23:26   ` Jaehoon Chung
2021-04-02 12:48 ` Marek Vasut [this message]
2021-04-02 12:48 ` [PATCH 08/19] usb: ehci-mx6: Add DM clock support Marek Vasut
2021-04-02 12:48 ` [PATCH 09/19] usb: ehci-mx6: Unify USBNC registers Marek Vasut
2021-04-02 12:48 ` [PATCH 10/19] usb: ehci-mx6: Parse USB PHY and MISC offsets from DT Marek Vasut
2021-04-02 12:48 ` [PATCH 11/19] usb: ehci-mx6: Split ehci_mx6_common_init() Marek Vasut
2021-04-02 12:48 ` [PATCH 12/19] usb: ehci-mx6: Pass PHY address to usb_*_phy*() Marek Vasut
2021-04-02 12:48 ` [PATCH 13/19] usb: ehci-mx6: Split usb_power_config() Marek Vasut
2021-04-02 12:48 ` [PATCH 14/19] usb: ehci-mx6: Pass MISC address to usb_oc_config() Marek Vasut
2021-04-02 12:48 ` [PATCH 15/19] usb: ehci-mx6: Use portnr in DM only if PHY is disabled Marek Vasut
2021-04-02 12:48 ` [PATCH 16/19] usb: ehci-mx6: Add generic EHCI PHY support Marek Vasut
2021-04-02 12:48 ` [PATCH 17/19] usb: ehci-mx6: Add fsl,imx7d-usb compatible string Marek Vasut
2021-04-02 12:48 ` [PATCH 18/19] usb: ehci-mx6: Add iMX8M support Marek Vasut
2021-04-02 12:48 ` [PATCH 19/19] ARM: imx8m: verdin-imx8mm: Enable USB Host support Marek Vasut
2021-04-07  7:07   ` Oleksandr Suvorov
2021-04-08  7:08   ` Marcel Ziswiler
2021-04-10  0:48     ` Marek Vasut
2021-04-06 19:34 ` [PATCH 01/19] phy: nop-phy: Add standard usb-nop-xceiv compat string Harm Berntsen
2021-04-06 19:53   ` Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210402124812.186761-7-marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.