Skip to content

Commit

Permalink
ACPI: battery: check for battery present on /proc/battery access
Browse files Browse the repository at this point in the history
http://bugzilla.kernel.org/show_bug.cgi?id=7200

Signed-off-by: Vladimir Lebedev <vladimir.p.lebedev@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Vladimir Lebedev authored and Len Brown committed Feb 10, 2007
1 parent eaefd5f commit 4bd35cd
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions drivers/acpi/battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,13 @@ static int acpi_battery_check(struct acpi_battery *battery)
return result;
}

static void acpi_battery_check_present(struct acpi_battery *battery)
{
if (!battery->flags.present) {
acpi_battery_check(battery);
}
}

/* --------------------------------------------------------------------------
FS Interface (/proc)
-------------------------------------------------------------------------- */
Expand All @@ -340,6 +347,8 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
if (!battery)
goto end;

acpi_battery_check_present(battery);

if (battery->flags.present)
seq_printf(seq, "present: yes\n");
else {
Expand Down Expand Up @@ -424,6 +433,8 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
if (!battery)
goto end;

acpi_battery_check_present(battery);

if (battery->flags.present)
seq_printf(seq, "present: yes\n");
else {
Expand Down Expand Up @@ -499,6 +510,8 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
if (!battery)
goto end;

acpi_battery_check_present(battery);

if (!battery->flags.present) {
seq_printf(seq, "present: no\n");
goto end;
Expand Down Expand Up @@ -536,6 +549,8 @@ acpi_battery_write_alarm(struct file *file,
if (!battery || (count > sizeof(alarm_string) - 1))
return -EINVAL;

acpi_battery_check_present(battery);

if (!battery->flags.present)
return -ENODEV;

Expand Down

0 comments on commit 4bd35cd

Please sign in to comment.