From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75D5313DB83; Tue, 27 Feb 2024 13:44:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709041486; cv=none; b=pLZU0NioISUgSZjKddruJlh9DVe+Ed3tONfII/aUTTOVGgvrDo2P5zOLN2qN/JqWDQosNr0MA8mT3mmoDPy15wTA6W956QJyUCWb5g/GSYIwP/DzSOTVhldhduX0dz4SgWiFRVYdcH+wPtjY201nZlK8TMoAzxlifWD6mFiUs/E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709041486; c=relaxed/simple; bh=4phwkBpR83qooV40CHScZeIIZdbf38UvW2PTja4QyJk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FMSLcaW1Mh8I9s97ot2GfG8+TDYLKUbLPZFLGRb93OemXEyPdjhzAw7td7AK4oAVKvYPzHA5wwdtnHP6QEvv2pSkP5leh1Q2WY/+DNhHyhhsZm3m55Mht8wMlZyQ1zbzNTjCwtJTxoUnqhdIsbT4NZUSwkzWkFG2Sf/BolERbXc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=aqJ+Wvl1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="aqJ+Wvl1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 143F4C433F1; Tue, 27 Feb 2024 13:44:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709041485; bh=4phwkBpR83qooV40CHScZeIIZdbf38UvW2PTja4QyJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aqJ+Wvl1qxOzfnB6DdfG5wYSeEkrdw893EhZpQX5QzRi5P4qWmKZClc5ADz4HhZzk auvk1tlkWWg9BjsCyXekXy09s6Y6earDxK37xvsJl4+vXkGa+3y0kXpSLmpqC5Jalo as62ThqlQL02ypjk8vo5DF9rYlgXnXxBf5XalEbg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Martin Blumenstingl , Mark Brown , Sasha Levin Subject: [PATCH 4.19 21/52] regulator: pwm-regulator: Add validity checks in continuous .get_voltage Date: Tue, 27 Feb 2024 14:26:08 +0100 Message-ID: <20240227131549.228177178@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227131548.514622258@linuxfoundation.org> References: <20240227131548.514622258@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Martin Blumenstingl [ Upstream commit c92688cac239794e4a1d976afa5203a4d3a2ac0e ] Continuous regulators can be configured to operate only in a certain duty cycle range (for example from 0..91%). Add a check to error out if the duty cycle translates to an unsupported (or out of range) voltage. Suggested-by: Uwe Kleine-König Signed-off-by: Martin Blumenstingl Link: https://msgid.link/r/20240113224628.377993-2-martin.blumenstingl@googlemail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/regulator/pwm-regulator.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index 34f3b9778ffa1..215581dfd3330 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c @@ -164,6 +164,9 @@ static int pwm_regulator_get_voltage(struct regulator_dev *rdev) pwm_get_state(drvdata->pwm, &pstate); voltage = pwm_get_relative_duty_cycle(&pstate, duty_unit); + if (voltage < min(max_uV_duty, min_uV_duty) || + voltage > max(max_uV_duty, min_uV_duty)) + return -ENOTRECOVERABLE; /* * The dutycycle for min_uV might be greater than the one for max_uV. -- 2.43.0