* [RFC 0/2] power_supply: add new POWER_SUPPLY_PROP_POLL_INTERVAL property
@ 2016-09-22 5:52 Matt Ranostay
2016-09-22 5:52 ` [RFC 1/2] power: power_supply: add new property POWER_SUPPLY_PROP_POLL_INTERVAL Matt Ranostay
2016-09-22 5:52 ` [RFC 2/2] power: bq27xxx_battery: add poll interval property query Matt Ranostay
0 siblings, 2 replies; 4+ messages in thread
From: Matt Ranostay @ 2016-09-22 5:52 UTC (permalink / raw)
To: Len Brown, David Woodhouse, linux-pm, linux-kernel; +Cc: Matt Ranostay
Some drivers should report and allow changes to the device polling interval of
new stats.
Matt Ranostay (2):
power: power_supply: add new property POWER_SUPPLY_PROP_POLL_INTERVAL
power: bq27xxx_battery: add poll interval property query
Documentation/power/power_supply_class.txt | 1 +
drivers/power/bq27xxx_battery.c | 37 ++++++++++++++++++++++++++++++
drivers/power/power_supply_sysfs.c | 1 +
include/linux/power_supply.h | 1 +
4 files changed, 40 insertions(+)
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC 1/2] power: power_supply: add new property POWER_SUPPLY_PROP_POLL_INTERVAL
2016-09-22 5:52 [RFC 0/2] power_supply: add new POWER_SUPPLY_PROP_POLL_INTERVAL property Matt Ranostay
@ 2016-09-22 5:52 ` Matt Ranostay
2016-09-27 23:53 ` Matt Ranostay
2016-09-22 5:52 ` [RFC 2/2] power: bq27xxx_battery: add poll interval property query Matt Ranostay
1 sibling, 1 reply; 4+ messages in thread
From: Matt Ranostay @ 2016-09-22 5:52 UTC (permalink / raw)
To: Len Brown, David Woodhouse, linux-pm, linux-kernel; +Cc: Matt Ranostay
Add new POWER_SUPPLY_PROP_POLL_INTERVAL property to display/set update
interval in milliseconds of the device.
Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
---
Documentation/power/power_supply_class.txt | 1 +
drivers/power/power_supply_sysfs.c | 1 +
include/linux/power_supply.h | 1 +
3 files changed, 3 insertions(+)
diff --git a/Documentation/power/power_supply_class.txt b/Documentation/power/power_supply_class.txt
index 82dacc06e355..c2e97872374a 100644
--- a/Documentation/power/power_supply_class.txt
+++ b/Documentation/power/power_supply_class.txt
@@ -158,6 +158,7 @@ while battery powers a load)
TIME_TO_FULL - seconds left for battery to be considered full (i.e.
while battery is charging)
+POLL_INTERVAL - seconds between battery stats querying
Battery <-> external power supply interaction
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index 80fed98832f9..df66fad322c2 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -198,6 +198,7 @@ static struct device_attribute power_supply_attrs[] = {
POWER_SUPPLY_ATTR(scope),
POWER_SUPPLY_ATTR(charge_term_current),
POWER_SUPPLY_ATTR(calibrate),
+ POWER_SUPPLY_ATTR(poll_interval),
/* Properties of type `const char *' */
POWER_SUPPLY_ATTR(model_name),
POWER_SUPPLY_ATTR(manufacturer),
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 751061790626..5d45ac511a64 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -148,6 +148,7 @@ enum power_supply_property {
POWER_SUPPLY_PROP_SCOPE,
POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
POWER_SUPPLY_PROP_CALIBRATE,
+ POWER_SUPPLY_PROP_POLL_INTERVAL, /* in seconds! */
/* Properties of type `const char *' */
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_MANUFACTURER,
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [RFC 2/2] power: bq27xxx_battery: add poll interval property query
2016-09-22 5:52 [RFC 0/2] power_supply: add new POWER_SUPPLY_PROP_POLL_INTERVAL property Matt Ranostay
2016-09-22 5:52 ` [RFC 1/2] power: power_supply: add new property POWER_SUPPLY_PROP_POLL_INTERVAL Matt Ranostay
@ 2016-09-22 5:52 ` Matt Ranostay
1 sibling, 0 replies; 4+ messages in thread
From: Matt Ranostay @ 2016-09-22 5:52 UTC (permalink / raw)
To: Len Brown, David Woodhouse, linux-pm, linux-kernel; +Cc: Matt Ranostay
Add POWER_SUPPLY_PROP_POLL_INTERVAL property to query and set the
polling interval of the fuel gauge.
Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
---
drivers/power/bq27xxx_battery.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/power/bq27xxx_battery.c b/drivers/power/bq27xxx_battery.c
index 9cdca31ef3b2..ec6419007921 100644
--- a/drivers/power/bq27xxx_battery.c
+++ b/drivers/power/bq27xxx_battery.c
@@ -274,6 +274,7 @@ static enum power_supply_property bq27000_battery_props[] = {
POWER_SUPPLY_PROP_POWER_AVG,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_MANUFACTURER,
+ POWER_SUPPLY_PROP_POLL_INTERVAL,
};
static enum power_supply_property bq27010_battery_props[] = {
@@ -294,6 +295,7 @@ static enum power_supply_property bq27010_battery_props[] = {
POWER_SUPPLY_PROP_CYCLE_COUNT,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_MANUFACTURER,
+ POWER_SUPPLY_PROP_POLL_INTERVAL,
};
static enum power_supply_property bq27500_battery_props[] = {
@@ -312,6 +314,7 @@ static enum power_supply_property bq27500_battery_props[] = {
POWER_SUPPLY_PROP_CYCLE_COUNT,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_MANUFACTURER,
+ POWER_SUPPLY_PROP_POLL_INTERVAL,
};
static enum power_supply_property bq27530_battery_props[] = {
@@ -330,6 +333,7 @@ static enum power_supply_property bq27530_battery_props[] = {
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_CYCLE_COUNT,
POWER_SUPPLY_PROP_MANUFACTURER,
+ POWER_SUPPLY_PROP_POLL_INTERVAL,
};
static enum power_supply_property bq27541_battery_props[] = {
@@ -349,6 +353,7 @@ static enum power_supply_property bq27541_battery_props[] = {
POWER_SUPPLY_PROP_POWER_AVG,
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_MANUFACTURER,
+ POWER_SUPPLY_PROP_POLL_INTERVAL,
};
static enum power_supply_property bq27545_battery_props[] = {
@@ -367,6 +372,7 @@ static enum power_supply_property bq27545_battery_props[] = {
POWER_SUPPLY_PROP_CYCLE_COUNT,
POWER_SUPPLY_PROP_POWER_AVG,
POWER_SUPPLY_PROP_MANUFACTURER,
+ POWER_SUPPLY_PROP_POLL_INTERVAL,
};
static enum power_supply_property bq27421_battery_props[] = {
@@ -382,6 +388,7 @@ static enum power_supply_property bq27421_battery_props[] = {
POWER_SUPPLY_PROP_CHARGE_NOW,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
POWER_SUPPLY_PROP_MANUFACTURER,
+ POWER_SUPPLY_PROP_POLL_INTERVAL,
};
#define BQ27XXX_PROP(_id, _prop) \
@@ -969,6 +976,9 @@ static int bq27xxx_battery_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_MANUFACTURER:
val->strval = BQ27XXX_MANUFACTURER;
break;
+ case POWER_SUPPLY_PROP_POLL_INTERVAL:
+ val->intval = poll_interval;
+ break;
default:
return -EINVAL;
}
@@ -976,6 +986,31 @@ static int bq27xxx_battery_get_property(struct power_supply *psy,
return ret;
}
+static int bq27xxx_battery_set_property(struct power_supply *psy,
+ enum power_supply_property psp,
+ const union power_supply_propval *val)
+{
+ struct bq27xxx_device_info *di = power_supply_get_drvdata(psy);
+
+ if (psp != POWER_SUPPLY_PROP_POLL_INTERVAL)
+ return -EINVAL;
+
+ poll_interval = val->intval;
+ cancel_delayed_work_sync(&di->work);
+ schedule_delayed_work(&di->work, 0);
+
+ return 0;
+}
+
+static int bq27xxx_property_is_writeable(struct power_supply *psy,
+ enum power_supply_property psp)
+{
+ if (psp == POWER_SUPPLY_PROP_POLL_INTERVAL)
+ return 1;
+
+ return 0;
+}
+
static void bq27xxx_external_power_changed(struct power_supply *psy)
{
struct bq27xxx_device_info *di = power_supply_get_drvdata(psy);
@@ -1002,6 +1037,8 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
psy_desc->properties = bq27xxx_battery_props[di->chip].props;
psy_desc->num_properties = bq27xxx_battery_props[di->chip].size;
psy_desc->get_property = bq27xxx_battery_get_property;
+ psy_desc->set_property = bq27xxx_battery_set_property;
+ psy_desc->property_is_writeable = bq27xxx_property_is_writeable;
psy_desc->external_power_changed = bq27xxx_external_power_changed;
di->bat = power_supply_register_no_ws(di->dev, psy_desc, &psy_cfg);
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC 1/2] power: power_supply: add new property POWER_SUPPLY_PROP_POLL_INTERVAL
2016-09-22 5:52 ` [RFC 1/2] power: power_supply: add new property POWER_SUPPLY_PROP_POLL_INTERVAL Matt Ranostay
@ 2016-09-27 23:53 ` Matt Ranostay
0 siblings, 0 replies; 4+ messages in thread
From: Matt Ranostay @ 2016-09-27 23:53 UTC (permalink / raw)
To: Matt Ranostay; +Cc: linux-pm, linux-kernel
On Wed, Sep 21, 2016 at 10:52 PM, Matt Ranostay <mranostay@gmail.com> wrote:
> Add new POWER_SUPPLY_PROP_POLL_INTERVAL property to display/set update
> interval in milliseconds of the device.
Should be seconds.
>
> Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
> ---
> Documentation/power/power_supply_class.txt | 1 +
> drivers/power/power_supply_sysfs.c | 1 +
> include/linux/power_supply.h | 1 +
> 3 files changed, 3 insertions(+)
>
> diff --git a/Documentation/power/power_supply_class.txt b/Documentation/power/power_supply_class.txt
> index 82dacc06e355..c2e97872374a 100644
> --- a/Documentation/power/power_supply_class.txt
> +++ b/Documentation/power/power_supply_class.txt
> @@ -158,6 +158,7 @@ while battery powers a load)
> TIME_TO_FULL - seconds left for battery to be considered full (i.e.
> while battery is charging)
>
> +POLL_INTERVAL - seconds between battery stats querying
>
> Battery <-> external power supply interaction
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
> index 80fed98832f9..df66fad322c2 100644
> --- a/drivers/power/power_supply_sysfs.c
> +++ b/drivers/power/power_supply_sysfs.c
> @@ -198,6 +198,7 @@ static struct device_attribute power_supply_attrs[] = {
> POWER_SUPPLY_ATTR(scope),
> POWER_SUPPLY_ATTR(charge_term_current),
> POWER_SUPPLY_ATTR(calibrate),
> + POWER_SUPPLY_ATTR(poll_interval),
> /* Properties of type `const char *' */
> POWER_SUPPLY_ATTR(model_name),
> POWER_SUPPLY_ATTR(manufacturer),
> diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
> index 751061790626..5d45ac511a64 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -148,6 +148,7 @@ enum power_supply_property {
> POWER_SUPPLY_PROP_SCOPE,
> POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT,
> POWER_SUPPLY_PROP_CALIBRATE,
> + POWER_SUPPLY_PROP_POLL_INTERVAL, /* in seconds! */
> /* Properties of type `const char *' */
> POWER_SUPPLY_PROP_MODEL_NAME,
> POWER_SUPPLY_PROP_MANUFACTURER,
> --
> 2.7.4
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-27 23:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-22 5:52 [RFC 0/2] power_supply: add new POWER_SUPPLY_PROP_POLL_INTERVAL property Matt Ranostay
2016-09-22 5:52 ` [RFC 1/2] power: power_supply: add new property POWER_SUPPLY_PROP_POLL_INTERVAL Matt Ranostay
2016-09-27 23:53 ` Matt Ranostay
2016-09-22 5:52 ` [RFC 2/2] power: bq27xxx_battery: add poll interval property query Matt Ranostay
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).