mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
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:
committed by
Rafael J. Wysocki
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user