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 BDA33C0015E for ; Wed, 19 Jul 2023 21:21:13 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 35A2286774; Wed, 19 Jul 2023 23:21:05 +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="DCoP86JV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E7CD886792; Wed, 19 Jul 2023 23:20:59 +0200 (CEST) Received: from s.wrqvtbkv.outbound-mail.sendgrid.net (s.wrqvtbkv.outbound-mail.sendgrid.net [149.72.123.24]) (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 728AB86774 for ; Wed, 19 Jul 2023 23:20:57 +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=5DcwPofrp6DhamzWk848OHWT1aKI0DDWWv8CbwhqpeM=; b=DCoP86JVsNz3V+JhptxzCwJFgVPjybwIznK+EO1voLSpxdbuoRyyav/84Q62IMn7mHvZ UicyC2/bOb5Vpzhrrst2uj4h3YNRRb8zWHdbrrfllpDu05zNxHdwt/XSrCkNO37TGgl7GD djAjn0mckEP0GdPnpAf1nlzG5Wf0V0nHWsgKjLhA/fryRR2Qj5cQgCsiFG+Zvwloo8kVDg OF/2L7CPyquA3zp+AbXCF8L6y+ZjtwOiMd1cxlieNYvghEmxWAaUs7t17sjhUax6Fxn8w4 j1W9r5Q1nXKjNdZQlMNqdOPbouyConqHgeh6ljD3iDtfwouFaVIQnB/HCVWRsNIQ== Received: by filterdrecv-8684c58db7-5vsrj with SMTP id filterdrecv-8684c58db7-5vsrj-1-64B853B6-1B 2023-07-19 21:20:55.176550357 +0000 UTC m=+6039761.995477296 Received: from bionic.localdomain (unknown) by geopod-ismtpd-1 (SG) with ESMTP id ol2UrpvPRjKSXxo9JGb_8g Wed, 19 Jul 2023 21:20:54.733 +0000 (UTC) From: Jonas Karlman Subject: [PATCH 1/5] adc: Use regulator_set_enable_if_allowed Date: Wed, 19 Jul 2023 21:20:55 +0000 (UTC) Message-ID: <20230719212049.709358-2-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+RrMu3cja6a0h+chQYgtLsks3uxrx?= =?us-ascii?Q?06+A0ex2BFu+mOnONdYCTwZXDUVt9xWoQbcHZPc?= =?us-ascii?Q?4tAY7rrtn=2FTlqNfn8rc9LG+GszyRZuBhWixZaM6?= =?us-ascii?Q?ngbbRXap=2F0cM6tkkHu0UPVbNptF3za8BFdPsVsG?= =?us-ascii?Q?c8yfeJ4G=2FGZ4qQgWyhMkvIg=2FVJrZ9odUzZ7TNs?= 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/adc/adc-uclass.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/adc/adc-uclass.c b/drivers/adc/adc-uclass.c index 9646e4d70627..6074eccbf097 100644 --- a/drivers/adc/adc-uclass.c +++ b/drivers/adc/adc-uclass.c @@ -51,23 +51,21 @@ static int check_channel(struct udevice *dev, int value, bool number_or_mask, static int adc_supply_enable(struct udevice *dev) { struct adc_uclass_plat *uc_pdata = dev_get_uclass_plat(dev); - const char *supply_type; - int ret = 0; + int ret; - if (uc_pdata->vdd_supply) { - supply_type = "vdd"; - ret = regulator_set_enable(uc_pdata->vdd_supply, true); + ret = regulator_set_enable_if_allowed(uc_pdata->vdd_supply, true); + if (ret && ret != -ENOSYS) { + pr_err("%s: can't enable vdd-supply!", dev->name); + return ret; } - if (!ret && uc_pdata->vss_supply) { - supply_type = "vss"; - ret = regulator_set_enable(uc_pdata->vss_supply, true); + ret = regulator_set_enable_if_allowed(uc_pdata->vss_supply, true); + if (ret && ret != -ENOSYS) { + pr_err("%s: can't enable vss-supply!", dev->name); + return ret; } - if (ret) - pr_err("%s: can't enable %s-supply!", dev->name, supply_type); - - return ret; + return 0; } int adc_data_mask(struct udevice *dev, unsigned int *data_mask) -- 2.41.0