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 9530AC0015E for ; Wed, 19 Jul 2023 21:21:23 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 056EA8679B; Wed, 19 Jul 2023 23:21:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kwiboo.se 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=kwiboo.se header.i=@kwiboo.se header.b="TnKHmcxv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 702A986786; Wed, 19 Jul 2023 23:21:02 +0200 (CEST) Received: from s.wrqvtzvf.outbound-mail.sendgrid.net (s.wrqvtzvf.outbound-mail.sendgrid.net [149.72.126.143]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4DF7286789 for ; Wed, 19 Jul 2023 23:20:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bounces+31435339-7456-u-boot=lists.denx.de@em2124.kwiboo.se DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type:cc:content-type:from:subject:to; s=s1; bh=AI/VRRwmcMHHfDeVzAQhg4NhZ1odriM/5huM9mMvqhU=; b=TnKHmcxvKbeTmD8HSqbsExG01symW901jTDFIu6Yjr8PuxVA2hhUQST7DfoWLz7XljS1 K4zsBqgyOyNU8sL0kEV4vrs0m1cF5FXMNFjFBwLPaaVruGO22ipj7s9eRiqxNyWrkSMwOE 2Zfn1A/HUuYR1+hXeJlvx5nwZjkxDFmh7lt/pKo1DEahWTU0lDr0mvDi0P2bxXS0N2ofik p1iN0+AusimOnwyuOz8RB/jZUgbiAeOVObYzcay2M8F5x/yRPvwbjiywoJ8h0EOEXCcSxP Vc2fAflHMfh5VChOezVkP4zueO4yp//Z1HEgZb/zwxT1NE3p+itXdAI1mcRO1TqQ== Received: by filterdrecv-65f68489c8-lsfh9 with SMTP id filterdrecv-65f68489c8-lsfh9-1-64B853B9-1B 2023-07-19 21:20:57.680418019 +0000 UTC m=+6039898.512519593 Received: from bionic.localdomain (unknown) by geopod-ismtpd-1 (SG) with ESMTP id KBfyghcrTvmknYTMnFmF8Q Wed, 19 Jul 2023 21:20:57.466 +0000 (UTC) From: Jonas Karlman Subject: [PATCH 3/5] usb: ehci-generic: Use regulator_set_enable_if_allowed Date: Wed, 19 Jul 2023 21:20:57 +0000 (UTC) Message-ID: <20230719212049.709358-4-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230719212049.709358-1-jonas@kwiboo.se> References: <20230719212049.709358-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxA?= =?us-ascii?Q?fZekEeQsTe+RrMu3cja6a0h33sQ6Dq178umNFdi?= =?us-ascii?Q?mTI=2FcdRBX5QgvGq7lllG=2FAm9H50pTIOsY2FfDf7?= =?us-ascii?Q?cWNhdEhHx51jqa+CGVxPy4nYzD7xJXTHZuowxaS?= =?us-ascii?Q?t+RAaIuZZpAiKIBkyZi7FCFamG9OAHDBNsf1I4E?= =?us-ascii?Q?YR=2FMdpwK5OMXNRGpXKXxPLjWlTfLA3AzH9oFkH?= To: Simon Glass , Marek Vasut , Peng Fan , Jaehoon Chung , Patrice Chotard Cc: Eugen Hristev , Svyatoslav Ryhel , u-boot@lists.denx.de, Jonas Karlman X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii 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 With the commit 4fcba5d556b4 ("regulator: implement basic reference counter") the return value of regulator_set_enable may be EALREADY or EBUSY for fixed/gpio regulators. Change to use the more relaxed regulator_set_enable_if_allowed to continue if regulator already was enabled or disabled. Signed-off-by: Jonas Karlman --- drivers/usb/host/ehci-generic.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/usb/host/ehci-generic.c b/drivers/usb/host/ehci-generic.c index a765a307a323..936e30438d9f 100644 --- a/drivers/usb/host/ehci-generic.c +++ b/drivers/usb/host/ehci-generic.c @@ -39,14 +39,10 @@ static int ehci_enable_vbus_supply(struct udevice *dev) if (ret && ret != -ENOENT) return ret; - if (priv->vbus_supply) { - ret = regulator_set_enable(priv->vbus_supply, true); - if (ret) { - dev_err(dev, "Error enabling VBUS supply (ret=%d)\n", ret); - return ret; - } - } else { - dev_dbg(dev, "No vbus supply\n"); + ret = regulator_set_enable_if_allowed(priv->vbus_supply, true); + if (ret && ret != -ENOSYS) { + dev_err(dev, "Error enabling VBUS supply (ret=%d)\n", ret); + return ret; } return 0; @@ -54,10 +50,13 @@ static int ehci_enable_vbus_supply(struct udevice *dev) static int ehci_disable_vbus_supply(struct generic_ehci *priv) { - if (priv->vbus_supply) - return regulator_set_enable(priv->vbus_supply, false); - else - return 0; + int ret; + + ret = regulator_set_enable_if_allowed(priv->vbus_supply, false); + if (ret && ret != -ENOSYS) + return ret; + + return 0; } static int ehci_usb_probe(struct udevice *dev) -- 2.41.0