aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorJeremy Erickson <jerickso@cs.unc.edu>2014-04-18 17:06:00 -0400
committerJeremy Erickson <jerickso@cs.unc.edu>2014-04-18 17:06:00 -0400
commita215aa7b9ab3759c047201199fba64d3042d7f13 (patch)
treebca37493d9b2233450e6d3ffced1261d0e4f71fe /drivers/power
parentd31199a77ef606f1d06894385f1852181ba6136b (diff)
Update 2.6.36 to 2.6.36.4wip-dissipation2-jerickso
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/ds2760_battery.c2
-rw-r--r--drivers/power/jz4740-battery.c7
-rw-r--r--drivers/power/olpc_battery.c8
3 files changed, 12 insertions, 5 deletions
diff --git a/drivers/power/ds2760_battery.c b/drivers/power/ds2760_battery.c
index 4d3b27228a2e..c8d26df9f145 100644
--- a/drivers/power/ds2760_battery.c
+++ b/drivers/power/ds2760_battery.c
@@ -212,7 +212,7 @@ static int ds2760_battery_read_status(struct ds2760_device_info *di)
212 if (di->rem_capacity > 100) 212 if (di->rem_capacity > 100)
213 di->rem_capacity = 100; 213 di->rem_capacity = 100;
214 214
215 if (di->current_uA >= 100L) 215 if (di->current_uA < -100L)
216 di->life_sec = -((di->accum_current_uAh - di->empty_uAh) * 36L) 216 di->life_sec = -((di->accum_current_uAh - di->empty_uAh) * 36L)
217 / (di->current_uA / 100L); 217 / (di->current_uA / 100L);
218 else 218 else
diff --git a/drivers/power/jz4740-battery.c b/drivers/power/jz4740-battery.c
index 20c4b952e9bd..a74cb0ac3d48 100644
--- a/drivers/power/jz4740-battery.c
+++ b/drivers/power/jz4740-battery.c
@@ -47,6 +47,8 @@ struct jz_battery {
47 47
48 struct power_supply battery; 48 struct power_supply battery;
49 struct delayed_work work; 49 struct delayed_work work;
50
51 struct mutex lock;
50}; 52};
51 53
52static inline struct jz_battery *psy_to_jz_battery(struct power_supply *psy) 54static 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)
68 unsigned long val; 70 unsigned long val;
69 long voltage; 71 long voltage;
70 72
73 mutex_lock(&battery->lock);
74
71 INIT_COMPLETION(battery->read_completion); 75 INIT_COMPLETION(battery->read_completion);
72 76
73 enable_irq(battery->irq); 77 enable_irq(battery->irq);
@@ -91,6 +95,8 @@ static long jz_battery_read_voltage(struct jz_battery *battery)
91 battery->cell->disable(battery->pdev); 95 battery->cell->disable(battery->pdev);
92 disable_irq(battery->irq); 96 disable_irq(battery->irq);
93 97
98 mutex_unlock(&battery->lock);
99
94 return voltage; 100 return voltage;
95} 101}
96 102
@@ -291,6 +297,7 @@ static int __devinit jz_battery_probe(struct platform_device *pdev)
291 jz_battery->pdev = pdev; 297 jz_battery->pdev = pdev;
292 298
293 init_completion(&jz_battery->read_completion); 299 init_completion(&jz_battery->read_completion);
300 mutex_init(&jz_battery->lock);
294 301
295 INIT_DELAYED_WORK(&jz_battery->work, jz_battery_work); 302 INIT_DELAYED_WORK(&jz_battery->work, jz_battery_work);
296 303
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index aafc1c506eda..5bc1dcf7785e 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
@@ -271,14 +271,14 @@ static int olpc_bat_get_property(struct power_supply *psy,
271 if (ret) 271 if (ret)
272 return ret; 272 return ret;
273 273
274 val->intval = (int)be16_to_cpu(ec_word) * 9760L / 32; 274 val->intval = (s16)be16_to_cpu(ec_word) * 9760L / 32;
275 break; 275 break;
276 case POWER_SUPPLY_PROP_CURRENT_AVG: 276 case POWER_SUPPLY_PROP_CURRENT_AVG:
277 ret = olpc_ec_cmd(EC_BAT_CURRENT, NULL, 0, (void *)&ec_word, 2); 277 ret = olpc_ec_cmd(EC_BAT_CURRENT, NULL, 0, (void *)&ec_word, 2);
278 if (ret) 278 if (ret)
279 return ret; 279 return ret;
280 280
281 val->intval = (int)be16_to_cpu(ec_word) * 15625L / 120; 281 val->intval = (s16)be16_to_cpu(ec_word) * 15625L / 120;
282 break; 282 break;
283 case POWER_SUPPLY_PROP_CAPACITY: 283 case POWER_SUPPLY_PROP_CAPACITY:
284 ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &ec_byte, 1); 284 ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &ec_byte, 1);
@@ -299,7 +299,7 @@ static int olpc_bat_get_property(struct power_supply *psy,
299 if (ret) 299 if (ret)
300 return ret; 300 return ret;
301 301
302 val->intval = (int)be16_to_cpu(ec_word) * 100 / 256; 302 val->intval = (s16)be16_to_cpu(ec_word) * 100 / 256;
303 break; 303 break;
304 case POWER_SUPPLY_PROP_TEMP_AMBIENT: 304 case POWER_SUPPLY_PROP_TEMP_AMBIENT:
305 ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2); 305 ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2);
@@ -313,7 +313,7 @@ static int olpc_bat_get_property(struct power_supply *psy,
313 if (ret) 313 if (ret)
314 return ret; 314 return ret;
315 315
316 val->intval = (int)be16_to_cpu(ec_word) * 6250 / 15; 316 val->intval = (s16)be16_to_cpu(ec_word) * 6250 / 15;
317 break; 317 break;
318 case POWER_SUPPLY_PROP_SERIAL_NUMBER: 318 case POWER_SUPPLY_PROP_SERIAL_NUMBER:
319 ret = olpc_ec_cmd(EC_BAT_SERIAL, NULL, 0, (void *)&ser_buf, 8); 319 ret = olpc_ec_cmd(EC_BAT_SERIAL, NULL, 0, (void *)&ser_buf, 8);