CHROMIUM: power: sbs-battery: Prevent CAPACITY_MODE races

A subset of smart battery commands return charge or energy depending on
the CAPACITY_MODE bit setting of BatteryMode(). In order to
unambiguously read a charge or energy value, it is necessary to ensure
that CAPACITY_MODE is set as desired, and not changed for the duration
of the attribute read.

TEST=On kevin, spam reads to charge_full battery sysfs attribute while
performing suspend_stress_test, verify that the same value is always

Signed-off-by: Shawn Nematbakhsh <>
Change-Id: Ic39e8d7f982d7045a2da6bf6fe835c2c3434815c
Commit-Ready: Shawn N <>
Tested-by: Shawn N <>
Reviewed-by: Guenter Roeck <>
1 file changed