ACPI: battery: check for battery present on /proc/battery access
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>
This commit is contained in:
parent
eaefd5fb7d
commit
4bd35cdb1e
1 changed files with 15 additions and 0 deletions
|
@ -324,6 +324,13 @@ static int acpi_battery_check(struct acpi_battery *battery)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void acpi_battery_check_present(struct acpi_battery *battery)
|
||||||
|
{
|
||||||
|
if (!battery->flags.present) {
|
||||||
|
acpi_battery_check(battery);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
FS Interface (/proc)
|
FS Interface (/proc)
|
||||||
-------------------------------------------------------------------------- */
|
-------------------------------------------------------------------------- */
|
||||||
|
@ -340,6 +347,8 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
|
||||||
if (!battery)
|
if (!battery)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
acpi_battery_check_present(battery);
|
||||||
|
|
||||||
if (battery->flags.present)
|
if (battery->flags.present)
|
||||||
seq_printf(seq, "present: yes\n");
|
seq_printf(seq, "present: yes\n");
|
||||||
else {
|
else {
|
||||||
|
@ -424,6 +433,8 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
|
||||||
if (!battery)
|
if (!battery)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
acpi_battery_check_present(battery);
|
||||||
|
|
||||||
if (battery->flags.present)
|
if (battery->flags.present)
|
||||||
seq_printf(seq, "present: yes\n");
|
seq_printf(seq, "present: yes\n");
|
||||||
else {
|
else {
|
||||||
|
@ -499,6 +510,8 @@ static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
|
||||||
if (!battery)
|
if (!battery)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
|
acpi_battery_check_present(battery);
|
||||||
|
|
||||||
if (!battery->flags.present) {
|
if (!battery->flags.present) {
|
||||||
seq_printf(seq, "present: no\n");
|
seq_printf(seq, "present: no\n");
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -536,6 +549,8 @@ acpi_battery_write_alarm(struct file *file,
|
||||||
if (!battery || (count > sizeof(alarm_string) - 1))
|
if (!battery || (count > sizeof(alarm_string) - 1))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
acpi_battery_check_present(battery);
|
||||||
|
|
||||||
if (!battery->flags.present)
|
if (!battery->flags.present)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue