Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 34ED9C77B73 for ; Tue, 2 May 2023 06:51:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 03BD6862DC; Tue, 2 May 2023 08:51:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="nmAB+ggD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 59468863A7; Tue, 2 May 2023 08:51:13 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4CE8E862DC for ; Tue, 2 May 2023 08:51:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=eugen.hristev@collabora.com Received: from eugen-station.. (unknown [82.76.24.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: ehristev) by madras.collabora.co.uk (Postfix) with ESMTPSA id 4EEA6660321C; Tue, 2 May 2023 07:51:10 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1683010270; bh=SMXMzO5RrY4T7OUXR1YkvYtH1Gv6qYgD5EztMTLYpm8=; h=From:To:Cc:Subject:Date:From; b=nmAB+ggDn2b/ka8N8Cm2buFi0+US5m9BIa19DSPA2GPDUHQqV5rn+Rakk+DQtgxrL p5gLHxP2KbLMXGR3iAJ6SvqTQRmqOEaxCfydkJj22N2c+zHjd/6eTTC/uyxm3+sL1S JYa6eAUgPmOifdvFT8Ofec8wo/5dpEuerni28t+vtPWAvgK/aabqSEb1ifPHjtyf/W vfcYPlAP2YGP9TzDyelgVZ8TUBE00dLvJb6oVRnVyUZrOjYew259vHY8+968u9T/DP Vg96O3ttTqZHZH1jZLcpeVzNJNgyVKpVNW5RXQqkTtz4vRKWNlCCB3V0FbF45Xx76i bv/MXTu+TilbQ== From: Eugen Hristev To: u-boot@lists.denx.de, tharvey@gateworks.com Cc: sjg@chromium.org, marex@denx.de, Eugen Hristev Subject: [PATCH] usb: ehci-mx6: replace regulator_set_enable with *_if_allowed Date: Tue, 2 May 2023 09:51:04 +0300 Message-Id: <20230502065104.32242-1-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean regulator_set_enable_if_allowed already handles cases when the regulator is already enabled, or already disabled, and does not treat these as errors. With this change, the driver can work correctly even if the regulator is already taken or already disabled by another consumer. Signed-off-by: Eugen Hristev --- Hi Tim, I have not tested this as I do not have a mx6 board. can you please try it ? Thanks, Eugen drivers/usb/host/ehci-mx6.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c index 91633f013a55..7806a4de71e0 100644 --- a/drivers/usb/host/ehci-mx6.c +++ b/drivers/usb/host/ehci-mx6.c @@ -480,9 +480,9 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev) #if CONFIG_IS_ENABLED(DM_REGULATOR) if (priv->vbus_supply) { int ret; - ret = regulator_set_enable(priv->vbus_supply, - (type == USB_INIT_DEVICE) ? - false : true); + ret = regulator_set_enable_if_allowed(priv->vbus_supply, + (type == USB_INIT_DEVICE) ? + false : true); if (ret && ret != -ENOSYS) { printf("Error enabling VBUS supply (ret=%i)\n", ret); return ret; @@ -707,9 +707,9 @@ static int ehci_usb_probe(struct udevice *dev) #if CONFIG_IS_ENABLED(DM_REGULATOR) if (priv->vbus_supply) { - ret = regulator_set_enable(priv->vbus_supply, - (type == USB_INIT_DEVICE) ? - false : true); + ret = regulator_set_enable_if_allowed(priv->vbus_supply, + (type == USB_INIT_DEVICE) ? + false : true); if (ret && ret != -ENOSYS) { printf("Error enabling VBUS supply (ret=%i)\n", ret); goto err_clk; @@ -748,7 +748,7 @@ err_regulator: #endif #if CONFIG_IS_ENABLED(DM_REGULATOR) if (priv->vbus_supply) - regulator_set_enable(priv->vbus_supply, false); + regulator_set_enable_if_allowed(priv->vbus_supply, false); #endif err_clk: #if CONFIG_IS_ENABLED(CLK) @@ -772,7 +772,7 @@ int ehci_usb_remove(struct udevice *dev) #if CONFIG_IS_ENABLED(DM_REGULATOR) if (priv->vbus_supply) - regulator_set_enable(priv->vbus_supply, false); + regulator_set_enable_if_allowed(priv->vbus_supply, false); #endif #if CONFIG_IS_ENABLED(CLK) -- 2.34.1