From: Alexey Starikovskiy <astarikovskiy@suse.de>
To: LenBrown <lenb@kernel.org>
Cc: Linux-acpi@vger.kernel.org
Subject: [RFC][PATCH] ACPI: battery: add power_{now, avg} properties to power_class
Date: Tue, 16 Dec 2008 00:38:56 +0300 [thread overview]
Message-ID: <20081215213855.8414.9349.stgit@thinkpad> (raw)
ACPI has smart batteries, which work in units of energy and measure
rate of (dis)charge as power, thus it is not appropriate to export it
as a current_now.
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
---
drivers/acpi/battery.c | 3 ++-
drivers/acpi/sbs.c | 6 ++++--
drivers/power/power_supply_sysfs.c | 2 ++
include/linux/power_supply.h | 2 ++
4 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 1423b0c..88f1fb5 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -173,6 +173,7 @@ static int acpi_battery_get_property(struct power_supply *psy,
val->intval = battery->voltage_now * 1000;
break;
case POWER_SUPPLY_PROP_CURRENT_NOW:
+ case POWER_SUPPLY_PROP_POWER_NOW:
val->intval = battery->current_now * 1000;
break;
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
@@ -223,7 +224,7 @@ static enum power_supply_property energy_battery_props[] = {
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
- POWER_SUPPLY_PROP_CURRENT_NOW,
+ POWER_SUPPLY_PROP_POWER_NOW,
POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
POWER_SUPPLY_PROP_ENERGY_FULL,
POWER_SUPPLY_PROP_ENERGY_NOW,
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 6050ce4..994c04e 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -224,10 +224,12 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,
acpi_battery_vscale(battery) * 1000;
break;
case POWER_SUPPLY_PROP_CURRENT_NOW:
+ case POWER_SUPPLY_PROP_POWER_NOW:
val->intval = abs(battery->current_now) *
acpi_battery_ipscale(battery) * 1000;
break;
case POWER_SUPPLY_PROP_CURRENT_AVG:
+ case POWER_SUPPLY_PROP_POWER_AVG:
val->intval = abs(battery->current_avg) *
acpi_battery_ipscale(battery) * 1000;
break;
@@ -291,8 +293,8 @@ static enum power_supply_property sbs_energy_battery_props[] = {
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
- POWER_SUPPLY_PROP_CURRENT_NOW,
- POWER_SUPPLY_PROP_CURRENT_AVG,
+ POWER_SUPPLY_PROP_POWER_NOW,
+ POWER_SUPPLY_PROP_POWER_AVG,
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
POWER_SUPPLY_PROP_ENERGY_FULL,
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index 23ae846..7aa8b4e 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -93,6 +93,8 @@ static struct device_attribute power_supply_attrs[] = {
POWER_SUPPLY_ATTR(voltage_avg),
POWER_SUPPLY_ATTR(current_now),
POWER_SUPPLY_ATTR(current_avg),
+ POWER_SUPPLY_ATTR(power_now),
+ POWER_SUPPLY_ATTR(power_avg),
POWER_SUPPLY_ATTR(charge_full_design),
POWER_SUPPLY_ATTR(charge_empty_design),
POWER_SUPPLY_ATTR(charge_full),
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index f9348cb..105a707 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -72,6 +72,8 @@ enum power_supply_property {
POWER_SUPPLY_PROP_VOLTAGE_AVG,
POWER_SUPPLY_PROP_CURRENT_NOW,
POWER_SUPPLY_PROP_CURRENT_AVG,
+ POWER_SUPPLY_PROP_POWER_NOW,
+ POWER_SUPPLY_PROP_POWER_AVG,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
POWER_SUPPLY_PROP_CHARGE_EMPTY_DESIGN,
POWER_SUPPLY_PROP_CHARGE_FULL,
next reply other threads:[~2008-12-15 21:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-15 21:38 Alexey Starikovskiy [this message]
2008-12-16 1:22 ` [RFC][PATCH] ACPI: battery: add power_{now, avg} properties to power_class Henrique de Moraes Holschuh
2008-12-16 8:53 ` Alexey Starikovskiy
2008-12-16 14:18 ` Henrique de Moraes Holschuh
2008-12-16 15:19 ` Rafael J. Wysocki
2008-12-16 15:17 ` Rafael J. Wysocki
2008-12-16 15:28 ` Alexey Starikovskiy
2008-12-16 15:51 ` Rafael J. Wysocki
-- strict thread matches above, loose matches on Subject: below --
2008-12-16 16:27 Alexey Starikovskiy
2008-12-16 17:41 ` Len Brown
2008-12-16 20:49 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081215213855.8414.9349.stgit@thinkpad \
--to=astarikovskiy@suse.de \
--cc=Linux-acpi@vger.kernel.org \
--cc=lenb@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox