Skip to contentSkip to conversation

Input: pm8xxx-vib - fix handling of separate enable register

PATCH Applied Stephan Gerhold 2 participants 2 messages Jan 14, 2020 – Jan 21, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Input: pm8xxx-vib - fix handling of separate enable register

Setting the vibrator enable_mask is not implemented correctly:

For regmap_update_bits(map, reg, mask, val) we give in either regs->enable_mask or 0 (= no-op) as mask and "val" as value. But "val" actually refers to the vibrator voltage control register, which has nothing to do with the enable_mask.

So we usually end up doing nothing when we really wanted to enable the vibrator.

We want to set or clear the enable_mask (to enable/disable the vibrator). Therefore, change the call to always modify the enable_mask and set the bits only if we want to enable the vibrator.

Cc Damien Riegel <[email protected]>
Fixes d4c7c5c96c92 ("Input: pm8xxx-vib - handle separate enable register")

---
v1: https://patchwork.kernel.org/patch/11286073/
Changes in v2:
- Changed regmap_update_bits(..., regs->enable_mask, on ? regs->enable_mask : 0) to regmap_update_bits(..., regs->enable_mask, on ? ~0 : 0) (suggested by Dmitry Torokhov)

---
 drivers/input/misc/pm8xxx-vibrator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/misc/pm8xxx-vibrator.c +1 -1
index ecd762f93732..53ad25eaf1a2 100644
@@ -90,7 +90,7 @@ static int pm8xxx_vib_set(struct pm8xxx_vib *vib, bool on)
 
 	if (regs->enable_mask)
 		rc = regmap_update_bits(vib->regmap, regs->enable_addr,
-					on ? regs->enable_mask : 0, val);
+					regs->enable_mask, on ? ~0 : 0);
 
 	return rc;
 }
Signature · 1 line
2.24.1
maintainer Applied
#1 lore raw
Quoted 10 lines · Stephan Gerhold

Setting the vibrator enable_mask is not implemented correctly:

For regmap_update_bits(map, reg, mask, val) we give in either regs->enable_mask or 0 (= no-op) as mask and "val" as value. But "val" actually refers to the vibrator voltage control register, which has nothing to do with the enable_mask.

So we usually end up doing nothing when we really wanted to enable the vibrator.

Quoted 7 lines

We want to set or clear the enable_mask (to enable/disable the vibrator). Therefore, change the call to always modify the enable_mask and set the bits only if we want to enable the vibrator.

Cc Damien Riegel <[email protected]>
Fixes d4c7c5c96c92 ("Input: pm8xxx-vib - handle separate enable register")

Applied, thank you.

Quoted 26 lines

---
v1: https://patchwork.kernel.org/patch/11286073/
Changes in v2:
- Changed regmap_update_bits(..., regs->enable_mask, on ? regs->enable_mask : 0) to regmap_update_bits(..., regs->enable_mask, on ? ~0 : 0) (suggested by Dmitry Torokhov)

---
 drivers/input/misc/pm8xxx-vibrator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/misc/pm8xxx-vibrator.c +1 -1
index ecd762f93732..53ad25eaf1a2 100644
@@ -90,7 +90,7 @@ static int pm8xxx_vib_set(struct pm8xxx_vib *vib, bool on)
 
 	if (regs->enable_mask)
 		rc = regmap_update_bits(vib->regmap, regs->enable_addr,
-					on ? regs->enable_mask : 0, val);
+					regs->enable_mask, on ? ~0 : 0);
 
 	return rc;
 }
Signature · 1 line
2.24.1
Signature · 1 line
Dmitry