OSDN Git Service

HID: Do not create input devices for feature reports
[android-x86/kernel.git] / drivers / hid / hid-input.c
index e60fdb8..ebcc02a 100644 (file)
@@ -827,6 +827,24 @@ static void hidinput_close(struct input_dev *dev)
        hid_hw_close(hid);
 }
 
+static void report_features(struct hid_device *hid)
+{
+       struct hid_driver *drv = hid->driver;
+       struct hid_report_enum *rep_enum;
+       struct hid_report *rep;
+       int i, j;
+
+       if (!drv->feature_mapping)
+               return;
+
+       rep_enum = &hid->report_enum[HID_FEATURE_REPORT];
+       list_for_each_entry(rep, &rep_enum->report_list, list)
+               for (i = 0; i < rep->maxfield; i++)
+                       for (j = 0; j < rep->field[i]->maxusage; j++)
+                               drv->feature_mapping(hid, rep->field[i],
+                                                    rep->field[i]->usage + j);
+}
+
 /*
  * Register the input device; print a message.
  * Configure the input layer interface
@@ -839,7 +857,6 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
        struct hid_input *hidinput = NULL;
        struct input_dev *input_dev;
        int i, j, k;
-       int max_report_type = HID_OUTPUT_REPORT;
 
        INIT_LIST_HEAD(&hid->inputs);
 
@@ -856,10 +873,13 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
                        return -1;
        }
 
-       if (hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS)
-               max_report_type = HID_INPUT_REPORT;
+       report_features(hid);
+
+       for (k = HID_INPUT_REPORT; k <= HID_OUTPUT_REPORT; k++) {
+               if (k == HID_OUTPUT_REPORT &&
+                       hid->quirks & HID_QUIRK_SKIP_OUTPUT_REPORTS)
+                       continue;
 
-       for (k = HID_INPUT_REPORT; k <= max_report_type; k++)
                list_for_each_entry(report, &hid->report_enum[k].report_list, list) {
 
                        if (!report->maxfield)
@@ -912,6 +932,7 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
                                hidinput = NULL;
                        }
                }
+       }
 
        if (hidinput && input_register_device(hidinput->input))
                goto out_cleanup;