aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristoffer Ericson <kristoffer.ericson@gmail.com>2010-10-26 20:45:33 +0200
committerKristoffer Ericson <kristoffer.ericson@gmail.com>2011-12-10 15:53:14 +0100
commit5613aee50952f0c84c7cdd2ef0a8056d2ba2644f (patch)
tree6bc4c06eb0b193b6561926ee1725a80dcf830f30
parent97789eaf5bbb603eb87b578e49c7222ccf330a87 (diff)
downloadlinux-hpc-5613aee50952f0c84c7cdd2ef0a8056d2ba2644f.tar.gz
drivers/power/jz4740-battery.c: Apply battery patch that blizzard suggested (patch by larsc)
-rw-r--r--drivers/power/jz4740-battery.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/power/jz4740-battery.c b/drivers/power/jz4740-battery.c
index 20c4b952e9bd1f..a74cb0ac3d4892 100644
--- a/drivers/power/jz4740-battery.c
+++ b/drivers/power/jz4740-battery.c
@@ -47,6 +47,8 @@ struct jz_battery {
struct power_supply battery;
struct delayed_work work;
+
+ struct mutex lock;
};
static inline struct jz_battery *psy_to_jz_battery(struct power_supply *psy)
@@ -68,6 +70,8 @@ static long jz_battery_read_voltage(struct jz_battery *battery)
unsigned long val;
long voltage;
+ mutex_lock(&battery->lock);
+
INIT_COMPLETION(battery->read_completion);
enable_irq(battery->irq);
@@ -91,6 +95,8 @@ static long jz_battery_read_voltage(struct jz_battery *battery)
battery->cell->disable(battery->pdev);
disable_irq(battery->irq);
+ mutex_unlock(&battery->lock);
+
return voltage;
}
@@ -291,6 +297,7 @@ static int __devinit jz_battery_probe(struct platform_device *pdev)
jz_battery->pdev = pdev;
init_completion(&jz_battery->read_completion);
+ mutex_init(&jz_battery->lock);
INIT_DELAYED_WORK(&jz_battery->work, jz_battery_work);