Commit 2fcd00c2 authored by Vojtech Pavlik's avatar Vojtech Pavlik

[PATCH] A cleanup of Paul's 2.5 hiddev update.

Get rid of #ifdefs in hid-core again. (For you, Greg.)
Move the uref generation code from hid-core to hiddev to make things cleaner.
parent 6fa91667
...@@ -793,22 +793,8 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, s ...@@ -793,22 +793,8 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, s
hid_dump_input(usage, value); hid_dump_input(usage, value);
if (hid->claimed & HID_CLAIMED_INPUT) if (hid->claimed & HID_CLAIMED_INPUT)
hidinput_hid_event(hid, field, usage, value); hidinput_hid_event(hid, field, usage, value);
#ifdef CONFIG_USB_HIDDEV if (hid->claimed & HID_CLAIMED_HIDDEV)
if (hid->claimed & HID_CLAIMED_HIDDEV) { hiddev_hid_event(hid, field, usage, value);
struct hiddev_usage_ref uref;
unsigned type = field->report_type;
uref.report_type =
(type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0));
uref.report_id = field->report->id;
uref.field_index = field->index;
uref.usage_index = (usage - field->usage);
uref.usage_code = usage->hid;
uref.value = value;
hiddev_hid_event(hid, &uref);
}
#endif
} }
/* /*
...@@ -904,21 +890,6 @@ static int hid_input_report(int type, struct urb *urb) ...@@ -904,21 +890,6 @@ static int hid_input_report(int type, struct urb *urb)
return -1; return -1;
} }
#ifdef CONFIG_USB_HIDDEV
/* Notify listeners that a report has been received */
if (hid->claimed & HID_CLAIMED_HIDDEV) {
struct hiddev_usage_ref uref;
memset(&uref, 0, sizeof(uref));
uref.report_type =
(type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0));
uref.report_id = report->id;
uref.field_index = HID_FIELD_INDEX_NONE;
hiddev_hid_event(hid, &uref);
}
#endif
size = ((report->size - 1) >> 3) + 1; size = ((report->size - 1) >> 3) + 1;
if (len < size) { if (len < size) {
...@@ -926,6 +897,9 @@ static int hid_input_report(int type, struct urb *urb) ...@@ -926,6 +897,9 @@ static int hid_input_report(int type, struct urb *urb)
return -1; return -1;
} }
if (hid->claimed & HID_CLAIMED_HIDDEV)
hiddev_report_event(hid, report);
for (n = 0; n < report->maxfield; n++) for (n = 0; n < report->maxfield; n++)
hid_input_field(hid, report->field[n], data); hid_input_field(hid, report->field[n], data);
......
...@@ -154,11 +154,8 @@ hiddev_lookup_usage(struct hid_device *hid, struct hiddev_usage_ref *uref) ...@@ -154,11 +154,8 @@ hiddev_lookup_usage(struct hid_device *hid, struct hiddev_usage_ref *uref)
return NULL; return NULL;
} }
/* static void hiddev_send_event(struct hid_device *hid,
* This is where hid.c calls into hiddev to pass an event that occurred over struct hiddev_usage_ref *uref)
* the interrupt pipe
*/
void hiddev_hid_event(struct hid_device *hid, struct hiddev_usage_ref *uref)
{ {
struct hiddev *hiddev = hid->hiddev; struct hiddev *hiddev = hid->hiddev;
struct hiddev_list *list = hiddev->list; struct hiddev_list *list = hiddev->list;
...@@ -178,6 +175,44 @@ void hiddev_hid_event(struct hid_device *hid, struct hiddev_usage_ref *uref) ...@@ -178,6 +175,44 @@ void hiddev_hid_event(struct hid_device *hid, struct hiddev_usage_ref *uref)
wake_up_interruptible(&hiddev->wait); wake_up_interruptible(&hiddev->wait);
} }
/*
* This is where hid.c calls into hiddev to pass an event that occurred over
* the interrupt pipe
*/
void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
struct hid_usage *usage, __s32 value)
{
unsigned type = field->report_type;
struct hiddev_usage_ref uref;
uref.report_type =
(type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0));
uref.report_id = field->report->id;
uref.field_index = field->index;
uref.usage_index = (usage - field->usage);
uref.usage_code = usage->hid;
uref.value = value;
hiddev_send_event(hid, &uref);
}
void hiddev_report_event(struct hid_device *hid, struct hid_report *report)
{
unsigned type = report->type;
struct hiddev_usage_ref uref;
memset(&uref, 0, sizeof(uref));
uref.report_type =
(type == HID_INPUT_REPORT) ? HID_REPORT_TYPE_INPUT :
((type == HID_OUTPUT_REPORT) ? HID_REPORT_TYPE_OUTPUT :
((type == HID_FEATURE_REPORT) ? HID_REPORT_TYPE_FEATURE:0));
uref.report_id = report->id;
hiddev_send_event(hid, &uref);
}
/* /*
* fasync file op * fasync file op
*/ */
......
...@@ -202,13 +202,17 @@ struct hiddev_usage_ref { ...@@ -202,13 +202,17 @@ struct hiddev_usage_ref {
#ifdef CONFIG_USB_HIDDEV #ifdef CONFIG_USB_HIDDEV
int hiddev_connect(struct hid_device *); int hiddev_connect(struct hid_device *);
void hiddev_disconnect(struct hid_device *); void hiddev_disconnect(struct hid_device *);
void hiddev_hid_event(struct hid_device *, struct hiddev_usage_ref *ref); void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
struct hid_usage *usage, __s32 value);
void hiddev_report_event(struct hid_device *hid, struct hid_report *report);
int __init hiddev_init(void); int __init hiddev_init(void);
void __exit hiddev_exit(void); void __exit hiddev_exit(void);
#else #else
static inline int hiddev_connect(struct hid_device *hid) { return -1; } static inline int hiddev_connect(struct hid_device *hid) { return -1; }
static inline void hiddev_disconnect(struct hid_device *hid) { } static inline void hiddev_disconnect(struct hid_device *hid) { }
static inline void hiddev_event(struct hid_device *hid, unsigned int usage, int value) { } static inline void hiddev_hid_event(struct hid_device *hid, struct hid_field *field,
struct hid_usage *usage, __s32 value) { }
static inline void hiddev_report_event(struct hid_device *hid, struct hid_report *report) { }
static inline int hiddev_init(void) { return 0; } static inline int hiddev_init(void) { return 0; }
static inline void hiddev_exit(void) { } static inline void hiddev_exit(void) { }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment