power: ds2780_battery: clean up eeprom read/write functions
authorVladimir Zapolskiy <vz@mleia.com>
Sun, 26 Jul 2015 21:26:47 +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 checks while
reading or writing "param_eeprom" or "user_eeprom", the checks are not
needed, since this task is done on caller side in fs/sysfs/file.c

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

index a7a0427343f3ef563fd9d6264165e27edf1e0ef2..d3743d0ad55bdcb5af7db6cc41b728b994f1840e 100644 (file)
@@ -637,10 +637,6 @@ static ssize_t ds2780_read_param_eeprom_bin(struct file *filp,
        struct power_supply *psy = to_power_supply(dev);
        struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
 
-       count = min_t(loff_t, count,
-               DS2780_EEPROM_BLOCK1_END -
-               DS2780_EEPROM_BLOCK1_START + 1 - off);
-
        return ds2780_read_block(dev_info, buf,
                                DS2780_EEPROM_BLOCK1_START + off, count);
 }
@@ -655,10 +651,6 @@ static ssize_t ds2780_write_param_eeprom_bin(struct file *filp,
        struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
        int ret;
 
-       count = min_t(loff_t, count,
-               DS2780_EEPROM_BLOCK1_END -
-               DS2780_EEPROM_BLOCK1_START + 1 - off);
-
        ret = ds2780_write(dev_info, buf,
                                DS2780_EEPROM_BLOCK1_START + off, count);
        if (ret < 0)
@@ -676,7 +668,7 @@ static struct bin_attribute ds2780_param_eeprom_bin_attr = {
                .name = "param_eeprom",
                .mode = S_IRUGO | S_IWUSR,
        },
-       .size = DS2780_EEPROM_BLOCK1_END - DS2780_EEPROM_BLOCK1_START + 1,
+       .size = DS2780_PARAM_EEPROM_SIZE,
        .read = ds2780_read_param_eeprom_bin,
        .write = ds2780_write_param_eeprom_bin,
 };
@@ -690,10 +682,6 @@ static ssize_t ds2780_read_user_eeprom_bin(struct file *filp,
        struct power_supply *psy = to_power_supply(dev);
        struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
 
-       count = min_t(loff_t, count,
-               DS2780_EEPROM_BLOCK0_END -
-               DS2780_EEPROM_BLOCK0_START + 1 - off);
-
        return ds2780_read_block(dev_info, buf,
                                DS2780_EEPROM_BLOCK0_START + off, count);
 }
@@ -708,10 +696,6 @@ static ssize_t ds2780_write_user_eeprom_bin(struct file *filp,
        struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
        int ret;
 
-       count = min_t(loff_t, count,
-               DS2780_EEPROM_BLOCK0_END -
-               DS2780_EEPROM_BLOCK0_START + 1 - off);
-
        ret = ds2780_write(dev_info, buf,
                                DS2780_EEPROM_BLOCK0_START + off, count);
        if (ret < 0)
@@ -729,7 +713,7 @@ static struct bin_attribute ds2780_user_eeprom_bin_attr = {
                .name = "user_eeprom",
                .mode = S_IRUGO | S_IWUSR,
        },
-       .size = DS2780_EEPROM_BLOCK0_END - DS2780_EEPROM_BLOCK0_START + 1,
+       .size = DS2780_USER_EEPROM_SIZE,
        .read = ds2780_read_user_eeprom_bin,
        .write = ds2780_write_user_eeprom_bin,
 };