]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
HID: hid-input/battery: set scope and powered device for HID battery
authorJeremy Fitzhardinge <jeremy@goop.org>
Thu, 8 Dec 2011 01:31:43 +0000 (17:31 -0800)
committerJiri Kosina <jkosina@suse.cz>
Fri, 3 Feb 2012 22:54:58 +0000 (23:54 +0100)
Set the battery's power supply scope to "Device" and point the power
supply to the powered device.

Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-input.c

index 9333d692a786b03df115ebe87d920e748b607dc6..af0200f061c0d95388f86860a348dcf7ec38a0e9 100644 (file)
@@ -279,7 +279,8 @@ static enum power_supply_property hidinput_battery_props[] = {
        POWER_SUPPLY_PROP_ONLINE,
        POWER_SUPPLY_PROP_CAPACITY,
        POWER_SUPPLY_PROP_MODEL_NAME,
-       POWER_SUPPLY_PROP_STATUS
+       POWER_SUPPLY_PROP_STATUS,
+       POWER_SUPPLY_PROP_SCOPE,
 };
 
 #define HID_BATTERY_QUIRK_PERCENT      (1 << 0) /* always reports percent */
@@ -344,6 +345,10 @@ static int hidinput_get_battery_property(struct power_supply *psy,
                val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
                break;
 
+       case POWER_SUPPLY_PROP_SCOPE:
+               val->intval = POWER_SUPPLY_SCOPE_DEVICE;
+               break;
+
        default:
                ret = -EINVAL;
                break;
@@ -403,6 +408,8 @@ static bool hidinput_setup_battery(struct hid_device *dev, unsigned report_type,
                battery->name = NULL;
        }
 
+       power_supply_powers(battery, &dev->dev);
+
 out:
        return true;
 }