diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-03-17 03:37:31 -0400 |
---|---|---|
committer | Anton Vorontsov <anton.vorontsov@linaro.org> | 2012-05-05 22:58:41 -0400 |
commit | 13f2483cd5e3df425cfa492cc62cf8fada5d01b9 (patch) | |
tree | bff2db8cb3f38c315bd1589631cc3c0706542cfe /drivers/power/ds2781_battery.c | |
parent | 840b91bda91ebaa6230caec0ccf005daf9305fb6 (diff) |
ds2781_battery: Use DS2781_PARAM_EEPROM_SIZE and DS2781_USER_EEPROM_SIZE
Since we have defined DS2781_PARAM_EEPROM_SIZE and
DS2781_USER_EEPROM_SIZE, use them to simplify the code.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Diffstat (limited to 'drivers/power/ds2781_battery.c')
-rw-r--r-- | drivers/power/ds2781_battery.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/drivers/power/ds2781_battery.c b/drivers/power/ds2781_battery.c index ca0d653d0a7a..975684a40f15 100644 --- a/drivers/power/ds2781_battery.c +++ b/drivers/power/ds2781_battery.c | |||
@@ -643,9 +643,7 @@ static ssize_t ds2781_read_param_eeprom_bin(struct file *filp, | |||
643 | struct power_supply *psy = to_power_supply(dev); | 643 | struct power_supply *psy = to_power_supply(dev); |
644 | struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); | 644 | struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); |
645 | 645 | ||
646 | count = min_t(loff_t, count, | 646 | count = min_t(loff_t, count, DS2781_PARAM_EEPROM_SIZE - off); |
647 | DS2781_EEPROM_BLOCK1_END - | ||
648 | DS2781_EEPROM_BLOCK1_START + 1 - off); | ||
649 | 647 | ||
650 | return ds2781_read_block(dev_info, buf, | 648 | return ds2781_read_block(dev_info, buf, |
651 | DS2781_EEPROM_BLOCK1_START + off, count); | 649 | DS2781_EEPROM_BLOCK1_START + off, count); |
@@ -661,9 +659,7 @@ static ssize_t ds2781_write_param_eeprom_bin(struct file *filp, | |||
661 | struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); | 659 | struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); |
662 | int ret; | 660 | int ret; |
663 | 661 | ||
664 | count = min_t(loff_t, count, | 662 | count = min_t(loff_t, count, DS2781_PARAM_EEPROM_SIZE - off); |
665 | DS2781_EEPROM_BLOCK1_END - | ||
666 | DS2781_EEPROM_BLOCK1_START + 1 - off); | ||
667 | 663 | ||
668 | ret = ds2781_write(dev_info, buf, | 664 | ret = ds2781_write(dev_info, buf, |
669 | DS2781_EEPROM_BLOCK1_START + off, count); | 665 | DS2781_EEPROM_BLOCK1_START + off, count); |
@@ -682,7 +678,7 @@ static struct bin_attribute ds2781_param_eeprom_bin_attr = { | |||
682 | .name = "param_eeprom", | 678 | .name = "param_eeprom", |
683 | .mode = S_IRUGO | S_IWUSR, | 679 | .mode = S_IRUGO | S_IWUSR, |
684 | }, | 680 | }, |
685 | .size = DS2781_EEPROM_BLOCK1_END - DS2781_EEPROM_BLOCK1_START + 1, | 681 | .size = DS2781_PARAM_EEPROM_SIZE, |
686 | .read = ds2781_read_param_eeprom_bin, | 682 | .read = ds2781_read_param_eeprom_bin, |
687 | .write = ds2781_write_param_eeprom_bin, | 683 | .write = ds2781_write_param_eeprom_bin, |
688 | }; | 684 | }; |
@@ -696,9 +692,7 @@ static ssize_t ds2781_read_user_eeprom_bin(struct file *filp, | |||
696 | struct power_supply *psy = to_power_supply(dev); | 692 | struct power_supply *psy = to_power_supply(dev); |
697 | struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); | 693 | struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); |
698 | 694 | ||
699 | count = min_t(loff_t, count, | 695 | count = min_t(loff_t, count, DS2781_USER_EEPROM_SIZE - off); |
700 | DS2781_EEPROM_BLOCK0_END - | ||
701 | DS2781_EEPROM_BLOCK0_START + 1 - off); | ||
702 | 696 | ||
703 | return ds2781_read_block(dev_info, buf, | 697 | return ds2781_read_block(dev_info, buf, |
704 | DS2781_EEPROM_BLOCK0_START + off, count); | 698 | DS2781_EEPROM_BLOCK0_START + off, count); |
@@ -715,9 +709,7 @@ static ssize_t ds2781_write_user_eeprom_bin(struct file *filp, | |||
715 | struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); | 709 | struct ds2781_device_info *dev_info = to_ds2781_device_info(psy); |
716 | int ret; | 710 | int ret; |
717 | 711 | ||
718 | count = min_t(loff_t, count, | 712 | count = min_t(loff_t, count, DS2781_USER_EEPROM_SIZE - off); |
719 | DS2781_EEPROM_BLOCK0_END - | ||
720 | DS2781_EEPROM_BLOCK0_START + 1 - off); | ||
721 | 713 | ||
722 | ret = ds2781_write(dev_info, buf, | 714 | ret = ds2781_write(dev_info, buf, |
723 | DS2781_EEPROM_BLOCK0_START + off, count); | 715 | DS2781_EEPROM_BLOCK0_START + off, count); |
@@ -736,7 +728,7 @@ static struct bin_attribute ds2781_user_eeprom_bin_attr = { | |||
736 | .name = "user_eeprom", | 728 | .name = "user_eeprom", |
737 | .mode = S_IRUGO | S_IWUSR, | 729 | .mode = S_IRUGO | S_IWUSR, |
738 | }, | 730 | }, |
739 | .size = DS2781_EEPROM_BLOCK0_END - DS2781_EEPROM_BLOCK0_START + 1, | 731 | .size = DS2781_USER_EEPROM_SIZE, |
740 | .read = ds2781_read_user_eeprom_bin, | 732 | .read = ds2781_read_user_eeprom_bin, |
741 | .write = ds2781_write_user_eeprom_bin, | 733 | .write = ds2781_write_user_eeprom_bin, |
742 | }; | 734 | }; |