diff options
Diffstat (limited to 'drivers/power/olpc_battery.c')
-rw-r--r-- | drivers/power/olpc_battery.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c index 5fbca2681baa..9c216dd41550 100644 --- a/drivers/power/olpc_battery.c +++ b/drivers/power/olpc_battery.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * published by the Free Software Foundation. | 8 | * published by the Free Software Foundation. |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/kernel.h> | ||
11 | #include <linux/module.h> | 12 | #include <linux/module.h> |
12 | #include <linux/err.h> | 13 | #include <linux/err.h> |
13 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
@@ -334,21 +335,21 @@ static ssize_t olpc_bat_eeprom_read(struct kobject *kobj, | |||
334 | struct bin_attribute *attr, char *buf, loff_t off, size_t count) | 335 | struct bin_attribute *attr, char *buf, loff_t off, size_t count) |
335 | { | 336 | { |
336 | uint8_t ec_byte; | 337 | uint8_t ec_byte; |
337 | int ret, end; | 338 | int ret; |
339 | int i; | ||
338 | 340 | ||
339 | if (off >= EEPROM_SIZE) | 341 | if (off >= EEPROM_SIZE) |
340 | return 0; | 342 | return 0; |
341 | if (off + count > EEPROM_SIZE) | 343 | if (off + count > EEPROM_SIZE) |
342 | count = EEPROM_SIZE - off; | 344 | count = EEPROM_SIZE - off; |
343 | 345 | ||
344 | end = EEPROM_START + off + count; | 346 | for (i = 0; i < count; i++) { |
345 | for (ec_byte = EEPROM_START + off; ec_byte < end; ec_byte++) { | 347 | ec_byte = EEPROM_START + off + i; |
346 | ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, | 348 | ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &buf[i], 1); |
347 | &buf[ec_byte - EEPROM_START], 1); | ||
348 | if (ret) { | 349 | if (ret) { |
349 | printk(KERN_ERR "olpc-battery: EC command " | 350 | pr_err("olpc-battery: " |
350 | "EC_BAT_EEPROM @ 0x%x failed -" | 351 | "EC_BAT_EEPROM cmd @ 0x%x failed - %d!\n", |
351 | " %d!\n", ec_byte, ret); | 352 | ec_byte, ret); |
352 | return -EIO; | 353 | return -EIO; |
353 | } | 354 | } |
354 | } | 355 | } |