From patchwork Mon Jun 14 10:27:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 460226 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=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, URIBL_BLOCKED, 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 D09BAC48BE8 for ; Mon, 14 Jun 2021 11:20:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC45E610A2 for ; Mon, 14 Jun 2021 11:20:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235187AbhFNLWF (ORCPT ); Mon, 14 Jun 2021 07:22:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:50444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236010AbhFNLUD (ORCPT ); Mon, 14 Jun 2021 07:20:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A434461468; Mon, 14 Jun 2021 10:51:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623667904; bh=NlyYz677VQ1YSl9go32taC6oUabOYNPti/10awgTDsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=djsHrcJfHdO4iCxbtkwV983pccySERpMpYipwFv2BI4EUX7atPIsKcT4BUZnqlwF+ zRkRjdYMWHn8Q1ooDrK/POUUpmYG4EkJpJT802+4F3K42kZP5jw08dJK7qdBDud99o XcyMummF+88D9cFioZeNMutsd6+lPxeXZ7MKZHNk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Axel Lin , Cristian Marussi , Mark Brown Subject: [PATCH 5.12 119/173] regulator: scmi: Fix off-by-one for linear regulators .n_voltages setting Date: Mon, 14 Jun 2021 12:27:31 +0200 Message-Id: <20210614102702.122535731@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102658.137943264@linuxfoundation.org> References: <20210614102658.137943264@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Axel Lin commit 36cb555fae0875d5416e8514a84a427bec6e4cda upstream. For linear regulators, the .n_voltages is (max_uv - min_uv) / uv_step + 1. Fixes: 0fbeae70ee7c ("regulator: add SCMI driver") Signed-off-by: Axel Lin Reviewed-by: Cristian Marussi Link: https://lore.kernel.org/r/20210521073020.1944981-1-axel.lin@ingics.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/regulator/scmi-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/regulator/scmi-regulator.c +++ b/drivers/regulator/scmi-regulator.c @@ -176,7 +176,7 @@ scmi_config_linear_regulator_mappings(st sreg->desc.uV_step = vinfo->levels_uv[SCMI_VOLTAGE_SEGMENT_STEP]; sreg->desc.linear_min_sel = 0; - sreg->desc.n_voltages = delta_uV / sreg->desc.uV_step; + sreg->desc.n_voltages = (delta_uV / sreg->desc.uV_step) + 1; sreg->desc.ops = &scmi_reg_linear_ops; }