From mboxrd@z Thu Jan 1 00:00:00 1970 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 372C4CF9C71 for ; Wed, 25 Sep 2024 02:53:40 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7202488B49; Wed, 25 Sep 2024 04:53:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1727232787; bh=ns+ea/3HJpzNdldFfu0LKAozT1na/ixD5afT6mspUuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Wtw+P9QY/zcwHd/P4xB98q8+xJKt1nOdski7s+WmiPJvG1LEmSrs5Jc50qSx1Se3V 3ZUCc8flz/5bk53AyUI94VnJ5Uhu9g2AXMqAFd+72mzxqY5RleDlCNYMRleGvrpCsf 7wtP2B3OeplPtrolj5cubnOp1m7ZvyX8lxNfTF0j5uAp6GxoFSTtp/s81XBCO97HuS Zoh8eKdCX+zKXZyxleZ3jxChqO6iAg8MUJGSq7TG9g/44V8tkvlWkYuN4PecBL/T4a pZadwWXhfyGP8sEmGmiFd8lkZbsNzfWdVULHh4pvlNgYdMYAf4vZIRpEhJBoZYtdP7 eZklfn1BC1OdQ== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 007A788AA7; Wed, 25 Sep 2024 04:24:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1727231053; bh=ns+ea/3HJpzNdldFfu0LKAozT1na/ixD5afT6mspUuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YJe+pBwWNePfejieZbpdgcxwvKRyuSCTvr0rDLqfe+ha3f51+rhlqEHwz4KjO4gF6 adYdzGINNtvzmwkbezkuxv8k0qA37tfyypZ7e3LtLLt9gXPZNBm/XeEYJGHSkqU3sj XxZEfiNLcqv7YttRjV55zwGqZOY9SJPMcP3dg2EqsFitXBl9hFjajCNoL/1WiDRfAL Ho0+qUuPV4Jt34ARgpqu09HAX/tMxXzMM+SCUJB0flNYcD45kRRG3XWEvxNETXGM+2 FJG6RuP8QHfzshAQ2qvgnfFe+j/RLFfPHPyP5s54IOtE1aomSbVKYlzUXlUboS6VF3 2B/XEbXGw8ulQ== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Ben Wolsieffer , Caleb Connolly , Chris Morgan , Dragan Simic , Eugen Hristev , Francesco Dolcini , Heinrich Schuchardt , Jaehoon Chung , Jagan Teki , Jonas Karlman , Kever Yang , Matteo Lisi , Mattijs Korpershoek , Max Krummenacher , Neil Armstrong , Patrice Chotard , Patrick Delaunay , Philipp Tomsich , Quentin Schulz , Sam Day , Simon Glass , Sumit Garg , Svyatoslav Ryhel , Thierry Reding , Tom Rini , Volodymyr Babchuk , u-boot-amlogic@groups.io, u-boot-qcom@groups.io, u-boot@dh-electronics.com, uboot-stm32@st-md-mailman.stormreply.com Subject: [PATCH v2 3/5] power: regulator: Exit from regulator_set_suspend_value on poorly described regulators Date: Wed, 25 Sep 2024 04:21:54 +0200 Message-ID: <20240925022314.714285-3-marex@denx.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240925022314.714285-1-marex@denx.de> References: <20240925022314.714285-1-marex@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Wed, 25 Sep 2024 04:53:05 +0200 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 In case the DT regulator node does not contain 'regulator-max-microvolt' property and does not contain 'regulator-state-mem' subnode (like the test.dts regul1_scmi: reg@1 {} regulator node), then regulator_pre_probe() will parse this regulator node and set uc_pdata->suspend_on = true and uc_pdata->suspend_uV = uc_pdata->max_uV, where uc_pdata->max_uV is set to -ENODATA because "regulator-max-microvolt" is missing, and therefore uc_pdata->suspend_uV is also -ENODATA. In case regulator_autoset() is used afterward, it will attempt to call regulator_set_suspend_value() with uV = uc_pdata->suspend_uV = -ENODATA and fail with -EINVAL. Check for this case in regulator_set_suspend_value() and immediately return 0, because there is no way to set meaningful suspend voltage, so do nothing and retain the existing settings of the regulator. Signed-off-by: Marek Vasut --- Cc: Ben Wolsieffer Cc: Caleb Connolly Cc: Chris Morgan Cc: Dragan Simic Cc: Eugen Hristev Cc: Francesco Dolcini Cc: Heinrich Schuchardt Cc: Jaehoon Chung Cc: Jagan Teki Cc: Jonas Karlman Cc: Kever Yang Cc: Matteo Lisi Cc: Mattijs Korpershoek Cc: Max Krummenacher Cc: Neil Armstrong Cc: Patrice Chotard Cc: Patrick Delaunay Cc: Philipp Tomsich Cc: Quentin Schulz Cc: Sam Day Cc: Simon Glass Cc: Sumit Garg Cc: Svyatoslav Ryhel Cc: Thierry Reding Cc: Tom Rini Cc: Volodymyr Babchuk Cc: u-boot-amlogic@groups.io Cc: u-boot-qcom@groups.io Cc: u-boot@dh-electronics.com Cc: u-boot@lists.denx.de Cc: uboot-stm32@st-md-mailman.stormreply.com --- V2: New patch --- drivers/power/regulator/regulator-uclass.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/power/regulator/regulator-uclass.c b/drivers/power/regulator/regulator-uclass.c index 14cf3159203..3c05fdf1966 100644 --- a/drivers/power/regulator/regulator-uclass.c +++ b/drivers/power/regulator/regulator-uclass.c @@ -85,6 +85,10 @@ int regulator_set_suspend_value(struct udevice *dev, int uV) const struct dm_regulator_ops *ops = dev_get_driver_ops(dev); struct dm_regulator_uclass_plat *uc_pdata; + /* Regulator did not set limits, assume already configured. */ + if (uV == -ENODATA) + return 0; + uc_pdata = dev_get_uclass_plat(dev); if (uc_pdata->min_uV != -ENODATA && uV < uc_pdata->min_uV) return -EINVAL; -- 2.45.2