[PATCH] Generic HID layer - input and event reporting

hid_input_report() was needlessly USB-specific in USB HID. This patch
makes the function independent of HID implementation and fixes all
the current users. Bluetooth patches comply with this prototype.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Jiri Kosina
2006-12-08 18:41:17 +01:00
committed by Greg Kroah-Hartman
parent aa938f7974
commit aa8de2f038
4 changed files with 68 additions and 62 deletions

View File

@@ -940,5 +940,64 @@ int hid_set_field(struct hid_field *field, unsigned offset, __s32 value)
}
EXPORT_SYMBOL_GPL(hid_set_field);
int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt)
{
struct hid_report_enum *report_enum = hid->report_enum + type;
struct hid_report *report;
int n, rsize;
if (!hid)
return -ENODEV;
if (!size) {
dbg("empty report");
return -1;
}
#ifdef DEBUG_DATA
printk(KERN_DEBUG __FILE__ ": report (size %u) (%snumbered)\n", len, report_enum->numbered ? "" : "un");
#endif
n = 0; /* Normally report number is 0 */
if (report_enum->numbered) { /* Device uses numbered reports, data[0] is report number */
n = *data++;
size--;
}
#ifdef DEBUG_DATA
{
int i;
printk(KERN_DEBUG __FILE__ ": report %d (size %u) = ", n, size);
for (i = 0; i < size; i++)
printk(" %02x", data[i]);
printk("\n");
}
#endif
if (!(report = report_enum->report_id_hash[n])) {
dbg("undefined report_id %d received", n);
return -1;
}
rsize = ((report->size - 1) >> 3) + 1;
if (size < rsize) {
dbg("report %d is too short, (%d < %d)", report->id, size, rsize);
return -1;
}
if ((hid->claimed & HID_CLAIMED_HIDDEV) && hid->hiddev_report_event)
hid->hiddev_report_event(hid, report);
for (n = 0; n < report->maxfield; n++)
hid_input_field(hid, report->field[n], data, interrupt);
if (hid->claimed & HID_CLAIMED_INPUT)
hidinput_report_event(hid, report);
return 0;
}
EXPORT_SYMBOL_GPL(hid_input_report);
MODULE_LICENSE(DRIVER_LICENSE);