]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] A cleanup of Paul's 2.5 hiddev update.
authorVojtech Pavlik <vojtech@suse.cz>
Mon, 15 Jul 2002 10:37:47 +0000 (03:37 -0700)
committerVojtech Pavlik <vojtech@suse.cz>
Mon, 15 Jul 2002 10:37:47 +0000 (03:37 -0700)
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.

drivers/usb/input/hid-core.c
drivers/usb/input/hiddev.c
include/linux/hiddev.h

index 6f82975e4838f6395a51a052b6318cde823c6f6e..068417749db63fc22010244ef3778f06044f910a 100644 (file)
@@ -793,22 +793,8 @@ static void hid_process_event(struct hid_device *hid, struct hid_field *field, s
        hid_dump_input(usage, value);
        if (hid->claimed & HID_CLAIMED_INPUT)
                hidinput_hid_event(hid, field, usage, value);
-#ifdef CONFIG_USB_HIDDEV
-       if (hid->claimed & HID_CLAIMED_HIDDEV) {
-               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
+       if (hid->claimed & HID_CLAIMED_HIDDEV)
+               hiddev_hid_event(hid, field, usage, value);
 }
 
 /*
@@ -904,21 +890,6 @@ static int hid_input_report(int type, struct urb *urb)
                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;
 
        if (len < size) {
@@ -926,6 +897,9 @@ static int hid_input_report(int type, struct urb *urb)
                return -1;
        }
 
+       if (hid->claimed & HID_CLAIMED_HIDDEV)
+               hiddev_report_event(hid, report);
+
        for (n = 0; n < report->maxfield; n++)
                hid_input_field(hid, report->field[n], data);
 
index 8ac1b9111145a9e75a864f2b936523f1e1f55319..563285d58541711017321084c759830ca00d95b1 100644 (file)
@@ -154,11 +154,8 @@ hiddev_lookup_usage(struct hid_device *hid, struct hiddev_usage_ref *uref)
        return NULL;
 }
 
-/*
- * 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 hiddev_usage_ref *uref)
+static void hiddev_send_event(struct hid_device *hid,
+                             struct hiddev_usage_ref *uref)
 {
        struct hiddev *hiddev = hid->hiddev;
        struct hiddev_list *list = hiddev->list;
@@ -178,6 +175,44 @@ void hiddev_hid_event(struct hid_device *hid, struct hiddev_usage_ref *uref)
        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
  */
index 05db98ccfdbb5e1d331e8dcce4af35dbdaa85857..0077b58559f533298de1d04b51fff7f0c2abb347 100644 (file)
@@ -202,13 +202,17 @@ struct hiddev_usage_ref {
 #ifdef CONFIG_USB_HIDDEV
 int hiddev_connect(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);
 void __exit hiddev_exit(void);
 #else
 static inline int hiddev_connect(struct hid_device *hid) { return -1; }
 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 void hiddev_exit(void) { }
 #endif