cns21xx: switch to 3.2.9
[openwrt.git] / target / linux / xburst / patches-2.6.36 / 300-battery-fixes.patch
1 From 2d435d52c63e4dd544938bad638ecd518cc04d1c Mon Sep 17 00:00:00 2001
2 From: Lars-Peter Clausen <lars@metafoo.de>
3 Date: Tue, 26 Oct 2010 20:13:40 +0200
4 Subject: [PATCH] POWER: jz4740-battery: Protect against concurrent battery readings
5
6 We can not handle more then one ADC request at a time to the battery. The patch
7 adds a mutex around the ADC read code to ensure this.
8
9 Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
10
11 jz4740-battery: Add missing kfree(jz_battery) in jz_battery_remove()
12
13 Signed-off-by: Axel Lin <axel.lin@gmail.com>
14 Acked-By: Lars-Peter Clausen <lars@metafoo.de>
15 Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
16 ---
17 drivers/power/jz4740-battery.c | 8 ++++++++
18 1 files changed, 8 insertions(+), 0 deletions(-)
19
20 --- a/drivers/power/jz4740-battery.c
21 +++ b/drivers/power/jz4740-battery.c
22 @@ -47,6 +47,8 @@ struct jz_battery {
23
24 struct power_supply battery;
25 struct delayed_work work;
26 +
27 + struct mutex lock;
28 };
29
30 static inline struct jz_battery *psy_to_jz_battery(struct power_supply *psy)
31 @@ -68,6 +70,8 @@ static long jz_battery_read_voltage(stru
32 unsigned long val;
33 long voltage;
34
35 + mutex_lock(&battery->lock);
36 +
37 INIT_COMPLETION(battery->read_completion);
38
39 enable_irq(battery->irq);
40 @@ -91,6 +95,8 @@ static long jz_battery_read_voltage(stru
41 battery->cell->disable(battery->pdev);
42 disable_irq(battery->irq);
43
44 + mutex_unlock(&battery->lock);
45 +
46 return voltage;
47 }
48
49 @@ -291,6 +297,7 @@ static int __devinit jz_battery_probe(st
50 jz_battery->pdev = pdev;
51
52 init_completion(&jz_battery->read_completion);
53 + mutex_init(&jz_battery->lock);
54
55 INIT_DELAYED_WORK(&jz_battery->work, jz_battery_work);
56
57 @@ -383,6 +390,7 @@ static int __devexit jz_battery_remove(s
58
59 iounmap(jz_battery->base);
60 release_mem_region(jz_battery->mem->start, resource_size(jz_battery->mem));
61 + kfree(jz_battery);
62
63 return 0;
64 }
This page took 0.043964 seconds and 5 git commands to generate.