mirror of https://github.com/torvalds/linux.git
ACPI: SBS: Fix present test in acpi_battery_read()
The battery->present variable is a 1 bit bitfield in a u8. This means
that the "state & (1 << battery->id)" test will only work when
"battery->id" is zero, otherwise ->present is zero. Fix this by adding
a !!.
Fixes: db1c291af7 ("ACPI: SBS: Make SBS reads table-driven.")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/aQSzr4NynN2mpEvG@stanley.mountain
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
6146a0f1df
commit
01e11d18da
|
|
@ -487,7 +487,7 @@ static int acpi_battery_read(struct acpi_battery *battery)
|
|||
if (result)
|
||||
return result;
|
||||
|
||||
battery->present = state & (1 << battery->id);
|
||||
battery->present = !!(state & (1 << battery->id));
|
||||
if (!battery->present)
|
||||
return 0;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue