| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Force feedback support for Betop based devices |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 19 | 20 | */ |
|---|
| 20 | 21 | |
|---|
| 21 | 22 | /* |
|---|
| 22 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 23 | | - * under the terms of the GNU General Public License as published by the Free |
|---|
| 24 | | - * Software Foundation; either version 2 of the License, or (at your option) |
|---|
| 25 | | - * any later version. |
|---|
| 26 | 23 | */ |
|---|
| 27 | 24 | |
|---|
| 28 | 25 | |
|---|
| .. | .. |
|---|
| 63 | 60 | struct list_head *report_list = |
|---|
| 64 | 61 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
|---|
| 65 | 62 | struct input_dev *dev; |
|---|
| 66 | | - int field_count = 0; |
|---|
| 67 | 63 | int error; |
|---|
| 68 | 64 | int i, j; |
|---|
| 69 | 65 | |
|---|
| .. | .. |
|---|
| 89 | 85 | * ----------------------------------------- |
|---|
| 90 | 86 | * Do init them with default value. |
|---|
| 91 | 87 | */ |
|---|
| 88 | + if (report->maxfield < 4) { |
|---|
| 89 | + hid_err(hid, "not enough fields in the report: %d\n", |
|---|
| 90 | + report->maxfield); |
|---|
| 91 | + return -ENODEV; |
|---|
| 92 | + } |
|---|
| 92 | 93 | for (i = 0; i < report->maxfield; i++) { |
|---|
| 94 | + if (report->field[i]->report_count < 1) { |
|---|
| 95 | + hid_err(hid, "no values in the field\n"); |
|---|
| 96 | + return -ENODEV; |
|---|
| 97 | + } |
|---|
| 93 | 98 | for (j = 0; j < report->field[i]->report_count; j++) { |
|---|
| 94 | 99 | report->field[i]->value[j] = 0x00; |
|---|
| 95 | | - field_count++; |
|---|
| 96 | 100 | } |
|---|
| 97 | | - } |
|---|
| 98 | | - |
|---|
| 99 | | - if (field_count < 4) { |
|---|
| 100 | | - hid_err(hid, "not enough fields in the report: %d\n", |
|---|
| 101 | | - field_count); |
|---|
| 102 | | - return -ENODEV; |
|---|
| 103 | 101 | } |
|---|
| 104 | 102 | |
|---|
| 105 | 103 | betopff = kzalloc(sizeof(*betopff), GFP_KERNEL); |
|---|