summaryrefslogtreecommitdiffstats
path: root/drivers/power/olpc_battery.c
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@collabora.co.uk>2009-06-30 02:14:00 -0400
committerAnton Vorontsov <cbouatmailru@gmail.com>2009-07-01 02:36:38 +0400
commit04a820ead0838c76e9c1242feb5e71048bf3e9dc (patch)
treecbcc95a15782189403d3e632dcd0b1b13bdb9c82 /drivers/power/olpc_battery.c
parent5a4f13fad1ab5bd08dea78fc55321e429d83cddf (diff)
downloadtalos-op-linux-04a820ead0838c76e9c1242feb5e71048bf3e9dc.tar.gz
talos-op-linux-04a820ead0838c76e9c1242feb5e71048bf3e9dc.zip
olpc_battery: Fix up eeprom read function
The eeprom read function was placing values into the wrong place in 'buf'; we were starting from buf[off], rather than buf[0]. Also, the for loop that we were using was much uglier than it needed to be. This cleans it up a bit. Signed-off-by: Andres Salomon <dilinger@collabora.co.uk> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
Diffstat (limited to 'drivers/power/olpc_battery.c')
-rw-r--r--drivers/power/olpc_battery.c17
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 @@
* published by the Free Software Foundation.
*/
+#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/err.h>
#include <linux/platform_device.h>
@@ -334,21 +335,21 @@ static ssize_t olpc_bat_eeprom_read(struct kobject *kobj,
struct bin_attribute *attr, char *buf, loff_t off, size_t count)
{
uint8_t ec_byte;
- int ret, end;
+ int ret;
+ int i;
if (off >= EEPROM_SIZE)
return 0;
if (off + count > EEPROM_SIZE)
count = EEPROM_SIZE - off;
- end = EEPROM_START + off + count;
- for (ec_byte = EEPROM_START + off; ec_byte < end; ec_byte++) {
- ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1,
- &buf[ec_byte - EEPROM_START], 1);
+ for (i = 0; i < count; i++) {
+ ec_byte = EEPROM_START + off + i;
+ ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &buf[i], 1);
if (ret) {
- printk(KERN_ERR "olpc-battery: EC command "
- "EC_BAT_EEPROM @ 0x%x failed -"
- " %d!\n", ec_byte, ret);
+ pr_err("olpc-battery: "
+ "EC_BAT_EEPROM cmd @ 0x%x failed - %d!\n",
+ ec_byte, ret);
return -EIO;
}
}
OpenPOWER on IntegriCloud