Skip to content

Commit 01e11d1

Browse files
Dan Carpenterrafaeljw
authored andcommitted
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: db1c291 ("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>
1 parent 6146a0f commit 01e11d1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/acpi/sbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ static int acpi_battery_read(struct acpi_battery *battery)
487487
if (result)
488488
return result;
489489

490-
battery->present = state & (1 << battery->id);
490+
battery->present = !!(state & (1 << battery->id));
491491
if (!battery->present)
492492
return 0;
493493

0 commit comments

Comments
 (0)