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 E37B0C6FD18 for ; Wed, 19 Apr 2023 13:46:04 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 054B486287; Wed, 19 Apr 2023 15:45:45 +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="LIUiQ8aH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 811388627F; Wed, 19 Apr 2023 15:45:37 +0200 (CEST) Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) (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 0A04086270 for ; Wed, 19 Apr 2023 15:45:34 +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 2F0C26603259; Wed, 19 Apr 2023 14:45:33 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1681911933; bh=wAY3hcSt2lroMxouBiUA/etT2m5Sh1LAdxfmSBSQ2+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LIUiQ8aHi0Uk6pKKTMxESZy9egI78JulJMJNMrEyBClwXY7g4cKYpEU+LcN68q6LK WpNkU/JfE3fLqkIPDqdPxW/LcpMaLkUp3VeGJwKa2BYhl6e/QLuMZ+1OVZ2BmyMlFA NwpVi1cnQQpZ0GYg+tI4NSJnLxQpurpjoPXqK3GLL8Qg3604Y2S70+BJCxzTl9Vl75 TlHtWdPTbVz3HLa6O7E0rA+/pZjXKhcixasFTeR57Tzjz2zM+vIF2HcOzQ6val4aiF Rl6jBTcP2U2DPpvJkYNopGgr0ejvWcBQm4T3EpceWv8n78VgJjmfO/LdtQRwQmtOqr 3RYneFs/JGHKg== From: Eugen Hristev To: jonas@kwiboo.se, u-boot@lists.denx.de, jh80.chung@samsung.com Cc: jagan@edgeble.ai, sjg@chromium.org, Eugen Hristev Subject: [PATCH v5 3/3] regulator: handle different error codes in regulator_set_enable_if_allowed Date: Wed, 19 Apr 2023 16:45:26 +0300 Message-Id: <20230419134526.128800-3-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419134526.128800-1-eugen.hristev@collabora.com> References: <20230419134526.128800-1-eugen.hristev@collabora.com> 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 The regulator core can return different codes which are not considered a real error for this function. Return success in such cases. Signed-off-by: Eugen Hristev --- Changes in v5: - this is a new patch drivers/power/regulator/regulator-uclass.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index d608f7c23657..3a6ba69f6d5f 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -197,6 +197,12 @@ int regulator_set_enable_if_allowed(struct udevice *dev, bool enable) ret = regulator_set_enable(dev, enable); if (ret == -ENOSYS || ret == -EACCES) return 0; + /* if we want to disable but it's in use by someone else */ + if (!enable && ret == -EBUSY) + return 0; + /* if it's already enabled/disabled */ + if (ret == -EALREADY) + return 0; return ret; } -- 2.34.1