Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd276927 authored by Todd Poynor's avatar Todd Poynor Committed by Amit Pundir
Browse files

power: Add property CHARGE_COUNTER_EXT and 64-bit precision properties



Add POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT that stores accumulated charge
in nAh units as a signed 64-bit value.

Add generic support for signed 64-bit property values.

Change-Id: I2bd34b1e95ffba24e7bfef81f398f22bd2aaf05e
Signed-off-by: default avatarTodd Poynor <toddpoynor@google.com>
parent 78a9fbcd
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -107,6 +107,9 @@ static ssize_t power_supply_show_property(struct device *dev,
	else if (off >= POWER_SUPPLY_PROP_MODEL_NAME)
		return sprintf(buf, "%s\n", value.strval);

	if (off == POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT)
		return sprintf(buf, "%lld\n", value.int64val);
	else
		return sprintf(buf, "%d\n", value.intval);
}

@@ -202,6 +205,8 @@ static struct device_attribute power_supply_attrs[] = {
	POWER_SUPPLY_ATTR(usb_hc),
	POWER_SUPPLY_ATTR(usb_otg),
	POWER_SUPPLY_ATTR(charge_enabled),
	/* Local extensions of type int64_t */
	POWER_SUPPLY_ATTR(charge_counter_ext),
	/* Properties of type `const char *' */
	POWER_SUPPLY_ATTR(model_name),
	POWER_SUPPLY_ATTR(manufacturer),
+4 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <linux/leds.h>
#include <linux/spinlock.h>
#include <linux/notifier.h>
#include <linux/types.h>

/*
 * All voltages, currents, charges, energies, time and temperatures in uV,
@@ -152,6 +153,8 @@ enum power_supply_property {
	POWER_SUPPLY_PROP_USB_HC,
	POWER_SUPPLY_PROP_USB_OTG,
	POWER_SUPPLY_PROP_CHARGE_ENABLED,
	/* Local extensions of type int64_t */
	POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT,
	/* Properties of type `const char *' */
	POWER_SUPPLY_PROP_MODEL_NAME,
	POWER_SUPPLY_PROP_MANUFACTURER,
@@ -179,6 +182,7 @@ enum power_supply_notifier_events {
union power_supply_propval {
	int intval;
	const char *strval;
	int64_t int64val;
};

struct device_node;