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 BA14CC0015E for ; Wed, 19 Jul 2023 21:21:33 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 219A4867A0; Wed, 19 Jul 2023 23:21:08 +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="CdU8JfSL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 281FA86797; 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 7509384773 for ; Wed, 19 Jul 2023 23:20:58 +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=T0i06skGkmRjFIcyN4FsdBWZpKfQXFbQOhlTedQLnjU=; b=CdU8JfSLICUKyIcU+zY3EwOoRuGT73xMpio7Nfieq16Fq60VTP4Wpa9C5WdqlLyCKMx+ u9aYzBSq31t9sZS6uVP9ccsQQJ6H6RAsnKAyP8/SMeRH0m/9attqpL00TxOcTTdqDuRdZW D5lNQwFILNfoofhVncKTcGVc+rWV2yzaoUuLDRsWb+yVuqeZyVLff64uObUQLnr9riIdt5 u7d7unEceWwwBq+RX6CRQChn5wzEfPPdQ5pXE3ppa1vbt74ug3Ya04psS59Uce51vSqeui vlXQM5vC2UprWJ8ii/WLA22f6+P5lxkRnJA7cH1McyWWQQqNqXva6Callg/sWWVg== Received: by filterdrecv-84b96456cb-5hl7m with SMTP id filterdrecv-84b96456cb-5hl7m-1-64B853B8-C 2023-07-19 21:20:56.347787129 +0000 UTC m=+6039760.316534627 Received: from bionic.localdomain (unknown) by geopod-ismtpd-1 (SG) with ESMTP id 7i22uA-yQ0mdZ5R_bovfSw Wed, 19 Jul 2023 21:20:56.034 +0000 (UTC) From: Jonas Karlman Subject: [PATCH 2/5] usb: dwc2: Use regulator_set_enable_if_allowed Date: Wed, 19 Jul 2023 21:20:56 +0000 (UTC) Message-ID: <20230719212049.709358-3-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+RrMu3cja6a0h44vZDBmqyGxFY+XD?= =?us-ascii?Q?xGVc3NM5Tyq11ItPoAkUzPqgZFqCgMryiZ1GaP7?= =?us-ascii?Q?LiDPYagls+3L1Nfniv9IN5emky9qO3WvI50SHYW?= =?us-ascii?Q?Ahi+5YXiObSPPA=2FORk+omC5LxEdlVCwqzcsk6eJ?= =?us-ascii?Q?yva1jU5L7oYkcf2EJdUa53Cq6offwU++pRjHD7?= 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/dwc2.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index 9818f9be94e0..637eb2dd06f5 100644 --- a/drivers/usb/host/dwc2.c +++ b/drivers/usb/host/dwc2.c @@ -194,8 +194,8 @@ static int dwc_vbus_supply_init(struct udevice *dev) return 0; } - ret = regulator_set_enable(priv->vbus_supply, true); - if (ret) { + ret = regulator_set_enable_if_allowed(priv->vbus_supply, true); + if (ret && ret != -ENOSYS) { dev_err(dev, "Error enabling vbus supply\n"); return ret; } @@ -208,12 +208,10 @@ static int dwc_vbus_supply_exit(struct udevice *dev) struct dwc2_priv *priv = dev_get_priv(dev); int ret; - if (priv->vbus_supply) { - ret = regulator_set_enable(priv->vbus_supply, false); - if (ret) { - dev_err(dev, "Error disabling vbus supply\n"); - return ret; - } + ret = regulator_set_enable_if_allowed(priv->vbus_supply, false); + if (ret && ret != -ENOSYS) { + dev_err(dev, "Error disabling vbus supply\n"); + return ret; } return 0; -- 2.41.0