aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/acpi/battery.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 2f4521a48fe7..0d7a32e502d1 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -324,6 +324,13 @@ static int acpi_battery_check(struct acpi_battery *battery)
324 return result; 324 return result;
325} 325}
326 326
327static void acpi_battery_check_present(struct acpi_battery *battery)
328{
329 if (!battery->flags.present) {
330 acpi_battery_check(battery);
331 }
332}
333
327/* -------------------------------------------------------------------------- 334/* --------------------------------------------------------------------------
328 FS Interface (/proc) 335 FS Interface (/proc)
329 -------------------------------------------------------------------------- */ 336 -------------------------------------------------------------------------- */
@@ -340,6 +347,8 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
340 if (!battery) 347 if (!battery)
341 goto end; 348 goto end;
342 349
350 acpi_battery_check_present(battery);
351
343 if (battery->flags.present) 352 if (battery->flags.present)
344 seq_printf(seq, "present: yes\n"); 353 seq_printf(seq, "present: yes\n");
345 else { 354 else {
@@ -424,6 +433,8 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
424 if (!battery) 433 if (!battery)
425 goto end; 434 goto end;
426 435
436 acpi_battery_check_present(battery);
437
427 if (battery->flags.present) 438 if (battery->flags.present)
428 seq_printf(seq, "present: yes\n"); 439 seq_printf(seq, "present: yes\n");
429 else { 440 else {
@@ -499,6 +510,8 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
499 if (!battery) 510 if (!battery)
500 goto end; 511 goto end;
501 512
513 acpi_battery_check_present(battery);
514
502 if (!battery->flags.present) { 515 if (!battery->flags.present) {
503 seq_printf(seq, "present: no\n"); 516 seq_printf(seq, "present: no\n");
504 goto end; 517 goto end;
@@ -536,6 +549,8 @@ acpi_battery_write_alarm(struct file *file,
536 if (!battery || (count > sizeof(alarm_string) - 1)) 549 if (!battery || (count > sizeof(alarm_string) - 1))
537 return -EINVAL; 550 return -EINVAL;
538 551
552 acpi_battery_check_present(battery);
553
539 if (!battery->flags.present) 554 if (!battery->flags.present)
540 return -ENODEV; 555 return -ENODEV;
541 556