diff mbox

input: mt: Initialize slots to unused

Message ID 1282638484-16236-1-git-send-email-rydberg@euromail.se
State Rejected
Delegated to: Leann Ogasawara
Headers show

Commit Message

Henrik Rydberg Aug. 24, 2010, 8:28 a.m. UTC
For MT slots, the ABS_MT_TRACKING_ID determines whether a slot is in use,
but currently leaves initialization up to the drivers. This patch sets the
slot state to unused upon creation.

Suggested for Maverick.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
---
 drivers/input/input.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

Comments

Chase Douglas Aug. 24, 2010, 11:58 a.m. UTC | #1
On Tue, 2010-08-24 at 10:28 +0200, Henrik Rydberg wrote:
> For MT slots, the ABS_MT_TRACKING_ID determines whether a slot is in use,
> but currently leaves initialization up to the drivers. This patch sets the
> slot state to unused upon creation.
> 
> Suggested for Maverick.
> 
> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
> ---
>  drivers/input/input.c |    7 +++++--
>  1 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 085ea38..be58b63 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -1750,8 +1750,9 @@ EXPORT_SYMBOL(input_free_device);
>   * @dev: input device supporting MT events and finger tracking
>   * @num_slots: number of slots used by the device
>   *
> - * This function allocates all necessary memory for MT slot handling
> - * in the input device, and adds ABS_MT_SLOT to the device capabilities.
> + * This function allocates all necessary memory for MT slot handling in the
> + * input device, and adds ABS_MT_SLOT to the device capabilities. All slots
> + * are initially unused with ABS_MT_TRACKING_ID == -1.
>   */
>  int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
>  {
> @@ -1764,6 +1765,8 @@ int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
>  
>  	dev->mtsize = num_slots;
>  	input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0);
> +	while (num_slots--)
> +		dev->mt[num_slots].abs[ABS_MT_TRACKING_ID - ABS_MT_FIRST] = -1;
>  
>  	return 0;
>  }
> -- 
> 1.7.1

This just makes it easier for all the drivers who would have to do this
themselves. Looks good to me.

Acked-by: Chase Douglas <chase.douglas@canonical.com>
Tim Gardner Aug. 24, 2010, 1:19 p.m. UTC | #2
On 08/24/2010 02:28 AM, Henrik Rydberg wrote:
> For MT slots, the ABS_MT_TRACKING_ID determines whether a slot is in use,
> but currently leaves initialization up to the drivers. This patch sets the
> slot state to unused upon creation.
>
> Suggested for Maverick.
>
> Signed-off-by: Henrik Rydberg<rydberg@euromail.se>
> ---
>   drivers/input/input.c |    7 +++++--
>   1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 085ea38..be58b63 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -1750,8 +1750,9 @@ EXPORT_SYMBOL(input_free_device);
>    * @dev: input device supporting MT events and finger tracking
>    * @num_slots: number of slots used by the device
>    *
> - * This function allocates all necessary memory for MT slot handling
> - * in the input device, and adds ABS_MT_SLOT to the device capabilities.
> + * This function allocates all necessary memory for MT slot handling in the
> + * input device, and adds ABS_MT_SLOT to the device capabilities. All slots
> + * are initially unused with ABS_MT_TRACKING_ID == -1.
>    */
>   int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
>   {
> @@ -1764,6 +1765,8 @@ int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
>
>   	dev->mtsize = num_slots;
>   	input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0);
> +	while (num_slots--)
> +		dev->mt[num_slots].abs[ABS_MT_TRACKING_ID - ABS_MT_FIRST] = -1;
>
>   	return 0;
>   }

'ABS_MT_TRACKING_ID - ABS_MT_FIRST' is a really unintuitive way of 
indexing an array. How about a one liner explaining why you're shifting 
the dev->mt[num_slots].abs[] index down by 0x30 ?

rtg
Henrik Rydberg Aug. 24, 2010, 1:49 p.m. UTC | #3
On 08/24/2010 03:19 PM, Tim Gardner wrote:

> On 08/24/2010 02:28 AM, Henrik Rydberg wrote:
>> For MT slots, the ABS_MT_TRACKING_ID determines whether a slot is in use,
>> but currently leaves initialization up to the drivers. This patch sets the
>> slot state to unused upon creation.
>>
>> Suggested for Maverick.
>>
>> Signed-off-by: Henrik Rydberg<rydberg@euromail.se>
>> ---
>>   drivers/input/input.c |    7 +++++--
>>   1 files changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/input/input.c b/drivers/input/input.c
>> index 085ea38..be58b63 100644
>> --- a/drivers/input/input.c
>> +++ b/drivers/input/input.c
>> @@ -1750,8 +1750,9 @@ EXPORT_SYMBOL(input_free_device);
>>    * @dev: input device supporting MT events and finger tracking
>>    * @num_slots: number of slots used by the device
>>    *
>> - * This function allocates all necessary memory for MT slot handling
>> - * in the input device, and adds ABS_MT_SLOT to the device capabilities.
>> + * This function allocates all necessary memory for MT slot handling in the
>> + * input device, and adds ABS_MT_SLOT to the device capabilities. All slots
>> + * are initially unused with ABS_MT_TRACKING_ID == -1.
>>    */
>>   int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
>>   {
>> @@ -1764,6 +1765,8 @@ int input_mt_create_slots(struct input_dev *dev,
>> unsigned int num_slots)
>>
>>       dev->mtsize = num_slots;
>>       input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0);
>> +    while (num_slots--)
>> +        dev->mt[num_slots].abs[ABS_MT_TRACKING_ID - ABS_MT_FIRST] = -1;
>>
>>       return 0;
>>   }
> 
> 'ABS_MT_TRACKING_ID - ABS_MT_FIRST' is a really unintuitive way of indexing an
> array. How about a one liner explaining why you're shifting the
> dev->mt[num_slots].abs[] index down by 0x30 ?


Ah, yes. There were three versions of memory-reducing schemes going upstream
before Dmitry picked the first version and modified it a bit. I guess all
versions were unintuitive one way or the other. ;-)

New patch with comment sent.

Thanks,
Henrik
diff mbox

Patch

diff --git a/drivers/input/input.c b/drivers/input/input.c
index 085ea38..be58b63 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1750,8 +1750,9 @@  EXPORT_SYMBOL(input_free_device);
  * @dev: input device supporting MT events and finger tracking
  * @num_slots: number of slots used by the device
  *
- * This function allocates all necessary memory for MT slot handling
- * in the input device, and adds ABS_MT_SLOT to the device capabilities.
+ * This function allocates all necessary memory for MT slot handling in the
+ * input device, and adds ABS_MT_SLOT to the device capabilities. All slots
+ * are initially unused with ABS_MT_TRACKING_ID == -1.
  */
 int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
 {
@@ -1764,6 +1765,8 @@  int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots)
 
 	dev->mtsize = num_slots;
 	input_set_abs_params(dev, ABS_MT_SLOT, 0, num_slots - 1, 0, 0);
+	while (num_slots--)
+		dev->mt[num_slots].abs[ABS_MT_TRACKING_ID - ABS_MT_FIRST] = -1;
 
 	return 0;
 }