aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/power/olpc_battery.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index 32570af3c5c9..5fbca2681baa 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
@@ -205,9 +205,9 @@ static int olpc_bat_get_property(struct power_supply *psy,
205 union power_supply_propval *val) 205 union power_supply_propval *val)
206{ 206{
207 int ret = 0; 207 int ret = 0;
208 int16_t ec_word; 208 __be16 ec_word;
209 uint8_t ec_byte; 209 uint8_t ec_byte;
210 uint64_t ser_buf; 210 __be64 ser_buf;
211 211
212 ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &ec_byte, 1); 212 ret = olpc_ec_cmd(EC_BAT_STATUS, NULL, 0, &ec_byte, 1);
213 if (ret) 213 if (ret)
@@ -257,16 +257,14 @@ static int olpc_bat_get_property(struct power_supply *psy,
257 if (ret) 257 if (ret)
258 return ret; 258 return ret;
259 259
260 ec_word = be16_to_cpu(ec_word); 260 val->intval = (int)be16_to_cpu(ec_word) * 9760L / 32;
261 val->intval = ec_word * 9760L / 32;
262 break; 261 break;
263 case POWER_SUPPLY_PROP_CURRENT_AVG: 262 case POWER_SUPPLY_PROP_CURRENT_AVG:
264 ret = olpc_ec_cmd(EC_BAT_CURRENT, NULL, 0, (void *)&ec_word, 2); 263 ret = olpc_ec_cmd(EC_BAT_CURRENT, NULL, 0, (void *)&ec_word, 2);
265 if (ret) 264 if (ret)
266 return ret; 265 return ret;
267 266
268 ec_word = be16_to_cpu(ec_word); 267 val->intval = (int)be16_to_cpu(ec_word) * 15625L / 120;
269 val->intval = ec_word * 15625L / 120;
270 break; 268 break;
271 case POWER_SUPPLY_PROP_CAPACITY: 269 case POWER_SUPPLY_PROP_CAPACITY:
272 ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &ec_byte, 1); 270 ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &ec_byte, 1);
@@ -278,24 +276,22 @@ static int olpc_bat_get_property(struct power_supply *psy,
278 ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2); 276 ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2);
279 if (ret) 277 if (ret)
280 return ret; 278 return ret;
281 ec_word = be16_to_cpu(ec_word); 279
282 val->intval = ec_word * 100 / 256; 280 val->intval = (int)be16_to_cpu(ec_word) * 100 / 256;
283 break; 281 break;
284 case POWER_SUPPLY_PROP_TEMP_AMBIENT: 282 case POWER_SUPPLY_PROP_TEMP_AMBIENT:
285 ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2); 283 ret = olpc_ec_cmd(EC_AMB_TEMP, NULL, 0, (void *)&ec_word, 2);
286 if (ret) 284 if (ret)
287 return ret; 285 return ret;
288 286
289 ec_word = be16_to_cpu(ec_word); 287 val->intval = (int)be16_to_cpu(ec_word) * 100 / 256;
290 val->intval = ec_word * 100 / 256;
291 break; 288 break;
292 case POWER_SUPPLY_PROP_CHARGE_COUNTER: 289 case POWER_SUPPLY_PROP_CHARGE_COUNTER:
293 ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2); 290 ret = olpc_ec_cmd(EC_BAT_ACR, NULL, 0, (void *)&ec_word, 2);
294 if (ret) 291 if (ret)
295 return ret; 292 return ret;
296 293
297 ec_word = be16_to_cpu(ec_word); 294 val->intval = (int)be16_to_cpu(ec_word) * 6250 / 15;
298 val->intval = ec_word * 6250 / 15;
299 break; 295 break;
300 case POWER_SUPPLY_PROP_SERIAL_NUMBER: 296 case POWER_SUPPLY_PROP_SERIAL_NUMBER:
301 ret = olpc_ec_cmd(EC_BAT_SERIAL, NULL, 0, (void *)&ser_buf, 8); 297 ret = olpc_ec_cmd(EC_BAT_SERIAL, NULL, 0, (void *)&ser_buf, 8);