aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorVladimir Zapolskiy <vz@mleia.com>2015-07-26 17:26:47 -0400
committerSebastian Reichel <sre@kernel.org>2015-07-27 10:28:54 -0400
commit753f15833c4d782ee41e333f66bfe424a39680e6 (patch)
tree7cf7ea0529a7433639f9b9dcbef4fc6827962411 /drivers/power
parent71a5a508436332ac40f688ef06e61628f25f3e5b (diff)
power: ds2780_battery: clean up eeprom read/write functions
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>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/ds2780_battery.c20
1 files changed, 2 insertions, 18 deletions
diff --git a/drivers/power/ds2780_battery.c b/drivers/power/ds2780_battery.c
index a7a0427343f3..d3743d0ad55b 100644
--- a/drivers/power/ds2780_battery.c
+++ b/drivers/power/ds2780_battery.c
@@ -637,10 +637,6 @@ static ssize_t ds2780_read_param_eeprom_bin(struct file *filp,
637 struct power_supply *psy = to_power_supply(dev); 637 struct power_supply *psy = to_power_supply(dev);
638 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); 638 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
639 639
640 count = min_t(loff_t, count,
641 DS2780_EEPROM_BLOCK1_END -
642 DS2780_EEPROM_BLOCK1_START + 1 - off);
643
644 return ds2780_read_block(dev_info, buf, 640 return ds2780_read_block(dev_info, buf,
645 DS2780_EEPROM_BLOCK1_START + off, count); 641 DS2780_EEPROM_BLOCK1_START + off, count);
646} 642}
@@ -655,10 +651,6 @@ static ssize_t ds2780_write_param_eeprom_bin(struct file *filp,
655 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); 651 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
656 int ret; 652 int ret;
657 653
658 count = min_t(loff_t, count,
659 DS2780_EEPROM_BLOCK1_END -
660 DS2780_EEPROM_BLOCK1_START + 1 - off);
661
662 ret = ds2780_write(dev_info, buf, 654 ret = ds2780_write(dev_info, buf,
663 DS2780_EEPROM_BLOCK1_START + off, count); 655 DS2780_EEPROM_BLOCK1_START + off, count);
664 if (ret < 0) 656 if (ret < 0)
@@ -676,7 +668,7 @@ static struct bin_attribute ds2780_param_eeprom_bin_attr = {
676 .name = "param_eeprom", 668 .name = "param_eeprom",
677 .mode = S_IRUGO | S_IWUSR, 669 .mode = S_IRUGO | S_IWUSR,
678 }, 670 },
679 .size = DS2780_EEPROM_BLOCK1_END - DS2780_EEPROM_BLOCK1_START + 1, 671 .size = DS2780_PARAM_EEPROM_SIZE,
680 .read = ds2780_read_param_eeprom_bin, 672 .read = ds2780_read_param_eeprom_bin,
681 .write = ds2780_write_param_eeprom_bin, 673 .write = ds2780_write_param_eeprom_bin,
682}; 674};
@@ -690,10 +682,6 @@ static ssize_t ds2780_read_user_eeprom_bin(struct file *filp,
690 struct power_supply *psy = to_power_supply(dev); 682 struct power_supply *psy = to_power_supply(dev);
691 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); 683 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
692 684
693 count = min_t(loff_t, count,
694 DS2780_EEPROM_BLOCK0_END -
695 DS2780_EEPROM_BLOCK0_START + 1 - off);
696
697 return ds2780_read_block(dev_info, buf, 685 return ds2780_read_block(dev_info, buf,
698 DS2780_EEPROM_BLOCK0_START + off, count); 686 DS2780_EEPROM_BLOCK0_START + off, count);
699} 687}
@@ -708,10 +696,6 @@ static ssize_t ds2780_write_user_eeprom_bin(struct file *filp,
708 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy); 696 struct ds2780_device_info *dev_info = to_ds2780_device_info(psy);
709 int ret; 697 int ret;
710 698
711 count = min_t(loff_t, count,
712 DS2780_EEPROM_BLOCK0_END -
713 DS2780_EEPROM_BLOCK0_START + 1 - off);
714
715 ret = ds2780_write(dev_info, buf, 699 ret = ds2780_write(dev_info, buf,
716 DS2780_EEPROM_BLOCK0_START + off, count); 700 DS2780_EEPROM_BLOCK0_START + off, count);
717 if (ret < 0) 701 if (ret < 0)
@@ -729,7 +713,7 @@ static struct bin_attribute ds2780_user_eeprom_bin_attr = {
729 .name = "user_eeprom", 713 .name = "user_eeprom",
730 .mode = S_IRUGO | S_IWUSR, 714 .mode = S_IRUGO | S_IWUSR,
731 }, 715 },
732 .size = DS2780_EEPROM_BLOCK0_END - DS2780_EEPROM_BLOCK0_START + 1, 716 .size = DS2780_USER_EEPROM_SIZE,
733 .read = ds2780_read_user_eeprom_bin, 717 .read = ds2780_read_user_eeprom_bin,
734 .write = ds2780_write_user_eeprom_bin, 718 .write = ds2780_write_user_eeprom_bin,
735}; 719};