diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2011-12-02 14:18:45 -0500 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy@goop.org> | 2012-01-08 02:30:37 -0500 |
commit | fb8ac91b4dccbdda0ad51d499079d05143783ba4 (patch) | |
tree | b85100063cf4128c79b610a0a7def43a40c98413 /drivers/hid/hid-input.c | |
parent | bbc21cfd55858d7c3e55bfaa91fa934b0b13ad4d (diff) |
hid-input/battery: deal with both FEATURE and INPUT report batteries
Some devices seem to report batteries as FEATUREs, others as INPUTs.
Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
Diffstat (limited to 'drivers/hid/hid-input.c')
-rw-r--r-- | drivers/hid/hid-input.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index 69dec476883a..f5c3efcdcb02 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c | |||
@@ -312,7 +312,6 @@ static int hidinput_get_battery_property(struct power_supply *psy, | |||
312 | int ret = 0; | 312 | int ret = 0; |
313 | int ret_rep; | 313 | int ret_rep; |
314 | __u8 buf[2] = {}; | 314 | __u8 buf[2] = {}; |
315 | unsigned char report_number = dev->battery_report_id; | ||
316 | 315 | ||
317 | switch (prop) { | 316 | switch (prop) { |
318 | case POWER_SUPPLY_PROP_PRESENT: | 317 | case POWER_SUPPLY_PROP_PRESENT: |
@@ -321,8 +320,9 @@ static int hidinput_get_battery_property(struct power_supply *psy, | |||
321 | break; | 320 | break; |
322 | 321 | ||
323 | case POWER_SUPPLY_PROP_CAPACITY: | 322 | case POWER_SUPPLY_PROP_CAPACITY: |
324 | ret_rep = dev->hid_get_raw_report(dev, report_number, | 323 | ret_rep = dev->hid_get_raw_report(dev, dev->battery_report_id, |
325 | buf, sizeof(buf), HID_FEATURE_REPORT); | 324 | buf, sizeof(buf), |
325 | dev->battery_report_type); | ||
326 | if (ret_rep != 2) { | 326 | if (ret_rep != 2) { |
327 | ret = -EINVAL; | 327 | ret = -EINVAL; |
328 | break; | 328 | break; |
@@ -351,7 +351,9 @@ static int hidinput_get_battery_property(struct power_supply *psy, | |||
351 | return ret; | 351 | return ret; |
352 | } | 352 | } |
353 | 353 | ||
354 | static void hidinput_setup_battery(struct hid_device *dev, unsigned id, s32 min, s32 max) | 354 | static void hidinput_setup_battery(struct hid_device *dev, |
355 | unsigned report_type, unsigned report_id, | ||
356 | s32 min, s32 max) | ||
355 | { | 357 | { |
356 | struct power_supply *battery = &dev->battery; | 358 | struct power_supply *battery = &dev->battery; |
357 | int ret; | 359 | int ret; |
@@ -379,7 +381,8 @@ static void hidinput_setup_battery(struct hid_device *dev, unsigned id, s32 min, | |||
379 | 381 | ||
380 | dev->battery_min = min; | 382 | dev->battery_min = min; |
381 | dev->battery_max = max; | 383 | dev->battery_max = max; |
382 | dev->battery_report_id = id; | 384 | dev->battery_report_type = report_type; |
385 | dev->battery_report_id = report_id; | ||
383 | 386 | ||
384 | ret = power_supply_register(&dev->dev, battery); | 387 | ret = power_supply_register(&dev->dev, battery); |
385 | if (ret != 0) { | 388 | if (ret != 0) { |
@@ -399,7 +402,9 @@ static void hidinput_cleanup_battery(struct hid_device *dev) | |||
399 | dev->battery.name = NULL; | 402 | dev->battery.name = NULL; |
400 | } | 403 | } |
401 | #else /* !CONFIG_HID_BATTERY_STRENGTH */ | 404 | #else /* !CONFIG_HID_BATTERY_STRENGTH */ |
402 | static void hidinput_setup_battery(struct hid_device *dev, unsigned id, s32 min, s32 max) | 405 | static void hidinput_setup_battery(struct hid_device *dev, |
406 | unsigned report_type, unsigned report_id, | ||
407 | s32 min, s32 max) | ||
403 | { | 408 | { |
404 | } | 409 | } |
405 | 410 | ||
@@ -769,6 +774,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel | |||
769 | case HID_UP_GENDEVCTRLS: | 774 | case HID_UP_GENDEVCTRLS: |
770 | if ((usage->hid & HID_USAGE) == 0x20) { /* Battery Strength */ | 775 | if ((usage->hid & HID_USAGE) == 0x20) { /* Battery Strength */ |
771 | hidinput_setup_battery(device, | 776 | hidinput_setup_battery(device, |
777 | HID_INPUT_REPORT, | ||
772 | field->report->id, | 778 | field->report->id, |
773 | field->logical_minimum, | 779 | field->logical_minimum, |
774 | field->logical_maximum); | 780 | field->logical_maximum); |
@@ -1052,7 +1058,7 @@ static void report_features(struct hid_device *hid) | |||
1052 | if (((rep->field[i]->usage + j)->hid & HID_USAGE_PAGE) == HID_UP_GENDEVCTRLS && | 1058 | if (((rep->field[i]->usage + j)->hid & HID_USAGE_PAGE) == HID_UP_GENDEVCTRLS && |
1053 | ((rep->field[i]->usage + j)->hid & HID_USAGE) == 0x20) { | 1059 | ((rep->field[i]->usage + j)->hid & HID_USAGE) == 0x20) { |
1054 | hidinput_setup_battery(hid, | 1060 | hidinput_setup_battery(hid, |
1055 | rep->id, | 1061 | HID_FEATURE_REPORT, rep->id, |
1056 | rep->field[i]->logical_minimum, | 1062 | rep->field[i]->logical_minimum, |
1057 | rep->field[i]->logical_maximum); | 1063 | rep->field[i]->logical_maximum); |
1058 | } | 1064 | } |