linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] Input: synaptics-rmi4: Fix register descriptor subpacket map construction
@ 2016-08-22 16:58 Andrew Duggan
  2016-08-22 21:19 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Duggan @ 2016-08-22 16:58 UTC (permalink / raw)
  To: linux-input, linux-kernel
  Cc: Andrew Duggan, Dmitry Torokhov, Jiri Kosina, Benjamin Tissoires,
	Vincent Huang, Chris Healy, Nitin Chaudhary, stable

From: Andrew Duggan <aduggan@synaptics.com>

The map_offset variable is specific to the register and needs to be reset
in the loop. Otherwise, subsequent register's subpacket maps will have
their bits set at the wrong index.

Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
Tested-by: Nitin Chaudhary <nitinchaudhary1289@gmail.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: stable@vger.kernel.org
---
In rmi_f12_read_sensor_tuning() we call rmi_register_desc_has_subpacket()
to check the subpacket map to make sure a subpacket exists to ensure that
the buffer contains the correct data. It happened that on my the test
devices the register we were checking was also the first register. This
issues showed up on newer devices where F12 CTRL 8 is not teh first control
register.

V2 moves map_offset closer to the do/while loop.

Thanks,
Andrew

 drivers/input/rmi4/rmi_driver.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
index 2b6b97e..00f9ad9 100644
--- a/drivers/input/rmi4/rmi_driver.c
+++ b/drivers/input/rmi4/rmi_driver.c
@@ -553,7 +553,6 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr,
 		goto free_struct_buff;
 
 	reg = find_first_bit(rdesc->presense_map, RMI_REG_DESC_PRESENSE_BITS);
-	map_offset = 0;
 	for (i = 0; i < rdesc->num_registers; i++) {
 		struct rmi_register_desc_item *item = &rdesc->registers[i];
 		int reg_size = struct_buf[offset];
@@ -576,6 +575,8 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr,
 		item->reg = reg;
 		item->reg_size = reg_size;
 
+		map_offset = 0;
+
 		do {
 			for (b = 0; b < 7; b++) {
 				if (struct_buf[offset] & (0x1 << b))
-- 
2.7.4

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

* Re: [PATCH v2] Input: synaptics-rmi4: Fix register descriptor subpacket map construction
  2016-08-22 16:58 [PATCH v2] Input: synaptics-rmi4: Fix register descriptor subpacket map construction Andrew Duggan
@ 2016-08-22 21:19 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2016-08-22 21:19 UTC (permalink / raw)
  To: Andrew Duggan
  Cc: linux-input, linux-kernel, Andrew Duggan, Jiri Kosina,
	Benjamin Tissoires, Vincent Huang, Chris Healy, Nitin Chaudhary,
	stable

On Mon, Aug 22, 2016 at 09:58:57AM -0700, Andrew Duggan wrote:
> From: Andrew Duggan <aduggan@synaptics.com>
> 
> The map_offset variable is specific to the register and needs to be reset
> in the loop. Otherwise, subsequent register's subpacket maps will have
> their bits set at the wrong index.
> 
> Signed-off-by: Andrew Duggan <aduggan@synaptics.com>
> Tested-by: Nitin Chaudhary <nitinchaudhary1289@gmail.com>
> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Cc: stable@vger.kernel.org


Applied, thank you.

> ---
> In rmi_f12_read_sensor_tuning() we call rmi_register_desc_has_subpacket()
> to check the subpacket map to make sure a subpacket exists to ensure that
> the buffer contains the correct data. It happened that on my the test
> devices the register we were checking was also the first register. This
> issues showed up on newer devices where F12 CTRL 8 is not teh first control
> register.
> 
> V2 moves map_offset closer to the do/while loop.
> 
> Thanks,
> Andrew
> 
>  drivers/input/rmi4/rmi_driver.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> index 2b6b97e..00f9ad9 100644
> --- a/drivers/input/rmi4/rmi_driver.c
> +++ b/drivers/input/rmi4/rmi_driver.c
> @@ -553,7 +553,6 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr,
>  		goto free_struct_buff;
>  
>  	reg = find_first_bit(rdesc->presense_map, RMI_REG_DESC_PRESENSE_BITS);
> -	map_offset = 0;
>  	for (i = 0; i < rdesc->num_registers; i++) {
>  		struct rmi_register_desc_item *item = &rdesc->registers[i];
>  		int reg_size = struct_buf[offset];
> @@ -576,6 +575,8 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr,
>  		item->reg = reg;
>  		item->reg_size = reg_size;
>  
> +		map_offset = 0;
> +
>  		do {
>  			for (b = 0; b < 7; b++) {
>  				if (struct_buf[offset] & (0x1 << b))
> -- 
> 2.7.4
> 

-- 
Dmitry

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

end of thread, other threads:[~2016-08-22 21:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-22 16:58 [PATCH v2] Input: synaptics-rmi4: Fix register descriptor subpacket map construction Andrew Duggan
2016-08-22 21:19 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).