Linux Input Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] Input: pm8xxx-vib - fix handling of separate enable register
@ 2020-01-14 18:34 Stephan Gerhold
  2020-01-21  4:44 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Stephan Gerhold @ 2020-01-14 18:34 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, Stephan Gerhold, Damien Riegel

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 <damien.riegel@savoirfairelinux.com>
Fixes: d4c7c5c96c92 ("Input: pm8xxx-vib - handle separate enable register")
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
---
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(-)

diff --git a/drivers/input/misc/pm8xxx-vibrator.c b/drivers/input/misc/pm8xxx-vibrator.c
index ecd762f93732..53ad25eaf1a2 100644
--- a/drivers/input/misc/pm8xxx-vibrator.c
+++ b/drivers/input/misc/pm8xxx-vibrator.c
@@ -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;
 }
-- 
2.24.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] Input: pm8xxx-vib - fix handling of separate enable register
  2020-01-14 18:34 [PATCH v2] Input: pm8xxx-vib - fix handling of separate enable register Stephan Gerhold
@ 2020-01-21  4:44 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2020-01-21  4:44 UTC (permalink / raw)
  To: Stephan Gerhold; +Cc: linux-input, Damien Riegel

On Tue, Jan 14, 2020 at 07:34:42PM +0100, Stephan Gerhold wrote:
> 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 <damien.riegel@savoirfairelinux.com>
> Fixes: d4c7c5c96c92 ("Input: pm8xxx-vib - handle separate enable register")
> Signed-off-by: Stephan Gerhold <stephan@gerhold.net>

Applied, thank you.

> ---
> 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(-)
> 
> diff --git a/drivers/input/misc/pm8xxx-vibrator.c b/drivers/input/misc/pm8xxx-vibrator.c
> index ecd762f93732..53ad25eaf1a2 100644
> --- a/drivers/input/misc/pm8xxx-vibrator.c
> +++ b/drivers/input/misc/pm8xxx-vibrator.c
> @@ -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;
>  }
> -- 
> 2.24.1
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 18:34 [PATCH v2] Input: pm8xxx-vib - fix handling of separate enable register Stephan Gerhold
2020-01-21  4:44 ` Dmitry Torokhov

Linux Input Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-input/0 linux-input/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-input linux-input/ https://lore.kernel.org/linux-input \
		linux-input@vger.kernel.org
	public-inbox-index linux-input

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-input


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git