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 X-Spam-Level: X-Spam-Status: No, score=-14.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0EA4C433E2 for ; Mon, 14 Sep 2020 13:14:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F543208DB for ; Mon, 14 Sep 2020 13:14:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600089283; bh=AV4Eaj7jrOJ68D6Rsb5R/SK1Yx16OhK4Q+b+JiZaeQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=t3F610CXTggspNfbZHRbdxHSB13+32kNdPMal8ciRVYzPULSkm3AXsB5Rhw02qsD/ 17JdGfEiLEwQUUqXrVZe6bs3dbBec3GQPIzPfFL1ZSnyG5KpvsiW1fYpOP9hUQwgk6 m+HO4TyrCYLtENCHBGuZXba8U1A31/Q0e/9Xiz60= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726725AbgINNOk (ORCPT ); Mon, 14 Sep 2020 09:14:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:60276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbgINNEt (ORCPT ); Mon, 14 Sep 2020 09:04:49 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2F75E21D80; Mon, 14 Sep 2020 13:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600088650; bh=AV4Eaj7jrOJ68D6Rsb5R/SK1Yx16OhK4Q+b+JiZaeQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oMrC+Cxd+ZATKqav0QY/Qfn9qBjPE2YKZ2Pn/0tEyadQzPmUa1635hkGSjO18pdNa dck26uvygEvg6SgB7JwViIXlj5p0ywPonbE8uxsf+wh+aIX1vse2zMzpbSKiQVfW/A xIAEoorrITW902st+1nphwgrt9zVbsf1sMj6TTx4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Vincent Whitchurch , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 5.8 10/29] regulator: pwm: Fix machine constraints application Date: Mon, 14 Sep 2020 09:03:39 -0400 Message-Id: <20200914130358.1804194-10-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200914130358.1804194-1-sashal@kernel.org> References: <20200914130358.1804194-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Whitchurch [ Upstream commit 59ae97a7a9e1499c2070e29841d1c4be4ae2994a ] If the zero duty cycle doesn't correspond to any voltage in the voltage table, the PWM regulator returns an -EINVAL from get_voltage_sel() which results in the core erroring out with a "failed to get the current voltage" and ending up not applying the machine constraints. Instead, return -ENOTRECOVERABLE which makes the core set the voltage since it's at an unknown value. For example, with this device tree: fooregulator { compatible = "pwm-regulator"; pwms = <&foopwm 0 100000>; regulator-min-microvolt = <2250000>; regulator-max-microvolt = <2250000>; regulator-name = "fooregulator"; regulator-always-on; regulator-boot-on; voltage-table = <2250000 30>; }; Before this patch: fooregulator: failed to get the current voltage(-22) After this patch: fooregulator: Setting 2250000-2250000uV fooregulator: 2250 mV Signed-off-by: Vincent Whitchurch Link: https://lore.kernel.org/r/20200902130952.24880-1-vincent.whitchurch@axis.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/pwm-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index 638329bd0745e..62ad7c4e7e7c8 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -279,7 +279,7 @@ static int pwm_regulator_init_table(struct platform_device *pdev, return ret; } - drvdata->state = -EINVAL; + drvdata->state = -ENOTRECOVERABLE; drvdata->duty_cycle_table = duty_cycle_table; drvdata->desc.ops = &pwm_regulator_voltage_table_ops; drvdata->desc.n_voltages = length / sizeof(*duty_cycle_table); -- 2.25.1