@@ -435,7 +435,8 @@ static int hidinput_get_battery_property(struct power_supply *psy,
435
435
return ret ;
436
436
}
437
437
438
- static int hidinput_setup_battery (struct hid_device * dev , unsigned report_type , struct hid_field * field )
438
+ static int hidinput_setup_battery (struct hid_device * dev , unsigned report_type ,
439
+ struct hid_field * field , bool is_percentage )
439
440
{
440
441
struct power_supply_desc * psy_desc ;
441
442
struct power_supply_config psy_cfg = { .drv_data = dev , };
@@ -475,7 +476,7 @@ static int hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
475
476
min = field -> logical_minimum ;
476
477
max = field -> logical_maximum ;
477
478
478
- if (quirks & HID_BATTERY_QUIRK_PERCENT ) {
479
+ if (is_percentage || ( quirks & HID_BATTERY_QUIRK_PERCENT ) ) {
479
480
min = 0 ;
480
481
max = 100 ;
481
482
}
@@ -552,7 +553,7 @@ static void hidinput_update_battery(struct hid_device *dev, int value)
552
553
}
553
554
#else /* !CONFIG_HID_BATTERY_STRENGTH */
554
555
static int hidinput_setup_battery (struct hid_device * dev , unsigned report_type ,
555
- struct hid_field * field )
556
+ struct hid_field * field , bool is_percentage )
556
557
{
557
558
return 0 ;
558
559
}
@@ -806,7 +807,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
806
807
break ;
807
808
808
809
case 0x3b : /* Battery Strength */
809
- hidinput_setup_battery (device , HID_INPUT_REPORT , field );
810
+ hidinput_setup_battery (device , HID_INPUT_REPORT , field , false );
810
811
usage -> type = EV_PWR ;
811
812
return ;
812
813
@@ -1068,7 +1069,16 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
1068
1069
case HID_UP_GENDEVCTRLS :
1069
1070
switch (usage -> hid ) {
1070
1071
case HID_DC_BATTERYSTRENGTH :
1071
- hidinput_setup_battery (device , HID_INPUT_REPORT , field );
1072
+ hidinput_setup_battery (device , HID_INPUT_REPORT , field , false);
1073
+ usage -> type = EV_PWR ;
1074
+ return ;
1075
+ }
1076
+ goto unknown ;
1077
+
1078
+ case HID_UP_BATTERY :
1079
+ switch (usage -> hid ) {
1080
+ case HID_BAT_ABSOLUTESTATEOFCHARGE :
1081
+ hidinput_setup_battery (device , HID_INPUT_REPORT , field , true);
1072
1082
usage -> type = EV_PWR ;
1073
1083
return ;
1074
1084
}
@@ -1672,7 +1682,7 @@ static void report_features(struct hid_device *hid)
1672
1682
/* Verify if Battery Strength feature is available */
1673
1683
if (usage -> hid == HID_DC_BATTERYSTRENGTH )
1674
1684
hidinput_setup_battery (hid , HID_FEATURE_REPORT ,
1675
- rep -> field [i ]);
1685
+ rep -> field [i ], false );
1676
1686
1677
1687
if (drv -> feature_mapping )
1678
1688
drv -> feature_mapping (hid , rep -> field [i ], usage );
0 commit comments