diff options
Diffstat (limited to 'drivers/hid/hid-lg3ff.c')
| -rw-r--r-- | drivers/hid/hid-lg3ff.c | 29 |
1 files changed, 6 insertions, 23 deletions
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++) |
