* [PATCH] power_supply: Add min/max alert properties for CAPACITY, TEMP, TEMP_AMBIENT
@ 2012-07-05 11:29 Ramakrishna Pallala
2012-07-14 3:44 ` Anton Vorontsov
0 siblings, 1 reply; 2+ messages in thread
From: Ramakrishna Pallala @ 2012-07-05 11:29 UTC (permalink / raw)
To: linux-kernel; +Cc: Anton Vorontsov, Anton Vorontsov, Ramakrishna Pallala
Minimum and maximum alerts on power supply properties will help or allow the
user space to "proactively" create policies like connect/disconnect charger
or stop/start the user apps based on capacity or temperature parameters.
These parameters can be used to avoid unnecessary polling from user space and
even from kernel space if the underlying HW can support INT triggers(ex: max17042/47).
This patch adds the following power supply alert type properties:
CAPACITY_ALERT_MIN
CAPACITY_ALERT_MAX
TEMP_ALERT_MIN
TEMP_ALERT_MAX
TEMP_AMBIENT_ALERT_MIN
TEMP_AMBIENT_ALERT_MAX
Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
---
Documentation/power/power_supply_class.txt | 6 ++++++
drivers/power/power_supply_sysfs.c | 6 ++++++
include/linux/power_supply.h | 6 ++++++
3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Documentation/power/power_supply_class.txt b/Documentation/power/power_supply_class.txt
index c0f62ae..2f0ddc1 100644
--- a/Documentation/power/power_supply_class.txt
+++ b/Documentation/power/power_supply_class.txt
@@ -119,11 +119,17 @@ CONSTANT_CHARGE_VOLTAGE - constant charge voltage programmed by charger.
ENERGY_FULL, ENERGY_EMPTY - same as above but for energy.
CAPACITY - capacity in percents.
+CAPACITY_ALERT_MIN - minimum capacity alert value in percents.
+CAPACITY_ALERT_MAX - maximum capacity alert value in percents.
CAPACITY_LEVEL - capacity level. This corresponds to
POWER_SUPPLY_CAPACITY_LEVEL_*.
TEMP - temperature of the power supply.
+TEMP_ALERT_MIN - minimum battery temperature alert value in milli centigrade.
+TEMP_ALERT_MAX - maximum battery temperature alert value in milli centigrade.
TEMP_AMBIENT - ambient temperature.
+TEMP_AMBIENT_ALERT_MIN - minimum ambient temperature alert value in milli centigrade.
+TEMP_AMBIENT_ALERT_MAX - maximum ambient temperature alert value in milli centigrade.
TIME_TO_EMPTY - seconds left for battery to be considered empty (i.e.
while battery powers a load)
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index 58846d9..1d96614 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -168,9 +168,15 @@ static struct device_attribute power_supply_attrs[] = {
POWER_SUPPLY_ATTR(energy_now),
POWER_SUPPLY_ATTR(energy_avg),
POWER_SUPPLY_ATTR(capacity),
+ POWER_SUPPLY_ATTR(capacity_alert_min),
+ POWER_SUPPLY_ATTR(capacity_alert_max),
POWER_SUPPLY_ATTR(capacity_level),
POWER_SUPPLY_ATTR(temp),
+ POWER_SUPPLY_ATTR(temp_alert_min),
+ POWER_SUPPLY_ATTR(temp_alert_max),
POWER_SUPPLY_ATTR(temp_ambient),
+ POWER_SUPPLY_ATTR(temp_ambient_alert_min),
+ POWER_SUPPLY_ATTR(temp_ambient_alert_max),
POWER_SUPPLY_ATTR(time_to_empty_now),
POWER_SUPPLY_ATTR(time_to_empty_avg),
POWER_SUPPLY_ATTR(time_to_full_now),
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 53f177d..0bafbb1 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -118,9 +118,15 @@ enum power_supply_property {
POWER_SUPPLY_PROP_ENERGY_NOW,
POWER_SUPPLY_PROP_ENERGY_AVG,
POWER_SUPPLY_PROP_CAPACITY, /* in percents! */
+ POWER_SUPPLY_PROP_CAPACITY_ALERT_MIN, /* in percents! */
+ POWER_SUPPLY_PROP_CAPACITY_ALERT_MAX, /* in percents! */
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
POWER_SUPPLY_PROP_TEMP,
+ POWER_SUPPLY_PROP_TEMP_ALERT_MIN,
+ POWER_SUPPLY_PROP_TEMP_ALERT_MAX,
POWER_SUPPLY_PROP_TEMP_AMBIENT,
+ POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MIN,
+ POWER_SUPPLY_PROP_TEMP_AMBIENT_ALERT_MAX,
POWER_SUPPLY_PROP_TIME_TO_EMPTY_NOW,
POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
POWER_SUPPLY_PROP_TIME_TO_FULL_NOW,
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] power_supply: Add min/max alert properties for CAPACITY, TEMP, TEMP_AMBIENT
2012-07-05 11:29 [PATCH] power_supply: Add min/max alert properties for CAPACITY, TEMP, TEMP_AMBIENT Ramakrishna Pallala
@ 2012-07-14 3:44 ` Anton Vorontsov
0 siblings, 0 replies; 2+ messages in thread
From: Anton Vorontsov @ 2012-07-14 3:44 UTC (permalink / raw)
To: Ramakrishna Pallala; +Cc: linux-kernel
On Thu, Jul 05, 2012 at 04:59:12PM +0530, Ramakrishna Pallala wrote:
> Minimum and maximum alerts on power supply properties will help or allow the
> user space to "proactively" create policies like connect/disconnect charger
> or stop/start the user apps based on capacity or temperature parameters.
>
> These parameters can be used to avoid unnecessary polling from user space and
> even from kernel space if the underlying HW can support INT triggers(ex: max17042/47).
>
> This patch adds the following power supply alert type properties:
> CAPACITY_ALERT_MIN
> CAPACITY_ALERT_MAX
> TEMP_ALERT_MIN
> TEMP_ALERT_MAX
> TEMP_AMBIENT_ALERT_MIN
> TEMP_AMBIENT_ALERT_MAX
>
> Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Looks nice, applied. Thank you!
--
Anton Vorontsov
Email: cbouatmailru@gmail.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-07-14 3:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-05 11:29 [PATCH] power_supply: Add min/max alert properties for CAPACITY, TEMP, TEMP_AMBIENT Ramakrishna Pallala
2012-07-14 3:44 ` Anton Vorontsov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox