power: olpc_battery: clean up eeprom read function
authorVladimir Zapolskiy <vz@mleia.com>
Sun, 26 Jul 2015 21:26:49 +0000 (00:26 +0300)
committerSebastian Reichel <sre@kernel.org>
Mon, 27 Jul 2015 14:28:54 +0000 (16:28 +0200)
The change removes redundant sysfs binary file boundary check while
reading eeprom content from userspace, the check is done on caller
side in fs/sysfs/file.c, if binary attribute size is not zero.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
drivers/power/olpc_battery.c

index a944338a39de406d80d932c31babebbb50731318..9e29b1321648d12bf55cbc6f423be199826bf4d2 100644 (file)
@@ -521,11 +521,6 @@ static ssize_t olpc_bat_eeprom_read(struct file *filp, struct kobject *kobj,
        int ret;
        int i;
 
-       if (off >= EEPROM_SIZE)
-               return 0;
-       if (off + count > EEPROM_SIZE)
-               count = EEPROM_SIZE - off;
-
        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);
@@ -545,7 +540,7 @@ static struct bin_attribute olpc_bat_eeprom = {
                .name = "eeprom",
                .mode = S_IRUGO,
        },
-       .size = 0,
+       .size = EEPROM_SIZE,
        .read = olpc_bat_eeprom_read,
 };