diff options
| -rw-r--r-- | drivers/hid/hid-lg2ff.c | 19 | ||||
| -rw-r--r-- | drivers/hid/hid-lg3ff.c | 29 | ||||
| -rw-r--r-- | drivers/hid/hid-lg4ff.c | 20 | ||||
| -rw-r--r-- | drivers/hid/hid-lgff.c | 17 |
4 files changed, 12 insertions, 73 deletions
diff --git a/drivers/hid/hid-lg2ff.c b/drivers/hid/hid-lg2ff.c index b3cd1507dda2..1a42eaa6ca02 100644 --- a/drivers/hid/hid-lg2ff.c +++ b/drivers/hid/hid-lg2ff.c | |||
| @@ -64,26 +64,13 @@ int lg2ff_init(struct hid_device *hid) | |||
| 64 | struct hid_report *report; | 64 | struct hid_report *report; |
| 65 | struct hid_input *hidinput = list_entry(hid->inputs.next, | 65 | struct hid_input *hidinput = list_entry(hid->inputs.next, |
| 66 | struct hid_input, list); | 66 | struct hid_input, list); |
| 67 | struct list_head *report_list = | ||
| 68 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; | ||
| 69 | struct input_dev *dev = hidinput->input; | 67 | struct input_dev *dev = hidinput->input; |
| 70 | int error; | 68 | int error; |
| 71 | 69 | ||
| 72 | if (list_empty(report_list)) { | 70 | /* Check that the report looks ok */ |
| 73 | hid_err(hid, "no output report found\n"); | 71 | report = hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7); |
| 72 | if (!report) | ||
| 74 | return -ENODEV; | 73 | return -ENODEV; |
| 75 | } | ||
| 76 | |||
| 77 | report = list_entry(report_list->next, struct hid_report, list); | ||
| 78 | |||
| 79 | if (report->maxfield < 1) { | ||
| 80 | hid_err(hid, "output report is empty\n"); | ||
| 81 | return -ENODEV; | ||
| 82 | } | ||
| 83 | if (report->field[0]->report_count < 7) { | ||
| 84 | hid_err(hid, "not enough values in the field\n"); | ||
| 85 | return -ENODEV; | ||
| 86 | } | ||
| 87 | 74 | ||
| 88 | lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL); | 75 | lg2ff = kmalloc(sizeof(struct lg2ff_device), GFP_KERNEL); |
| 89 | if (!lg2ff) | 76 | if (!lg2ff) |
diff --git a/drivers/hid/hid-lg3ff.c b/drivers/hid/hid-lg3ff.c index e52f181f6aa1..8c2da183d3bc 100644 --- a/drivers/hid/hid-lg3ff.c +++ b/drivers/hid/hid-lg3ff.c | |||
| @@ -66,10 +66,11 @@ static int hid_lg3ff_play(struct input_dev *dev, void *data, | |||
| 66 | int x, y; | 66 | int x, y; |
| 67 | 67 | ||
| 68 | /* | 68 | /* |
| 69 | * Maxusage should always be 63 (maximum fields) | 69 | * Available values in the field should always be 63, but we only use up to |
| 70 | * likely a better way to ensure this data is clean | 70 | * 35. Instead, clear the entire area, however big it is. |
| 71 | */ | 71 | */ |
| 72 | memset(report->field[0]->value, 0, sizeof(__s32)*report->field[0]->maxusage); | 72 | memset(report->field[0]->value, 0, |
| 73 | sizeof(__s32) * report->field[0]->report_count); | ||
| 73 | 74 | ||
| 74 | switch (effect->type) { | 75 | switch (effect->type) { |
| 75 | case FF_CONSTANT: | 76 | case FF_CONSTANT: |
| @@ -129,32 +130,14 @@ static const signed short ff3_joystick_ac[] = { | |||
| 129 | int lg3ff_init(struct hid_device *hid) | 130 | int lg3ff_init(struct hid_device *hid) |
| 130 | { | 131 | { |
| 131 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | 132 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
| 132 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; | ||
| 133 | struct input_dev *dev = hidinput->input; | 133 | struct input_dev *dev = hidinput->input; |
| 134 | struct hid_report *report; | ||
| 135 | struct hid_field *field; | ||
| 136 | const signed short *ff_bits = ff3_joystick_ac; | 134 | const signed short *ff_bits = ff3_joystick_ac; |
| 137 | int error; | 135 | int error; |
| 138 | int i; | 136 | int i; |
| 139 | 137 | ||
| 140 | /* Find the report to use */ | ||
| 141 | if (list_empty(report_list)) { | ||
| 142 | hid_err(hid, "No output report found\n"); | ||
| 143 | return -1; | ||
| 144 | } | ||
| 145 | |||
| 146 | /* Check that the report looks ok */ | 138 | /* Check that the report looks ok */ |
| 147 | report = list_entry(report_list->next, struct hid_report, list); | 139 | if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 35)) |
| 148 | if (!report) { | 140 | return -ENODEV; |
| 149 | hid_err(hid, "NULL output report\n"); | ||
| 150 | return -1; | ||
| 151 | } | ||
| 152 | |||
| 153 | field = report->field[0]; | ||
| 154 | if (!field) { | ||
| 155 | hid_err(hid, "NULL field\n"); | ||
| 156 | return -1; | ||
| 157 | } | ||
| 158 | 141 | ||
| 159 | /* Assume single fixed device G940 */ | 142 | /* Assume single fixed device G940 */ |
| 160 | for (i = 0; ff_bits[i] >= 0; i++) | 143 | for (i = 0; ff_bits[i] >= 0; i++) |
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c index 0ddae2a00d59..8782fe1aaa07 100644 --- a/drivers/hid/hid-lg4ff.c +++ b/drivers/hid/hid-lg4ff.c | |||
| @@ -484,34 +484,16 @@ static enum led_brightness lg4ff_led_get_brightness(struct led_classdev *led_cde | |||
| 484 | int lg4ff_init(struct hid_device *hid) | 484 | int lg4ff_init(struct hid_device *hid) |
| 485 | { | 485 | { |
| 486 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | 486 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
| 487 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; | ||
| 488 | struct input_dev *dev = hidinput->input; | 487 | struct input_dev *dev = hidinput->input; |
| 489 | struct hid_report *report; | ||
| 490 | struct hid_field *field; | ||
| 491 | struct lg4ff_device_entry *entry; | 488 | struct lg4ff_device_entry *entry; |
| 492 | struct lg_drv_data *drv_data; | 489 | struct lg_drv_data *drv_data; |
| 493 | struct usb_device_descriptor *udesc; | 490 | struct usb_device_descriptor *udesc; |
| 494 | int error, i, j; | 491 | int error, i, j; |
| 495 | __u16 bcdDevice, rev_maj, rev_min; | 492 | __u16 bcdDevice, rev_maj, rev_min; |
| 496 | 493 | ||
| 497 | /* Find the report to use */ | ||
| 498 | if (list_empty(report_list)) { | ||
| 499 | hid_err(hid, "No output report found\n"); | ||
| 500 | return -1; | ||
| 501 | } | ||
| 502 | |||
| 503 | /* Check that the report looks ok */ | 494 | /* Check that the report looks ok */ |
| 504 | report = list_entry(report_list->next, struct hid_report, list); | 495 | if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7)) |
| 505 | if (!report) { | ||
| 506 | hid_err(hid, "NULL output report\n"); | ||
| 507 | return -1; | 496 | return -1; |
| 508 | } | ||
| 509 | |||
| 510 | field = report->field[0]; | ||
| 511 | if (!field) { | ||
| 512 | hid_err(hid, "NULL field\n"); | ||
| 513 | return -1; | ||
| 514 | } | ||
| 515 | 497 | ||
| 516 | /* Check what wheel has been connected */ | 498 | /* Check what wheel has been connected */ |
| 517 | for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) { | 499 | for (i = 0; i < ARRAY_SIZE(lg4ff_devices); i++) { |
diff --git a/drivers/hid/hid-lgff.c b/drivers/hid/hid-lgff.c index d7ea8c845b40..e1394af0ae7b 100644 --- a/drivers/hid/hid-lgff.c +++ b/drivers/hid/hid-lgff.c | |||
| @@ -128,27 +128,14 @@ static void hid_lgff_set_autocenter(struct input_dev *dev, u16 magnitude) | |||
| 128 | int lgff_init(struct hid_device* hid) | 128 | int lgff_init(struct hid_device* hid) |
| 129 | { | 129 | { |
| 130 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); | 130 | struct hid_input *hidinput = list_entry(hid->inputs.next, struct hid_input, list); |
| 131 | struct list_head *report_list = &hid->report_enum[HID_OUTPUT_REPORT].report_list; | ||
| 132 | struct input_dev *dev = hidinput->input; | 131 | struct input_dev *dev = hidinput->input; |
| 133 | struct hid_report *report; | ||
| 134 | struct hid_field *field; | ||
| 135 | const signed short *ff_bits = ff_joystick; | 132 | const signed short *ff_bits = ff_joystick; |
| 136 | int error; | 133 | int error; |
| 137 | int i; | 134 | int i; |
| 138 | 135 | ||
| 139 | /* Find the report to use */ | ||
| 140 | if (list_empty(report_list)) { | ||
| 141 | hid_err(hid, "No output report found\n"); | ||
| 142 | return -1; | ||
| 143 | } | ||
| 144 | |||
| 145 | /* Check that the report looks ok */ | 136 | /* Check that the report looks ok */ |
| 146 | report = list_entry(report_list->next, struct hid_report, list); | 137 | if (!hid_validate_values(hid, HID_OUTPUT_REPORT, 0, 0, 7)) |
| 147 | field = report->field[0]; | 138 | return -ENODEV; |
| 148 | if (!field) { | ||
| 149 | hid_err(hid, "NULL field\n"); | ||
| 150 | return -1; | ||
| 151 | } | ||
| 152 | 139 | ||
| 153 | for (i = 0; i < ARRAY_SIZE(devices); i++) { | 140 | for (i = 0; i < ARRAY_SIZE(devices); i++) { |
| 154 | if (dev->id.vendor == devices[i].idVendor && | 141 | if (dev->id.vendor == devices[i].idVendor && |
