Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: pm8xxx-vibrator - correct VIB_MAX_LEVELS calculation

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 <quic_fenglinw@quicinc.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20240412-pm8xxx-vibrator-new-design-v10-1-0ec0ad133866@quicinc.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Fenglin Wu and committed by
Dmitry Torokhov
48c0687a ba2ec9c4

+4 -3
+4 -3
drivers/input/misc/pm8xxx-vibrator.c
··· 13 13 14 14 #define VIB_MAX_LEVEL_mV (3100) 15 15 #define VIB_MIN_LEVEL_mV (1200) 16 - #define VIB_MAX_LEVELS (VIB_MAX_LEVEL_mV - VIB_MIN_LEVEL_mV) 16 + #define VIB_PER_STEP_mV (100) 17 + #define VIB_MAX_LEVELS (VIB_MAX_LEVEL_mV - VIB_MIN_LEVEL_mV + VIB_PER_STEP_mV) 17 18 18 19 #define MAX_FF_SPEED 0xff 19 20 ··· 118 117 vib->active = true; 119 118 vib->level = ((VIB_MAX_LEVELS * vib->speed) / MAX_FF_SPEED) + 120 119 VIB_MIN_LEVEL_mV; 121 - vib->level /= 100; 120 + vib->level /= VIB_PER_STEP_mV; 122 121 } else { 123 122 vib->active = false; 124 - vib->level = VIB_MIN_LEVEL_mV / 100; 123 + vib->level = VIB_MIN_LEVEL_mV / VIB_PER_STEP_mV; 125 124 } 126 125 127 126 pm8xxx_vib_set(vib, vib->active);