* [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class
@ 2009-01-13 23:57 Alexey Starikovskiy
2009-01-13 23:57 ` [PATCH 2/3] ACPI: EC: Limit workaround for ASUS notebooks even more Alexey Starikovskiy
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Alexey Starikovskiy @ 2009-01-13 23:57 UTC (permalink / raw)
To: Len Brown; +Cc: Linux-acpi
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. Current_now will be exported until 2.6.29 to allow
for userland applications to match.
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
---
Documentation/feature-removal-schedule.txt | 8 +++++++
drivers/acpi/battery.c | 14 +++++++------
drivers/acpi/sbs.c | 31 ++++++++++++++++------------
drivers/power/power_supply_sysfs.c | 2 ++
include/linux/power_supply.h | 2 ++
5 files changed, 38 insertions(+), 19 deletions(-)
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 5ddbe35..79fe354 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -3,6 +3,14 @@ removed in the kernel source tree. Every entry should contain what
exactly is going away, why it is happening, and who is going to be doing
the work. When the feature is removed from the kernel, it should also
be removed from this file.
+---------------------------
+
+What: current_{now,avg} attributes for batteries, reporting in energy units
+When: 2.6.29
+Why: Batteries, reporting in energy units, will report (dis)charge rate as
+ power (Watts), and not as current (Amperes), thus new power_{now,avg}
+ attributes should be used for such batteries to avoid the confusion.
+Who: Alexey Starikovskiy <astarikovskiy@suse.de>
---------------------------
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 65132f9..7aa9f11 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -92,7 +92,7 @@ struct acpi_battery {
#endif
struct acpi_device *device;
unsigned long update_time;
- int current_now;
+ int rate_now;
int capacity_now;
int voltage_now;
int design_capacity;
@@ -173,7 +173,8 @@ static int acpi_battery_get_property(struct power_supply *psy,
val->intval = battery->voltage_now * 1000;
break;
case POWER_SUPPLY_PROP_CURRENT_NOW:
- val->intval = battery->current_now * 1000;
+ case POWER_SUPPLY_PROP_POWER_NOW:
+ val->intval = battery->rate_now * 1000;
break;
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
@@ -223,7 +224,8 @@ 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_CURRENT_NOW, /* to be removed in 2.6.29 */
+ POWER_SUPPLY_PROP_POWER_NOW,
POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
POWER_SUPPLY_PROP_ENERGY_FULL,
POWER_SUPPLY_PROP_ENERGY_NOW,
@@ -250,7 +252,7 @@ struct acpi_offsets {
static struct acpi_offsets state_offsets[] = {
{offsetof(struct acpi_battery, state), 0},
- {offsetof(struct acpi_battery, current_now), 0},
+ {offsetof(struct acpi_battery, rate_now), 0},
{offsetof(struct acpi_battery, capacity_now), 0},
{offsetof(struct acpi_battery, voltage_now), 0},
};
@@ -582,11 +584,11 @@ static int acpi_battery_print_state(struct seq_file *seq, int result)
else
seq_printf(seq, "charging state: charged\n");
- if (battery->current_now == ACPI_BATTERY_VALUE_UNKNOWN)
+ if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN)
seq_printf(seq, "present rate: unknown\n");
else
seq_printf(seq, "present rate: %d %s\n",
- battery->current_now, acpi_battery_units(battery));
+ battery->rate_now, acpi_battery_units(battery));
if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN)
seq_printf(seq, "remaining capacity: unknown\n");
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 6050ce4..e3b0087 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -102,8 +102,8 @@ struct acpi_battery {
u16 cycle_count;
u16 temp_now;
u16 voltage_now;
- s16 current_now;
- s16 current_avg;
+ s16 rate_now;
+ s16 rate_avg;
u16 capacity_now;
u16 state_of_charge;
u16 state;
@@ -202,9 +202,9 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,
return -ENODEV;
switch (psp) {
case POWER_SUPPLY_PROP_STATUS:
- if (battery->current_now < 0)
+ if (battery->rate_now < 0)
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
- else if (battery->current_now > 0)
+ else if (battery->rate_now > 0)
val->intval = POWER_SUPPLY_STATUS_CHARGING;
else
val->intval = POWER_SUPPLY_STATUS_FULL;
@@ -224,11 +224,13 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,
acpi_battery_vscale(battery) * 1000;
break;
case POWER_SUPPLY_PROP_CURRENT_NOW:
- val->intval = abs(battery->current_now) *
+ case POWER_SUPPLY_PROP_POWER_NOW:
+ val->intval = abs(battery->rate_now) *
acpi_battery_ipscale(battery) * 1000;
break;
case POWER_SUPPLY_PROP_CURRENT_AVG:
- val->intval = abs(battery->current_avg) *
+ case POWER_SUPPLY_PROP_POWER_AVG:
+ val->intval = abs(battery->rate_avg) *
acpi_battery_ipscale(battery) * 1000;
break;
case POWER_SUPPLY_PROP_CAPACITY:
@@ -291,8 +293,10 @@ 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_CURRENT_NOW, /* to be removed in 2.6.29 */
+ POWER_SUPPLY_PROP_CURRENT_AVG, /* to be removed in 2.6.29 */
+ 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,
@@ -301,6 +305,7 @@ static enum power_supply_property sbs_energy_battery_props[] = {
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_MANUFACTURER,
};
+
#endif
/* --------------------------------------------------------------------------
@@ -330,8 +335,8 @@ static struct acpi_battery_reader info_readers[] = {
static struct acpi_battery_reader state_readers[] = {
{0x08, SMBUS_READ_WORD, offsetof(struct acpi_battery, temp_now)},
{0x09, SMBUS_READ_WORD, offsetof(struct acpi_battery, voltage_now)},
- {0x0a, SMBUS_READ_WORD, offsetof(struct acpi_battery, current_now)},
- {0x0b, SMBUS_READ_WORD, offsetof(struct acpi_battery, current_avg)},
+ {0x0a, SMBUS_READ_WORD, offsetof(struct acpi_battery, rate_now)},
+ {0x0b, SMBUS_READ_WORD, offsetof(struct acpi_battery, rate_avg)},
{0x0f, SMBUS_READ_WORD, offsetof(struct acpi_battery, capacity_now)},
{0x0e, SMBUS_READ_WORD, offsetof(struct acpi_battery, state_of_charge)},
{0x16, SMBUS_READ_WORD, offsetof(struct acpi_battery, state)},
@@ -589,9 +594,9 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
seq_printf(seq, "capacity state: %s\n",
(battery->state & 0x0010) ? "critical" : "ok");
seq_printf(seq, "charging state: %s\n",
- (battery->current_now < 0) ? "discharging" :
- ((battery->current_now > 0) ? "charging" : "charged"));
- rate = abs(battery->current_now) * acpi_battery_ipscale(battery);
+ (battery->rate_now < 0) ? "discharging" :
+ ((battery->rate_now > 0) ? "charging" : "charged"));
+ rate = abs(battery->rate_now) * acpi_battery_ipscale(battery);
rate *= (acpi_battery_mode(battery))?(battery->voltage_now *
acpi_battery_vscale(battery)/1000):1;
seq_printf(seq, "present rate: %d%s\n", rate,
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index ac01e06..da73591 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 8ff25e0..594c494 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -73,6 +73,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,
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/3] ACPI: EC: Limit workaround for ASUS notebooks even more
2009-01-13 23:57 [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class Alexey Starikovskiy
@ 2009-01-13 23:57 ` Alexey Starikovskiy
2009-01-16 19:08 ` Len Brown
2009-01-13 23:57 ` [PATCH 3/3] ACPI: EC: Don't trust ECDT tables from ASUS Alexey Starikovskiy
2009-01-16 19:11 ` [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class Len Brown
2 siblings, 1 reply; 10+ messages in thread
From: Alexey Starikovskiy @ 2009-01-13 23:57 UTC (permalink / raw)
To: Len Brown; +Cc: Linux-acpi
References: http://bugzilla.kernel.org/show_bug.cgi?id=11884
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
---
drivers/acpi/ec.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 8dfcbb8..e079426 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -1027,7 +1027,8 @@ int __init acpi_ec_ecdt_probe(void)
* which needs it, has fake EC._INI method, so use it as flag.
* Keep boot_ec struct as it will be needed soon.
*/
- if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &dummy)))
+ if (!dmi_name_in_vendors("ASUS") ||
+ ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &dummy)))
return -ENODEV;
install:
if (!ec_install_handlers(boot_ec)) {
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/3] ACPI: EC: Don't trust ECDT tables from ASUS
2009-01-13 23:57 [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class Alexey Starikovskiy
2009-01-13 23:57 ` [PATCH 2/3] ACPI: EC: Limit workaround for ASUS notebooks even more Alexey Starikovskiy
@ 2009-01-13 23:57 ` Alexey Starikovskiy
2009-01-16 19:08 ` Len Brown
2009-01-16 19:11 ` [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class Len Brown
2 siblings, 1 reply; 10+ messages in thread
From: Alexey Starikovskiy @ 2009-01-13 23:57 UTC (permalink / raw)
To: Len Brown; +Cc: Linux-acpi
References: http://bugzilla.kernel.org/show_bug.cgi?id=9399
http://bugzilla.kernel.org/show_bug.cgi?id=11880
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
---
drivers/acpi/ec.c | 74 +++++++++++++++++++++--------------------------------
1 files changed, 30 insertions(+), 44 deletions(-)
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index e079426..a2b82c9 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -120,31 +120,6 @@ static struct acpi_ec {
spinlock_t curr_lock;
} *boot_ec, *first_ec;
-/*
- * Some Asus system have exchanged ECDT data/command IO addresses.
- */
-static int print_ecdt_error(const struct dmi_system_id *id)
-{
- printk(KERN_NOTICE PREFIX "%s detected - "
- "ECDT has exchanged control/data I/O address\n",
- id->ident);
- return 0;
-}
-
-static struct dmi_system_id __cpuinitdata ec_dmi_table[] = {
- {
- print_ecdt_error, "Asus L4R", {
- DMI_MATCH(DMI_BIOS_VERSION, "1008.006"),
- DMI_MATCH(DMI_PRODUCT_NAME, "L4R"),
- DMI_MATCH(DMI_BOARD_NAME, "L4R") }, NULL},
- {
- print_ecdt_error, "Asus M6R", {
- DMI_MATCH(DMI_BIOS_VERSION, "0207"),
- DMI_MATCH(DMI_PRODUCT_NAME, "M6R"),
- DMI_MATCH(DMI_BOARD_NAME, "M6R") }, NULL},
- {},
-};
-
/* --------------------------------------------------------------------------
Transaction Management
-------------------------------------------------------------------------- */
@@ -983,8 +958,8 @@ static const struct acpi_device_id ec_device_ids[] = {
int __init acpi_ec_ecdt_probe(void)
{
acpi_status status;
+ struct acpi_ec *saved_ec = NULL;
struct acpi_table_ecdt *ecdt_ptr;
- acpi_handle dummy;
boot_ec = make_acpi_ec();
if (!boot_ec)
@@ -998,21 +973,16 @@ int __init acpi_ec_ecdt_probe(void)
pr_info(PREFIX "EC description table is found, configuring boot EC\n");
boot_ec->command_addr = ecdt_ptr->control.address;
boot_ec->data_addr = ecdt_ptr->data.address;
- if (dmi_check_system(ec_dmi_table)) {
- /*
- * If the board falls into ec_dmi_table, it means
- * that ECDT table gives the incorrect command/status
- * & data I/O address. Just fix it.
- */
- boot_ec->data_addr = ecdt_ptr->control.address;
- boot_ec->command_addr = ecdt_ptr->data.address;
- }
boot_ec->gpe = ecdt_ptr->gpe;
boot_ec->handle = ACPI_ROOT_OBJECT;
acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle);
- /* Add some basic check against completely broken table */
- if (boot_ec->data_addr != boot_ec->command_addr)
+ /* Don't trust ECDT, which comes from ASUSTek */
+ if (!dmi_name_in_vendors("ASUS"))
goto install;
+ saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
+ if (!saved_ec)
+ return -ENOMEM;
+ memcpy(&saved_ec, boot_ec, sizeof(saved_ec));
/* fall through */
}
/* This workaround is needed only on some broken machines,
@@ -1023,13 +993,29 @@ int __init acpi_ec_ecdt_probe(void)
/* Check that acpi_get_devices actually find something */
if (ACPI_FAILURE(status) || !boot_ec->handle)
goto error;
- /* We really need to limit this workaround, the only ASUS,
- * which needs it, has fake EC._INI method, so use it as flag.
- * Keep boot_ec struct as it will be needed soon.
- */
- if (!dmi_name_in_vendors("ASUS") ||
- ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &dummy)))
- return -ENODEV;
+ if (saved_ec) {
+ /* try to find good ECDT from ASUSTek */
+ if (saved_ec->command_addr != boot_ec->command_addr ||
+ saved_ec->data_addr != boot_ec->data_addr ||
+ saved_ec->gpe != boot_ec->gpe ||
+ saved_ec->handle != boot_ec->handle)
+ pr_info(PREFIX "ASUSTek keeps feeding us with broken "
+ "ECDT tables, which are very hard to workaround. "
+ "Trying to use DSDT EC info instead. Please send "
+ "output of acpidump to linux-acpi@vger.kernel.org\n");
+ kfree(saved_ec);
+ saved_ec = NULL;
+ } else {
+ /* We really need to limit this workaround, the only ASUS,
+ * which needs it, has fake EC._INI method, so use it as flag.
+ * Keep boot_ec struct as it will be needed soon.
+ */
+ acpi_handle dummy;
+ if (!dmi_name_in_vendors("ASUS") ||
+ ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI",
+ &dummy)))
+ return -ENODEV;
+ }
install:
if (!ec_install_handlers(boot_ec)) {
first_ec = boot_ec;
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] ACPI: EC: Don't trust ECDT tables from ASUS
2009-01-13 23:57 ` [PATCH 3/3] ACPI: EC: Don't trust ECDT tables from ASUS Alexey Starikovskiy
@ 2009-01-16 19:08 ` Len Brown
0 siblings, 0 replies; 10+ messages in thread
From: Len Brown @ 2009-01-16 19:08 UTC (permalink / raw)
To: Alexey Starikovskiy; +Cc: Linux-acpi
applied
--
Len Brown, Intel Open Source Technology Center
On Wed, 14 Jan 2009, Alexey Starikovskiy wrote:
> References: http://bugzilla.kernel.org/show_bug.cgi?id=9399
> http://bugzilla.kernel.org/show_bug.cgi?id=11880
>
> Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
> ---
>
> drivers/acpi/ec.c | 74 +++++++++++++++++++++--------------------------------
> 1 files changed, 30 insertions(+), 44 deletions(-)
>
>
> diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
> index e079426..a2b82c9 100644
> --- a/drivers/acpi/ec.c
> +++ b/drivers/acpi/ec.c
> @@ -120,31 +120,6 @@ static struct acpi_ec {
> spinlock_t curr_lock;
> } *boot_ec, *first_ec;
>
> -/*
> - * Some Asus system have exchanged ECDT data/command IO addresses.
> - */
> -static int print_ecdt_error(const struct dmi_system_id *id)
> -{
> - printk(KERN_NOTICE PREFIX "%s detected - "
> - "ECDT has exchanged control/data I/O address\n",
> - id->ident);
> - return 0;
> -}
> -
> -static struct dmi_system_id __cpuinitdata ec_dmi_table[] = {
> - {
> - print_ecdt_error, "Asus L4R", {
> - DMI_MATCH(DMI_BIOS_VERSION, "1008.006"),
> - DMI_MATCH(DMI_PRODUCT_NAME, "L4R"),
> - DMI_MATCH(DMI_BOARD_NAME, "L4R") }, NULL},
> - {
> - print_ecdt_error, "Asus M6R", {
> - DMI_MATCH(DMI_BIOS_VERSION, "0207"),
> - DMI_MATCH(DMI_PRODUCT_NAME, "M6R"),
> - DMI_MATCH(DMI_BOARD_NAME, "M6R") }, NULL},
> - {},
> -};
> -
> /* --------------------------------------------------------------------------
> Transaction Management
> -------------------------------------------------------------------------- */
> @@ -983,8 +958,8 @@ static const struct acpi_device_id ec_device_ids[] = {
> int __init acpi_ec_ecdt_probe(void)
> {
> acpi_status status;
> + struct acpi_ec *saved_ec = NULL;
> struct acpi_table_ecdt *ecdt_ptr;
> - acpi_handle dummy;
>
> boot_ec = make_acpi_ec();
> if (!boot_ec)
> @@ -998,21 +973,16 @@ int __init acpi_ec_ecdt_probe(void)
> pr_info(PREFIX "EC description table is found, configuring boot EC\n");
> boot_ec->command_addr = ecdt_ptr->control.address;
> boot_ec->data_addr = ecdt_ptr->data.address;
> - if (dmi_check_system(ec_dmi_table)) {
> - /*
> - * If the board falls into ec_dmi_table, it means
> - * that ECDT table gives the incorrect command/status
> - * & data I/O address. Just fix it.
> - */
> - boot_ec->data_addr = ecdt_ptr->control.address;
> - boot_ec->command_addr = ecdt_ptr->data.address;
> - }
> boot_ec->gpe = ecdt_ptr->gpe;
> boot_ec->handle = ACPI_ROOT_OBJECT;
> acpi_get_handle(ACPI_ROOT_OBJECT, ecdt_ptr->id, &boot_ec->handle);
> - /* Add some basic check against completely broken table */
> - if (boot_ec->data_addr != boot_ec->command_addr)
> + /* Don't trust ECDT, which comes from ASUSTek */
> + if (!dmi_name_in_vendors("ASUS"))
> goto install;
> + saved_ec = kmalloc(sizeof(struct acpi_ec), GFP_KERNEL);
> + if (!saved_ec)
> + return -ENOMEM;
> + memcpy(&saved_ec, boot_ec, sizeof(saved_ec));
> /* fall through */
> }
> /* This workaround is needed only on some broken machines,
> @@ -1023,13 +993,29 @@ int __init acpi_ec_ecdt_probe(void)
> /* Check that acpi_get_devices actually find something */
> if (ACPI_FAILURE(status) || !boot_ec->handle)
> goto error;
> - /* We really need to limit this workaround, the only ASUS,
> - * which needs it, has fake EC._INI method, so use it as flag.
> - * Keep boot_ec struct as it will be needed soon.
> - */
> - if (!dmi_name_in_vendors("ASUS") ||
> - ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &dummy)))
> - return -ENODEV;
> + if (saved_ec) {
> + /* try to find good ECDT from ASUSTek */
> + if (saved_ec->command_addr != boot_ec->command_addr ||
> + saved_ec->data_addr != boot_ec->data_addr ||
> + saved_ec->gpe != boot_ec->gpe ||
> + saved_ec->handle != boot_ec->handle)
> + pr_info(PREFIX "ASUSTek keeps feeding us with broken "
> + "ECDT tables, which are very hard to workaround. "
> + "Trying to use DSDT EC info instead. Please send "
> + "output of acpidump to linux-acpi@vger.kernel.org\n");
> + kfree(saved_ec);
> + saved_ec = NULL;
> + } else {
> + /* We really need to limit this workaround, the only ASUS,
> + * which needs it, has fake EC._INI method, so use it as flag.
> + * Keep boot_ec struct as it will be needed soon.
> + */
> + acpi_handle dummy;
> + if (!dmi_name_in_vendors("ASUS") ||
> + ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI",
> + &dummy)))
> + return -ENODEV;
> + }
> install:
> if (!ec_install_handlers(boot_ec)) {
> first_ec = boot_ec;
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/3] ACPI: EC: Limit workaround for ASUS notebooks even more
2009-01-13 23:57 ` [PATCH 2/3] ACPI: EC: Limit workaround for ASUS notebooks even more Alexey Starikovskiy
@ 2009-01-16 19:08 ` Len Brown
0 siblings, 0 replies; 10+ messages in thread
From: Len Brown @ 2009-01-16 19:08 UTC (permalink / raw)
To: Alexey Starikovskiy; +Cc: Linux-acpi
applied
--
Len Brown, Intel Open Source Technology Center
On Wed, 14 Jan 2009, Alexey Starikovskiy wrote:
> References: http://bugzilla.kernel.org/show_bug.cgi?id=11884
>
> Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
> ---
>
> drivers/acpi/ec.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
>
> diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
> index 8dfcbb8..e079426 100644
> --- a/drivers/acpi/ec.c
> +++ b/drivers/acpi/ec.c
> @@ -1027,7 +1027,8 @@ int __init acpi_ec_ecdt_probe(void)
> * which needs it, has fake EC._INI method, so use it as flag.
> * Keep boot_ec struct as it will be needed soon.
> */
> - if (ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &dummy)))
> + if (!dmi_name_in_vendors("ASUS") ||
> + ACPI_FAILURE(acpi_get_handle(boot_ec->handle, "_INI", &dummy)))
> return -ENODEV;
> install:
> if (!ec_install_handlers(boot_ec)) {
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class
2009-01-13 23:57 [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class Alexey Starikovskiy
2009-01-13 23:57 ` [PATCH 2/3] ACPI: EC: Limit workaround for ASUS notebooks even more Alexey Starikovskiy
2009-01-13 23:57 ` [PATCH 3/3] ACPI: EC: Don't trust ECDT tables from ASUS Alexey Starikovskiy
@ 2009-01-16 19:11 ` Len Brown
2009-01-16 19:32 ` Alexey Starikovskiy
2 siblings, 1 reply; 10+ messages in thread
From: Len Brown @ 2009-01-16 19:11 UTC (permalink / raw)
To: Alexey Starikovskiy; +Cc: Linux-acpi
How can this patch schedule something for removal in 2.6.29
when the patch itself isn't in the tree before 2.6.29?
--
Len Brown, Intel Open Source Technology Center
On Wed, 14 Jan 2009, Alexey Starikovskiy wrote:
> 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. Current_now will be exported until 2.6.29 to allow
> for userland applications to match.
>
> Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
> ---
>
> Documentation/feature-removal-schedule.txt | 8 +++++++
> drivers/acpi/battery.c | 14 +++++++------
> drivers/acpi/sbs.c | 31 ++++++++++++++++------------
> drivers/power/power_supply_sysfs.c | 2 ++
> include/linux/power_supply.h | 2 ++
> 5 files changed, 38 insertions(+), 19 deletions(-)
>
>
> diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
> index 5ddbe35..79fe354 100644
> --- a/Documentation/feature-removal-schedule.txt
> +++ b/Documentation/feature-removal-schedule.txt
> @@ -3,6 +3,14 @@ removed in the kernel source tree. Every entry should contain what
> exactly is going away, why it is happening, and who is going to be doing
> the work. When the feature is removed from the kernel, it should also
> be removed from this file.
> +---------------------------
> +
> +What: current_{now,avg} attributes for batteries, reporting in energy units
> +When: 2.6.29
> +Why: Batteries, reporting in energy units, will report (dis)charge rate as
> + power (Watts), and not as current (Amperes), thus new power_{now,avg}
> + attributes should be used for such batteries to avoid the confusion.
> +Who: Alexey Starikovskiy <astarikovskiy@suse.de>
>
> ---------------------------
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 65132f9..7aa9f11 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -92,7 +92,7 @@ struct acpi_battery {
> #endif
> struct acpi_device *device;
> unsigned long update_time;
> - int current_now;
> + int rate_now;
> int capacity_now;
> int voltage_now;
> int design_capacity;
> @@ -173,7 +173,8 @@ static int acpi_battery_get_property(struct power_supply *psy,
> val->intval = battery->voltage_now * 1000;
> break;
> case POWER_SUPPLY_PROP_CURRENT_NOW:
> - val->intval = battery->current_now * 1000;
> + case POWER_SUPPLY_PROP_POWER_NOW:
> + val->intval = battery->rate_now * 1000;
> break;
> case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
> case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
> @@ -223,7 +224,8 @@ 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_CURRENT_NOW, /* to be removed in 2.6.29 */
> + POWER_SUPPLY_PROP_POWER_NOW,
> POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
> POWER_SUPPLY_PROP_ENERGY_FULL,
> POWER_SUPPLY_PROP_ENERGY_NOW,
> @@ -250,7 +252,7 @@ struct acpi_offsets {
>
> static struct acpi_offsets state_offsets[] = {
> {offsetof(struct acpi_battery, state), 0},
> - {offsetof(struct acpi_battery, current_now), 0},
> + {offsetof(struct acpi_battery, rate_now), 0},
> {offsetof(struct acpi_battery, capacity_now), 0},
> {offsetof(struct acpi_battery, voltage_now), 0},
> };
> @@ -582,11 +584,11 @@ static int acpi_battery_print_state(struct seq_file *seq, int result)
> else
> seq_printf(seq, "charging state: charged\n");
>
> - if (battery->current_now == ACPI_BATTERY_VALUE_UNKNOWN)
> + if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN)
> seq_printf(seq, "present rate: unknown\n");
> else
> seq_printf(seq, "present rate: %d %s\n",
> - battery->current_now, acpi_battery_units(battery));
> + battery->rate_now, acpi_battery_units(battery));
>
> if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN)
> seq_printf(seq, "remaining capacity: unknown\n");
> diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
> index 6050ce4..e3b0087 100644
> --- a/drivers/acpi/sbs.c
> +++ b/drivers/acpi/sbs.c
> @@ -102,8 +102,8 @@ struct acpi_battery {
> u16 cycle_count;
> u16 temp_now;
> u16 voltage_now;
> - s16 current_now;
> - s16 current_avg;
> + s16 rate_now;
> + s16 rate_avg;
> u16 capacity_now;
> u16 state_of_charge;
> u16 state;
> @@ -202,9 +202,9 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,
> return -ENODEV;
> switch (psp) {
> case POWER_SUPPLY_PROP_STATUS:
> - if (battery->current_now < 0)
> + if (battery->rate_now < 0)
> val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
> - else if (battery->current_now > 0)
> + else if (battery->rate_now > 0)
> val->intval = POWER_SUPPLY_STATUS_CHARGING;
> else
> val->intval = POWER_SUPPLY_STATUS_FULL;
> @@ -224,11 +224,13 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,
> acpi_battery_vscale(battery) * 1000;
> break;
> case POWER_SUPPLY_PROP_CURRENT_NOW:
> - val->intval = abs(battery->current_now) *
> + case POWER_SUPPLY_PROP_POWER_NOW:
> + val->intval = abs(battery->rate_now) *
> acpi_battery_ipscale(battery) * 1000;
> break;
> case POWER_SUPPLY_PROP_CURRENT_AVG:
> - val->intval = abs(battery->current_avg) *
> + case POWER_SUPPLY_PROP_POWER_AVG:
> + val->intval = abs(battery->rate_avg) *
> acpi_battery_ipscale(battery) * 1000;
> break;
> case POWER_SUPPLY_PROP_CAPACITY:
> @@ -291,8 +293,10 @@ 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_CURRENT_NOW, /* to be removed in 2.6.29 */
> + POWER_SUPPLY_PROP_CURRENT_AVG, /* to be removed in 2.6.29 */
> + 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,
> @@ -301,6 +305,7 @@ static enum power_supply_property sbs_energy_battery_props[] = {
> POWER_SUPPLY_PROP_MODEL_NAME,
> POWER_SUPPLY_PROP_MANUFACTURER,
> };
> +
> #endif
>
> /* --------------------------------------------------------------------------
> @@ -330,8 +335,8 @@ static struct acpi_battery_reader info_readers[] = {
> static struct acpi_battery_reader state_readers[] = {
> {0x08, SMBUS_READ_WORD, offsetof(struct acpi_battery, temp_now)},
> {0x09, SMBUS_READ_WORD, offsetof(struct acpi_battery, voltage_now)},
> - {0x0a, SMBUS_READ_WORD, offsetof(struct acpi_battery, current_now)},
> - {0x0b, SMBUS_READ_WORD, offsetof(struct acpi_battery, current_avg)},
> + {0x0a, SMBUS_READ_WORD, offsetof(struct acpi_battery, rate_now)},
> + {0x0b, SMBUS_READ_WORD, offsetof(struct acpi_battery, rate_avg)},
> {0x0f, SMBUS_READ_WORD, offsetof(struct acpi_battery, capacity_now)},
> {0x0e, SMBUS_READ_WORD, offsetof(struct acpi_battery, state_of_charge)},
> {0x16, SMBUS_READ_WORD, offsetof(struct acpi_battery, state)},
> @@ -589,9 +594,9 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
> seq_printf(seq, "capacity state: %s\n",
> (battery->state & 0x0010) ? "critical" : "ok");
> seq_printf(seq, "charging state: %s\n",
> - (battery->current_now < 0) ? "discharging" :
> - ((battery->current_now > 0) ? "charging" : "charged"));
> - rate = abs(battery->current_now) * acpi_battery_ipscale(battery);
> + (battery->rate_now < 0) ? "discharging" :
> + ((battery->rate_now > 0) ? "charging" : "charged"));
> + rate = abs(battery->rate_now) * acpi_battery_ipscale(battery);
> rate *= (acpi_battery_mode(battery))?(battery->voltage_now *
> acpi_battery_vscale(battery)/1000):1;
> seq_printf(seq, "present rate: %d%s\n", rate,
> diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
> index ac01e06..da73591 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 8ff25e0..594c494 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -73,6 +73,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,
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class
2009-01-16 19:11 ` [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class Len Brown
@ 2009-01-16 19:32 ` Alexey Starikovskiy
2009-03-17 6:24 ` Len Brown
0 siblings, 1 reply; 10+ messages in thread
From: Alexey Starikovskiy @ 2009-01-16 19:32 UTC (permalink / raw)
To: Len Brown; +Cc: Linux-acpi
2.6.30?
or 2.6.31?
Len Brown wrote:
> How can this patch schedule something for removal in 2.6.29
> when the patch itself isn't in the tree before 2.6.29?
> --
> Len Brown, Intel Open Source Technology Center
>
> On Wed, 14 Jan 2009, Alexey Starikovskiy wrote:
>
>> 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. Current_now will be exported until 2.6.29 to allow
>> for userland applications to match.
>>
>> Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
>> ---
>>
>> Documentation/feature-removal-schedule.txt | 8 +++++++
>> drivers/acpi/battery.c | 14 +++++++------
>> drivers/acpi/sbs.c | 31 ++++++++++++++++------------
>> drivers/power/power_supply_sysfs.c | 2 ++
>> include/linux/power_supply.h | 2 ++
>> 5 files changed, 38 insertions(+), 19 deletions(-)
>>
>>
>> diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
>> index 5ddbe35..79fe354 100644
>> --- a/Documentation/feature-removal-schedule.txt
>> +++ b/Documentation/feature-removal-schedule.txt
>> @@ -3,6 +3,14 @@ removed in the kernel source tree. Every entry should contain what
>> exactly is going away, why it is happening, and who is going to be doing
>> the work. When the feature is removed from the kernel, it should also
>> be removed from this file.
>> +---------------------------
>> +
>> +What: current_{now,avg} attributes for batteries, reporting in energy units
>> +When: 2.6.29
>> +Why: Batteries, reporting in energy units, will report (dis)charge rate as
>> + power (Watts), and not as current (Amperes), thus new power_{now,avg}
>> + attributes should be used for such batteries to avoid the confusion.
>> +Who: Alexey Starikovskiy <astarikovskiy@suse.de>
>>
>> ---------------------------
>>
>> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
>> index 65132f9..7aa9f11 100644
>> --- a/drivers/acpi/battery.c
>> +++ b/drivers/acpi/battery.c
>> @@ -92,7 +92,7 @@ struct acpi_battery {
>> #endif
>> struct acpi_device *device;
>> unsigned long update_time;
>> - int current_now;
>> + int rate_now;
>> int capacity_now;
>> int voltage_now;
>> int design_capacity;
>> @@ -173,7 +173,8 @@ static int acpi_battery_get_property(struct power_supply *psy,
>> val->intval = battery->voltage_now * 1000;
>> break;
>> case POWER_SUPPLY_PROP_CURRENT_NOW:
>> - val->intval = battery->current_now * 1000;
>> + case POWER_SUPPLY_PROP_POWER_NOW:
>> + val->intval = battery->rate_now * 1000;
>> break;
>> case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
>> case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
>> @@ -223,7 +224,8 @@ 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_CURRENT_NOW, /* to be removed in 2.6.29 */
>> + POWER_SUPPLY_PROP_POWER_NOW,
>> POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
>> POWER_SUPPLY_PROP_ENERGY_FULL,
>> POWER_SUPPLY_PROP_ENERGY_NOW,
>> @@ -250,7 +252,7 @@ struct acpi_offsets {
>>
>> static struct acpi_offsets state_offsets[] = {
>> {offsetof(struct acpi_battery, state), 0},
>> - {offsetof(struct acpi_battery, current_now), 0},
>> + {offsetof(struct acpi_battery, rate_now), 0},
>> {offsetof(struct acpi_battery, capacity_now), 0},
>> {offsetof(struct acpi_battery, voltage_now), 0},
>> };
>> @@ -582,11 +584,11 @@ static int acpi_battery_print_state(struct seq_file *seq, int result)
>> else
>> seq_printf(seq, "charging state: charged\n");
>>
>> - if (battery->current_now == ACPI_BATTERY_VALUE_UNKNOWN)
>> + if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN)
>> seq_printf(seq, "present rate: unknown\n");
>> else
>> seq_printf(seq, "present rate: %d %s\n",
>> - battery->current_now, acpi_battery_units(battery));
>> + battery->rate_now, acpi_battery_units(battery));
>>
>> if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN)
>> seq_printf(seq, "remaining capacity: unknown\n");
>> diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
>> index 6050ce4..e3b0087 100644
>> --- a/drivers/acpi/sbs.c
>> +++ b/drivers/acpi/sbs.c
>> @@ -102,8 +102,8 @@ struct acpi_battery {
>> u16 cycle_count;
>> u16 temp_now;
>> u16 voltage_now;
>> - s16 current_now;
>> - s16 current_avg;
>> + s16 rate_now;
>> + s16 rate_avg;
>> u16 capacity_now;
>> u16 state_of_charge;
>> u16 state;
>> @@ -202,9 +202,9 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,
>> return -ENODEV;
>> switch (psp) {
>> case POWER_SUPPLY_PROP_STATUS:
>> - if (battery->current_now < 0)
>> + if (battery->rate_now < 0)
>> val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
>> - else if (battery->current_now > 0)
>> + else if (battery->rate_now > 0)
>> val->intval = POWER_SUPPLY_STATUS_CHARGING;
>> else
>> val->intval = POWER_SUPPLY_STATUS_FULL;
>> @@ -224,11 +224,13 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,
>> acpi_battery_vscale(battery) * 1000;
>> break;
>> case POWER_SUPPLY_PROP_CURRENT_NOW:
>> - val->intval = abs(battery->current_now) *
>> + case POWER_SUPPLY_PROP_POWER_NOW:
>> + val->intval = abs(battery->rate_now) *
>> acpi_battery_ipscale(battery) * 1000;
>> break;
>> case POWER_SUPPLY_PROP_CURRENT_AVG:
>> - val->intval = abs(battery->current_avg) *
>> + case POWER_SUPPLY_PROP_POWER_AVG:
>> + val->intval = abs(battery->rate_avg) *
>> acpi_battery_ipscale(battery) * 1000;
>> break;
>> case POWER_SUPPLY_PROP_CAPACITY:
>> @@ -291,8 +293,10 @@ 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_CURRENT_NOW, /* to be removed in 2.6.29 */
>> + POWER_SUPPLY_PROP_CURRENT_AVG, /* to be removed in 2.6.29 */
>> + 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,
>> @@ -301,6 +305,7 @@ static enum power_supply_property sbs_energy_battery_props[] = {
>> POWER_SUPPLY_PROP_MODEL_NAME,
>> POWER_SUPPLY_PROP_MANUFACTURER,
>> };
>> +
>> #endif
>>
>> /* --------------------------------------------------------------------------
>> @@ -330,8 +335,8 @@ static struct acpi_battery_reader info_readers[] = {
>> static struct acpi_battery_reader state_readers[] = {
>> {0x08, SMBUS_READ_WORD, offsetof(struct acpi_battery, temp_now)},
>> {0x09, SMBUS_READ_WORD, offsetof(struct acpi_battery, voltage_now)},
>> - {0x0a, SMBUS_READ_WORD, offsetof(struct acpi_battery, current_now)},
>> - {0x0b, SMBUS_READ_WORD, offsetof(struct acpi_battery, current_avg)},
>> + {0x0a, SMBUS_READ_WORD, offsetof(struct acpi_battery, rate_now)},
>> + {0x0b, SMBUS_READ_WORD, offsetof(struct acpi_battery, rate_avg)},
>> {0x0f, SMBUS_READ_WORD, offsetof(struct acpi_battery, capacity_now)},
>> {0x0e, SMBUS_READ_WORD, offsetof(struct acpi_battery, state_of_charge)},
>> {0x16, SMBUS_READ_WORD, offsetof(struct acpi_battery, state)},
>> @@ -589,9 +594,9 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
>> seq_printf(seq, "capacity state: %s\n",
>> (battery->state & 0x0010) ? "critical" : "ok");
>> seq_printf(seq, "charging state: %s\n",
>> - (battery->current_now < 0) ? "discharging" :
>> - ((battery->current_now > 0) ? "charging" : "charged"));
>> - rate = abs(battery->current_now) * acpi_battery_ipscale(battery);
>> + (battery->rate_now < 0) ? "discharging" :
>> + ((battery->rate_now > 0) ? "charging" : "charged"));
>> + rate = abs(battery->rate_now) * acpi_battery_ipscale(battery);
>> rate *= (acpi_battery_mode(battery))?(battery->voltage_now *
>> acpi_battery_vscale(battery)/1000):1;
>> seq_printf(seq, "present rate: %d%s\n", rate,
>> diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
>> index ac01e06..da73591 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 8ff25e0..594c494 100644
>> --- a/include/linux/power_supply.h
>> +++ b/include/linux/power_supply.h
>> @@ -73,6 +73,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,
>>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class
2009-01-16 19:32 ` Alexey Starikovskiy
@ 2009-03-17 6:24 ` Len Brown
2009-03-17 14:20 ` Alexey Starikovskiy
0 siblings, 1 reply; 10+ messages in thread
From: Len Brown @ 2009-03-17 6:24 UTC (permalink / raw)
To: Alexey Starikovskiy; +Cc: Linux-acpi
On Fri, 16 Jan 2009, Alexey Starikovskiy wrote:
> 2.6.30?
> or 2.6.31?
Although we've had this patch in the test tree for a bit,
I don't think that any amount of aging in -next will help us here.
Is it possible to put the add the new attribute immediately,
get buy-in from the user-space guys,
and then remove the old attribute in a subsequent patch?
thanks,
Len Brown, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class
2009-03-17 6:24 ` Len Brown
@ 2009-03-17 14:20 ` Alexey Starikovskiy
2009-03-28 21:59 ` Alexey Starikovskiy
0 siblings, 1 reply; 10+ messages in thread
From: Alexey Starikovskiy @ 2009-03-17 14:20 UTC (permalink / raw)
To: Len Brown; +Cc: Linux-acpi
[-- Attachment #1: Type: text/plain, Size: 605 bytes --]
Len Brown wrote:
> On Fri, 16 Jan 2009, Alexey Starikovskiy wrote:
>
>> 2.6.30?
>> or 2.6.31?
>
> Although we've had this patch in the test tree for a bit,
> I don't think that any amount of aging in -next will help us here.
>
> Is it possible to put the add the new attribute immediately,
> get buy-in from the user-space guys,
> and then remove the old attribute in a subsequent patch?
Actually this is what patch did -- it only mentioned feature removal.
Attached is the patch with no mention of removal schedule at all.
>
> thanks,
> Len Brown, Intel Open Source Technology Center
Regards,
Alex.
[-- Attachment #2: add_power_now_property_to_power_class.patch --]
[-- Type: text/x-diff, Size: 7301 bytes --]
ACPI: battery: add power_{now,avg} properties to power_class
From: Alexey Starikovskiy <astarikovskiy@suse.de>
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. Current_now will still be exported to allow
for userland applications to match.
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
---
drivers/acpi/battery.c | 12 +++++++-----
drivers/acpi/sbs.c | 27 ++++++++++++++++-----------
drivers/power/power_supply_sysfs.c | 2 ++
include/linux/power_supply.h | 2 ++
4 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 69cbc57..09a2240 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -92,7 +92,7 @@ struct acpi_battery {
#endif
struct acpi_device *device;
unsigned long update_time;
- int current_now;
+ int rate_now;
int capacity_now;
int voltage_now;
int design_capacity;
@@ -196,7 +196,8 @@ static int acpi_battery_get_property(struct power_supply *psy,
val->intval = battery->voltage_now * 1000;
break;
case POWER_SUPPLY_PROP_CURRENT_NOW:
- val->intval = battery->current_now * 1000;
+ case POWER_SUPPLY_PROP_POWER_NOW:
+ val->intval = battery->rate_now * 1000;
break;
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN:
@@ -247,6 +248,7 @@ static enum power_supply_property energy_battery_props[] = {
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,
@@ -273,7 +275,7 @@ struct acpi_offsets {
static struct acpi_offsets state_offsets[] = {
{offsetof(struct acpi_battery, state), 0},
- {offsetof(struct acpi_battery, current_now), 0},
+ {offsetof(struct acpi_battery, rate_now), 0},
{offsetof(struct acpi_battery, capacity_now), 0},
{offsetof(struct acpi_battery, voltage_now), 0},
};
@@ -605,11 +607,11 @@ static int acpi_battery_print_state(struct seq_file *seq, int result)
else
seq_printf(seq, "charging state: charged\n");
- if (battery->current_now == ACPI_BATTERY_VALUE_UNKNOWN)
+ if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN)
seq_printf(seq, "present rate: unknown\n");
else
seq_printf(seq, "present rate: %d %s\n",
- battery->current_now, acpi_battery_units(battery));
+ battery->rate_now, acpi_battery_units(battery));
if (battery->capacity_now == ACPI_BATTERY_VALUE_UNKNOWN)
seq_printf(seq, "remaining capacity: unknown\n");
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index 6050ce4..3963cb6 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -102,8 +102,8 @@ struct acpi_battery {
u16 cycle_count;
u16 temp_now;
u16 voltage_now;
- s16 current_now;
- s16 current_avg;
+ s16 rate_now;
+ s16 rate_avg;
u16 capacity_now;
u16 state_of_charge;
u16 state;
@@ -202,9 +202,9 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,
return -ENODEV;
switch (psp) {
case POWER_SUPPLY_PROP_STATUS:
- if (battery->current_now < 0)
+ if (battery->rate_now < 0)
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
- else if (battery->current_now > 0)
+ else if (battery->rate_now > 0)
val->intval = POWER_SUPPLY_STATUS_CHARGING;
else
val->intval = POWER_SUPPLY_STATUS_FULL;
@@ -224,11 +224,13 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy,
acpi_battery_vscale(battery) * 1000;
break;
case POWER_SUPPLY_PROP_CURRENT_NOW:
- val->intval = abs(battery->current_now) *
+ case POWER_SUPPLY_PROP_POWER_NOW:
+ val->intval = abs(battery->rate_now) *
acpi_battery_ipscale(battery) * 1000;
break;
case POWER_SUPPLY_PROP_CURRENT_AVG:
- val->intval = abs(battery->current_avg) *
+ case POWER_SUPPLY_PROP_POWER_AVG:
+ val->intval = abs(battery->rate_avg) *
acpi_battery_ipscale(battery) * 1000;
break;
case POWER_SUPPLY_PROP_CAPACITY:
@@ -293,6 +295,8 @@ static enum power_supply_property sbs_energy_battery_props[] = {
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,
@@ -301,6 +305,7 @@ static enum power_supply_property sbs_energy_battery_props[] = {
POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_MANUFACTURER,
};
+
#endif
/* --------------------------------------------------------------------------
@@ -330,8 +335,8 @@ static struct acpi_battery_reader info_readers[] = {
static struct acpi_battery_reader state_readers[] = {
{0x08, SMBUS_READ_WORD, offsetof(struct acpi_battery, temp_now)},
{0x09, SMBUS_READ_WORD, offsetof(struct acpi_battery, voltage_now)},
- {0x0a, SMBUS_READ_WORD, offsetof(struct acpi_battery, current_now)},
- {0x0b, SMBUS_READ_WORD, offsetof(struct acpi_battery, current_avg)},
+ {0x0a, SMBUS_READ_WORD, offsetof(struct acpi_battery, rate_now)},
+ {0x0b, SMBUS_READ_WORD, offsetof(struct acpi_battery, rate_avg)},
{0x0f, SMBUS_READ_WORD, offsetof(struct acpi_battery, capacity_now)},
{0x0e, SMBUS_READ_WORD, offsetof(struct acpi_battery, state_of_charge)},
{0x16, SMBUS_READ_WORD, offsetof(struct acpi_battery, state)},
@@ -589,9 +594,9 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
seq_printf(seq, "capacity state: %s\n",
(battery->state & 0x0010) ? "critical" : "ok");
seq_printf(seq, "charging state: %s\n",
- (battery->current_now < 0) ? "discharging" :
- ((battery->current_now > 0) ? "charging" : "charged"));
- rate = abs(battery->current_now) * acpi_battery_ipscale(battery);
+ (battery->rate_now < 0) ? "discharging" :
+ ((battery->rate_now > 0) ? "charging" : "charged"));
+ rate = abs(battery->rate_now) * acpi_battery_ipscale(battery);
rate *= (acpi_battery_mode(battery))?(battery->voltage_now *
acpi_battery_vscale(battery)/1000):1;
seq_printf(seq, "present rate: %d%s\n", rate,
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index ac01e06..da73591 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 8ff25e0..594c494 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -73,6 +73,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,
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class
2009-03-17 14:20 ` Alexey Starikovskiy
@ 2009-03-28 21:59 ` Alexey Starikovskiy
0 siblings, 0 replies; 10+ messages in thread
From: Alexey Starikovskiy @ 2009-03-28 21:59 UTC (permalink / raw)
To: Len Brown; +Cc: Linux-acpi
Hi Len,
Rafael: What I said is that it was too late to change the interpretation of
'current_now' in the case when energy units were used.
My patch does not change interpretation of 'current_now' in the case when energy units are used.
It only adds _new_ power_now and power_avg attributes in this case.
I hope it is clear now.
Regards,
Alex.
Alexey Starikovskiy wrote:
> Len Brown wrote:
>> On Fri, 16 Jan 2009, Alexey Starikovskiy wrote:
>>
>>> 2.6.30?
>>> or 2.6.31?
>>
>> Although we've had this patch in the test tree for a bit,
>> I don't think that any amount of aging in -next will help us here.
>>
>> Is it possible to put the add the new attribute immediately,
>> get buy-in from the user-space guys,
>> and then remove the old attribute in a subsequent patch?
> Actually this is what patch did -- it only mentioned feature removal.
> Attached is the patch with no mention of removal schedule at all.
>>
>> thanks,
>> Len Brown, Intel Open Source Technology Center
>
> Regards,
> Alex.
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-03-28 21:59 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-13 23:57 [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class Alexey Starikovskiy
2009-01-13 23:57 ` [PATCH 2/3] ACPI: EC: Limit workaround for ASUS notebooks even more Alexey Starikovskiy
2009-01-16 19:08 ` Len Brown
2009-01-13 23:57 ` [PATCH 3/3] ACPI: EC: Don't trust ECDT tables from ASUS Alexey Starikovskiy
2009-01-16 19:08 ` Len Brown
2009-01-16 19:11 ` [PATCH 1/3] ACPI: battery: add power_{now, avg} properties to power_class Len Brown
2009-01-16 19:32 ` Alexey Starikovskiy
2009-03-17 6:24 ` Len Brown
2009-03-17 14:20 ` Alexey Starikovskiy
2009-03-28 21:59 ` Alexey Starikovskiy
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).