diff mbox

[v3,04/13] HID: hid-input: add usage_index in struct hid_usage.

Message ID 1352306256-12180-5-git-send-email-benjamin.tissoires@gmail.com (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show

Commit Message

Benjamin Tissoires Nov. 7, 2012, 4:37 p.m. UTC
Currently, there is no way to know the index of the current field
in the .input_mapping and .event callbacks  when this field is inside
an array of HID fields.
This patch adds this index to the struct hid_usage so that this
information is available to input_mapping and event callbacks.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
---
 drivers/hid/hid-core.c | 4 ++++
 include/linux/hid.h    | 1 +
 2 files changed, 5 insertions(+)

Comments

Jiri Kosina Nov. 13, 2012, 7:44 a.m. UTC | #1
On Wed, 7 Nov 2012, Benjamin Tissoires wrote:

> Currently, there is no way to know the index of the current field
> in the .input_mapping and .event callbacks  when this field is inside
> an array of HID fields.
> This patch adds this index to the struct hid_usage so that this
> information is available to input_mapping and event callbacks.
> 
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>

Acked-by: Jiri Kosina <jkosina@suse.cz>

> ---
>  drivers/hid/hid-core.c | 4 ++++
>  include/linux/hid.h    | 1 +
>  2 files changed, 5 insertions(+)
> 
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index 9da3007..8f82c4c 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -92,6 +92,7 @@ EXPORT_SYMBOL_GPL(hid_register_report);
>  static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
>  {
>  	struct hid_field *field;
> +	int i;
>  
>  	if (report->maxfield == HID_MAX_FIELDS) {
>  		hid_err(report->device, "too many fields in report\n");
> @@ -110,6 +111,9 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned
>  	field->value = (s32 *)(field->usage + usages);
>  	field->report = report;
>  
> +	for (i = 0; i < usages; i++)
> +		field->usage[i].usage_index = i;
> +
>  	return field;
>  }
>  
> diff --git a/include/linux/hid.h b/include/linux/hid.h
> index a110a3e..6b4f322 100644
> --- a/include/linux/hid.h
> +++ b/include/linux/hid.h
> @@ -380,6 +380,7 @@ struct hid_usage {
>  	unsigned  hid;			/* hid usage code */
>  	unsigned  collection_index;	/* index into collection array */
>  	/* hidinput data */
> +	unsigned  usage_index;		/* index into usage array */
>  	__u16     code;			/* input driver code */
>  	__u8      type;			/* input driver type */
>  	__s8	  hat_min;		/* hat switch fun */
> -- 
> 1.7.11.7
>
Henrik Rydberg Nov. 13, 2012, 3:38 p.m. UTC | #2
Hi Benjamin,

> Currently, there is no way to know the index of the current field
> in the .input_mapping and .event callbacks  when this field is inside
> an array of HID fields.
> This patch adds this index to the struct hid_usage so that this
> information is available to input_mapping and event callbacks.
> 
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
> ---
>  drivers/hid/hid-core.c | 4 ++++
>  include/linux/hid.h    | 1 +
>  2 files changed, 5 insertions(+)
> 
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index 9da3007..8f82c4c 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -92,6 +92,7 @@ EXPORT_SYMBOL_GPL(hid_register_report);
>  static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
>  {
>  	struct hid_field *field;
> +	int i;
>  
>  	if (report->maxfield == HID_MAX_FIELDS) {
>  		hid_err(report->device, "too many fields in report\n");
> @@ -110,6 +111,9 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned
>  	field->value = (s32 *)(field->usage + usages);
>  	field->report = report;
>  
> +	for (i = 0; i < usages; i++)
> +		field->usage[i].usage_index = i;
> +
>  	return field;
>  }
>  
> diff --git a/include/linux/hid.h b/include/linux/hid.h
> index a110a3e..6b4f322 100644
> --- a/include/linux/hid.h
> +++ b/include/linux/hid.h
> @@ -380,6 +380,7 @@ struct hid_usage {
>  	unsigned  hid;			/* hid usage code */
>  	unsigned  collection_index;	/* index into collection array */
>  	/* hidinput data */
> +	unsigned  usage_index;		/* index into usage array */

Is  this really hidinput data? Should it not be one line above?

>  	__u16     code;			/* input driver code */
>  	__u8      type;			/* input driver type */
>  	__s8	  hat_min;		/* hat switch fun */
> -- 
> 1.7.11.7
> 

Thanks,
Henrik
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 9da3007..8f82c4c 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -92,6 +92,7 @@  EXPORT_SYMBOL_GPL(hid_register_report);
 static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values)
 {
 	struct hid_field *field;
+	int i;
 
 	if (report->maxfield == HID_MAX_FIELDS) {
 		hid_err(report->device, "too many fields in report\n");
@@ -110,6 +111,9 @@  static struct hid_field *hid_register_field(struct hid_report *report, unsigned
 	field->value = (s32 *)(field->usage + usages);
 	field->report = report;
 
+	for (i = 0; i < usages; i++)
+		field->usage[i].usage_index = i;
+
 	return field;
 }
 
diff --git a/include/linux/hid.h b/include/linux/hid.h
index a110a3e..6b4f322 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -380,6 +380,7 @@  struct hid_usage {
 	unsigned  hid;			/* hid usage code */
 	unsigned  collection_index;	/* index into collection array */
 	/* hidinput data */
+	unsigned  usage_index;		/* index into usage array */
 	__u16     code;			/* input driver code */
 	__u8      type;			/* input driver type */
 	__s8	  hat_min;		/* hat switch fun */