Skip to content

Commit

Permalink
HID: hid-input/battery: set scope and powered device for HID battery
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeremy Fitzhardinge authored and Jiri Kosina committed Feb 3, 2012
1 parent 7c7ed8e commit 45d9c27
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/hid/hid-input.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 45d9c27

Please sign in to comment.