diff options
| -rw-r--r-- | drivers/hid/hid-rmi.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c index 2c3524bacca6..0dc25142f451 100644 --- a/drivers/hid/hid-rmi.c +++ b/drivers/hid/hid-rmi.c | |||
| @@ -848,6 +848,8 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 848 | struct rmi_data *data = NULL; | 848 | struct rmi_data *data = NULL; |
| 849 | int ret; | 849 | int ret; |
| 850 | size_t alloc_size; | 850 | size_t alloc_size; |
| 851 | struct hid_report *input_report; | ||
| 852 | struct hid_report *output_report; | ||
| 851 | 853 | ||
| 852 | data = devm_kzalloc(&hdev->dev, sizeof(struct rmi_data), GFP_KERNEL); | 854 | data = devm_kzalloc(&hdev->dev, sizeof(struct rmi_data), GFP_KERNEL); |
| 853 | if (!data) | 855 | if (!data) |
| @@ -866,12 +868,26 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id) | |||
| 866 | return ret; | 868 | return ret; |
| 867 | } | 869 | } |
| 868 | 870 | ||
| 869 | data->input_report_size = (hdev->report_enum[HID_INPUT_REPORT] | 871 | input_report = hdev->report_enum[HID_INPUT_REPORT] |
| 870 | .report_id_hash[RMI_ATTN_REPORT_ID]->size >> 3) | 872 | .report_id_hash[RMI_ATTN_REPORT_ID]; |
| 871 | + 1 /* report id */; | 873 | if (!input_report) { |
| 872 | data->output_report_size = (hdev->report_enum[HID_OUTPUT_REPORT] | 874 | hid_err(hdev, "device does not have expected input report\n"); |
| 873 | .report_id_hash[RMI_WRITE_REPORT_ID]->size >> 3) | 875 | ret = -ENODEV; |
| 874 | + 1 /* report id */; | 876 | return ret; |
| 877 | } | ||
| 878 | |||
| 879 | data->input_report_size = (input_report->size >> 3) + 1 /* report id */; | ||
| 880 | |||
| 881 | output_report = hdev->report_enum[HID_OUTPUT_REPORT] | ||
| 882 | .report_id_hash[RMI_WRITE_REPORT_ID]; | ||
| 883 | if (!output_report) { | ||
| 884 | hid_err(hdev, "device does not have expected output report\n"); | ||
| 885 | ret = -ENODEV; | ||
| 886 | return ret; | ||
| 887 | } | ||
| 888 | |||
| 889 | data->output_report_size = (output_report->size >> 3) | ||
| 890 | + 1 /* report id */; | ||
| 875 | 891 | ||
| 876 | alloc_size = data->output_report_size + data->input_report_size; | 892 | alloc_size = data->output_report_size + data->input_report_size; |
| 877 | 893 | ||
