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 CB203C38145 for ; Thu, 8 Sep 2022 11:38:50 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7DCBD844C2; Thu, 8 Sep 2022 13:38:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.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=metanate.com header.i=@metanate.com header.b="2DlBrRu8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E7BD284AF4; Thu, 8 Sep 2022 13:38:46 +0200 (CEST) Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) (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 B5D9683FF9 for ; Thu, 8 Sep 2022 13:38:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=john@metanate.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Content-Type:Reply-To:Content-ID:Content-Description: In-Reply-To:References; bh=YShn4LNzavQpL0kfPx5tGhc8kNiAS04vSwKy5Oum+i8=; b=2D lBrRu8Yh3hMwvOTCMw283Zlzd+XPqrv9ceLNxfnSdIjMItjUpwb5K/BA6XoCxNV18Qd/mBknF43RL D/7BSoqimJfHy6GiX7jARYfN7e74V+gljwNC5lTD9M711Nz6jmkYa3pAyp5URWfmKU9HQzKs4ZFtJ AeBNLm1EvxCEXxVMXmfwV9xAuariekm7L6fVAuBGtxDO9GIvzt/HB+g4Q9oAXTj3ePWr5z3LiSpdb kZnrtzug3F/ml7gHwdFiv55Ya00f2lCosVxaHTvnbWc8xt5m8vLclROn9MzYJ7ykflJ87hqtFUwu6 0jN+2ZW8+6R3q1uHhl65yovHqOLzVtpA==; Received: from [81.174.171.191] (helo=donbot.metanate.com) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oWFrk-0003HF-Pf; Thu, 08 Sep 2022 12:38:40 +0100 From: John Keeping To: u-boot@lists.denx.de Cc: John Keeping , Jaehoon Chung , Joseph Chen , Kever Yang , Elaine Zhang Subject: [PATCH] power: regulator: fix autoset error handling Date: Thu, 8 Sep 2022 12:38:35 +0100 Message-Id: <20220908113835.2162230-1-john@metanate.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated: YES 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.6 at phobos.denx.de X-Virus-Status: Clean If a regulator does not support .set_suspend_enable or .set_suspend_value then ret is set to ENOSYS early in the function. The most serious impact of this is that when no automatic setting of voltage is needed then the final regulator_set_enable() is skipped because ret has not been cleared. It seems that the error handling for regulator_set_suspend_value() is also wrong as if this succeeds then the normal boot-on checks are still required, and again ENOSYS needs special treatment here. Fixes: 11406b8f7e ("dm: regulator: support regulator more state") Signed-off-by: John Keeping --- drivers/power/regulator/regulator-uclass.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index aca00e56bb..d608f7c236 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -288,9 +288,15 @@ int regulator_autoset(struct udevice *dev) uc_pdata = dev_get_uclass_plat(dev); ret = regulator_set_suspend_enable(dev, uc_pdata->suspend_on); + if (ret == -ENOSYS) + ret = 0; + if (!ret && uc_pdata->suspend_on) { ret = regulator_set_suspend_value(dev, uc_pdata->suspend_uV); - if (!ret) + if (ret == -ENOSYS) + ret = 0; + + if (ret) return ret; } -- 2.37.3