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 982841991D7; Thu, 6 Jun 2024 14:21:26 +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=1717683686; cv=none; b=QnK2MjULKjHNt4X2D//XoBTgTpP3jHw+OlQ0Zcm5r637v7QbDZAxAkZkTtDrnjSMcaRmCC64/89yXbcN+2C2Eb36rDP0FYKN1tQMs8osg1MwmCt0HZbDc1Q3jRJsRRyxk3piiP7T8jEqgvfLhimnjeIfg7s4fG+RPZeHM5rz5NQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717683686; c=relaxed/simple; bh=vs6p+MyNKxAw0qWIafKPul10lUGyu/WS5yT0kuFPWgY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E4pDUP3ku0seEJdSth3d1nO1STqYKkKRkw7JIYGs+4INzpB3RLszrIY4Lm9vXna8FYY38Ty3QWNUa33zoEMKFCKzZK+VIj2YT8sBLF0ZsQ4QWzLxo32HAj9yHRKh/4zaLP2f7kxPx5Saln2J3I5f3KjcHsuwljI6JNrfOQmaWSg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=O6mVdI8K; 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="O6mVdI8K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77851C2BD10; Thu, 6 Jun 2024 14:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1717683686; bh=vs6p+MyNKxAw0qWIafKPul10lUGyu/WS5yT0kuFPWgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O6mVdI8KAaeGljP+nA9FHmg3fbsMkODOwYYRlVwu07Vw9cPg6Ib5WNCKm/rMvflSF zrhmmfX+JtLWeeZa/qOVZxc2GKU8Ebpx9ruftw3ceR6EaBQd9IN4qFH8Sz3aSEwta9 jZmxO9BockliQt5FpSfalRtQggKlTVMoXJgEyDUI= 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 6.6 566/744] Input: pm8xxx-vibrator - correct VIB_MAX_LEVELS calculation Date: Thu, 6 Jun 2024 16:03:58 +0200 Message-ID: <20240606131750.608028631@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240606131732.440653204@linuxfoundation.org> References: <20240606131732.440653204@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 6.6-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 5c288fe7accf1..79f478d3a9b37 100644 --- a/drivers/input/misc/pm8xxx-vibrator.c +++ b/drivers/input/misc/pm8xxx-vibrator.c @@ -13,7 +13,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 @@ -117,10 +118,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