bq27x00 could return abnormal data when bq27x00_read called by multiple processes at the same time,
when applications access capacity, voltage and temperature frequently.�
to make sure that not running bq27x00_read before previous return, add battery_lock to avoid this:
--- bq27x00_battery.c.orig � � �2011-11-17 09:53:51.564690000 +0800
+++ bq27x00_battery.c � 2011-11-17 10:00:26.768690000 +0800
@@ -129,10 +129,19 @@
��* Common code for BQ27x00 devices
��*/
-static inline int bq27x00_read(struct bq27x00_device_info *di, u8 reg,
+/* To avoid running multiple bq27x00_read return with abnormal data,
+ � add battery_lock mutex. --H.Z
+*/
+static DEFINE_MUTEX(battery_lock);
+
+static int bq27x00_read(struct bq27x00_device_info *di, u8 reg,
�� � � � � � � �bool single)
�{
- � � � return di->bus.read(di, reg, single);
+ � � � int ret;
+ � � � mutex_lock(&battery_lock);
+ � � � ret = di->bus.read(di, reg, single);
+ � � � mutex_unlock(&battery_lock);
+ � � � return ret;
�}
_______________________________________________ linux-pm mailing list linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linuxfoundation.org/mailman/listinfo/linux-pm