ACPI: Battery: remove cycle from battery removal.
PATCH 1/1 ACPI: Battery: remove cycle from battery removal.
get_property() should not call battery_update(),
it also should call get_status() only if battery is present to avoid cycle and oops.
Signed-off-by Alexey Starikovskiy <[email protected]>
Tested-by Rolf Eike Beer <[email protected]>
Acked-by Johannes Weiner <[email protected]>
---
drivers/acpi/battery.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
drivers/acpi/battery.c +6 -4
@@ -132,7 +132,7 @@ static int acpi_battery_technology(struct acpi_battery *battery)return POWER_SUPPLY_TECHNOLOGY_UNKNOWN ; } -static int acpi_battery_update (struct acpi_battery *battery); +static int acpi_battery_get_state (struct acpi_battery *battery); static int acpi_battery_get_property(struct power_supply *psy, enum power_supply_property psp,
@@ -140,10 +140,11 @@ static int acpi_battery_get_property(struct power_supply *psy, {struct acpi_battery *battery =to_acpi_battery (psy); -if ((!acpi_battery_present (battery)) && - psp !=POWER_SUPPLY_PROP_PRESENT ) +if (acpi_battery_present (battery)) { +/* run battery update only if it is present */ +acpi_battery_get_state (battery); + }else if (psp !=POWER_SUPPLY_PROP_PRESENT )return -ENODEV ; -acpi_battery_update (battery);switch (psp) {case POWER_SUPPLY_PROP_STATUS :if (battery->state &0x01 )
@@ -457,6 +458,7 @@ static void sysfs_remove_battery(struct acpi_battery *battery)return ;device_remove_file (battery->bat.dev, &alarm_attr);power_supply_unregister (&battery->bat); + battery->bat.dev =NULL ; }static int acpi_battery_update (struct acpi_battery *battery)
Quoted 7 lines · Alexey Starikovskiy
get_property()should not callbattery_update(),
it also should callget_status()only if battery is present to avoid cycle and oops.Signed-off-by Alexey Starikovskiy <[email protected]>Tested-by Rolf Eike Beer <[email protected]>Acked-by Johannes Weiner <[email protected]>
It looks like this patch has been merged as commit 9104476e4efbef8a8e32d48ced583603ff32a2db
Quoted 43 lines
---
drivers/acpi/battery.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)drivers/acpi/battery.c +6
-5@@ -132,7 +132,7 @@ static int acpi_battery_technology(struct acpi_battery *battery)return POWER_SUPPLY_TECHNOLOGY_UNKNOWN ; } -static int acpi_battery_update (struct acpi_battery *battery); +static int acpi_battery_get_state (struct acpi_battery *battery); static int acpi_battery_get_property(struct power_supply *psy, enum power_supply_property psp,@@ -140,10 +140,11 @@ static int acpi_battery_get_property(struct power_supply *psy, {struct acpi_battery *battery =to_acpi_battery (psy); -if ((!acpi_battery_present (battery)) && - psp !=POWER_SUPPLY_PROP_PRESENT ) +if (acpi_battery_present (battery)) { +/* run battery update only if it is present */ +acpi_battery_get_state (battery); + }else if (psp !=POWER_SUPPLY_PROP_PRESENT )return -ENODEV ; -acpi_battery_update (battery);switch (psp) {case POWER_SUPPLY_PROP_STATUS :if (battery->state &0x01 )@@ -457,6 +458,7 @@ static void sysfs_remove_battery(struct acpi_battery *battery)return ;device_remove_file (battery->bat.dev, &alarm_attr);power_supply_unregister (&battery->bat); + battery->bat.dev =NULL ; }static int acpi_battery_update (struct acpi_battery *battery) -
Quoted 11 lines · Rafael J. Wysocki
Quoted 7 lines · Alexey Starikovskiy
get_property()should not callbattery_update(),
it also should callget_status()only if battery is present to avoid cycle and oops.Signed-off-by Alexey Starikovskiy <[email protected]>Tested-by Rolf Eike Beer <[email protected]>Acked-by Johannes Weiner <[email protected]>It looks like this patch has been merged as commit
9104476e4efbef8a8e32d48ced583603ff32a2db
Yes, I noticed.
Thanks,
Alex.