]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/acpi/battery.c
Pull bugzilla-7200 into release branch
[linux-2.6.git] / drivers / acpi / battery.c
index 02de49ef1bcee80829077e39e340c414cb3dc297..e64c76c8b7268a56562969d48b6c940bbda09bfc 100644 (file)
@@ -323,6 +323,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)
    -------------------------------------------------------------------------- */
@@ -339,6 +346,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 {
@@ -423,6 +432,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 {
@@ -498,6 +509,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;
@@ -535,6 +548,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;