summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-input.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-input.c')
-rw-r--r--drivers/hid/hid-input.c36
1 files changed, 23 insertions, 13 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
index dea9cc65bf80..b8eabf206e74 100644
--- a/drivers/hid/hid-input.c
+++ b/drivers/hid/hid-input.c
@@ -350,13 +350,13 @@ static int hidinput_query_battery_capacity(struct hid_device *dev)
u8 *buf;
int ret;
- buf = kmalloc(2, GFP_KERNEL);
+ buf = kmalloc(4, GFP_KERNEL);
if (!buf)
return -ENOMEM;
- ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 2,
+ ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 4,
dev->battery_report_type, HID_REQ_GET_REPORT);
- if (ret != 2) {
+ if (ret < 2) {
kfree(buf);
return -ENODATA;
}
@@ -1560,21 +1560,12 @@ static bool __hidinput_change_resolution_multipliers(struct hid_device *hid,
{
struct hid_usage *usage;
bool update_needed = false;
+ bool get_report_completed = false;
int i, j;
if (report->maxfield == 0)
return false;
- /*
- * If we have more than one feature within this report we
- * need to fill in the bits from the others before we can
- * overwrite the ones for the Resolution Multiplier.
- */
- if (report->maxfield > 1) {
- hid_hw_request(hid, report, HID_REQ_GET_REPORT);
- hid_hw_wait(hid);
- }
-
for (i = 0; i < report->maxfield; i++) {
__s32 value = use_logical_max ?
report->field[i]->logical_maximum :
@@ -1593,6 +1584,25 @@ static bool __hidinput_change_resolution_multipliers(struct hid_device *hid,
if (usage->hid != HID_GD_RESOLUTION_MULTIPLIER)
continue;
+ /*
+ * If we have more than one feature within this
+ * report we need to fill in the bits from the
+ * others before we can overwrite the ones for the
+ * Resolution Multiplier.
+ *
+ * But if we're not allowed to read from the device,
+ * we just bail. Such a device should not exist
+ * anyway.
+ */
+ if (!get_report_completed && report->maxfield > 1) {
+ if (hid->quirks & HID_QUIRK_NO_INIT_REPORTS)
+ return update_needed;
+
+ hid_hw_request(hid, report, HID_REQ_GET_REPORT);
+ hid_hw_wait(hid);
+ get_report_completed = true;
+ }
+
report->field[i]->value[j] = value;
update_needed = true;
}