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 66046384; Thu, 13 Jun 2024 12:41:03 +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=1718282463; cv=none; b=bm7Bx4yl9bwoNXZbxofCGe+HWXGonGuTAQDmJcPumC6yTue4GIQ819+QAPV13wUrZUVFRQwiulLvqFck/jKowLEOgeCowpmD2ti1Ck0ebjZWoPzNBT3E7CNVzbJFbfPYlDBQlDTV4sj4gVJqcEZ4wm6efzMddQ3CSoh/mVQ0D/8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718282463; c=relaxed/simple; bh=29yvsxyuIREbQ7amNDkzwOcFCfC2CMZzptVzxZvA+zU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aKSY2IqGnDBIb+78QT2BWNl5/5Dh0k132BqE6Dkxy8+0bhEak9xFCSwki+hxnVtf7v9qnYLI9K6D2YW4MLSbd+eQBYCP2au1E8bVczF9VvdTp50DcXCI2YYjp9xnkYF2zpM/2CviwRwYnfWtmPY0D13acaaKS0QBqWmNNoiRweg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IBBOD6JC; 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="IBBOD6JC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A55D7C2BBFC; Thu, 13 Jun 2024 12:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718282463; bh=29yvsxyuIREbQ7amNDkzwOcFCfC2CMZzptVzxZvA+zU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IBBOD6JC9FKA72RUJm0NzrUgZXTSaawneHqqbwFUAt5gaIO3u7KJUpDY43n69lTIh +noSK0OYQiS/aPqTKI49zVpvuHfRLTOANYlst0qrQaIecvPoPhcQpwRHhWQTjX679m SjB+saZA8UI41U78X9JA/fMSJNDbw0yLXGKQhGyA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Fenglin Wu , Dmitry Baryshkov , Dmitry Torokhov , Sasha Levin Subject: [PATCH 5.15 255/402] Input: pm8xxx-vibrator - correct VIB_MAX_LEVELS calculation Date: Thu, 13 Jun 2024 13:33:32 +0200 Message-ID: <20240613113312.093150543@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613113302.116811394@linuxfoundation.org> References: <20240613113302.116811394@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fenglin Wu [ Upstream commit 48c0687a322d54ac7e7a685c0b6db78d78f593af ] The output voltage is inclusive hence the max level calculation is off-by-one-step. Correct it. iWhile we are at it also add a define for the step size instead of using the magic value. Fixes: 11205bb63e5c ("Input: add support for pm8xxx based vibrator driver") Signed-off-by: Fenglin Wu Reviewed-by: Dmitry Baryshkov Link: https://lore.kernel.org/r/20240412-pm8xxx-vibrator-new-design-v10-1-0ec0ad133866@quicinc.com Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/misc/pm8xxx-vibrator.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/input/misc/pm8xxx-vibrator.c b/drivers/input/misc/pm8xxx-vibrator.c index 53ad25eaf1a28..8bfe5c7b1244c 100644 --- a/drivers/input/misc/pm8xxx-vibrator.c +++ b/drivers/input/misc/pm8xxx-vibrator.c @@ -14,7 +14,8 @@ #define VIB_MAX_LEVEL_mV (3100) #define VIB_MIN_LEVEL_mV (1200) -#define VIB_MAX_LEVELS (VIB_MAX_LEVEL_mV - VIB_MIN_LEVEL_mV) +#define VIB_PER_STEP_mV (100) +#define VIB_MAX_LEVELS (VIB_MAX_LEVEL_mV - VIB_MIN_LEVEL_mV + VIB_PER_STEP_mV) #define MAX_FF_SPEED 0xff @@ -118,10 +119,10 @@ static void pm8xxx_work_handler(struct work_struct *work) vib->active = true; vib->level = ((VIB_MAX_LEVELS * vib->speed) / MAX_FF_SPEED) + VIB_MIN_LEVEL_mV; - vib->level /= 100; + vib->level /= VIB_PER_STEP_mV; } else { vib->active = false; - vib->level = VIB_MIN_LEVEL_mV / 100; + vib->level = VIB_MIN_LEVEL_mV / VIB_PER_STEP_mV; } pm8xxx_vib_set(vib, vib->active); -- 2.43.0