diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-04-09 11:35:10 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-10 06:04:26 -0400 |
commit | 268a164135b0635418ba703f77f4f654ea5abaec (patch) | |
tree | dc00030b6adda118b79b273736a3e2a09efe7cc5 /drivers/regulator/twl-regulator.c | |
parent | 5ade39358f0244a0672860766eed92e8c908b805 (diff) |
regulator: twl-regulator: Use DIV_ROUND_UP at appropriate places
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/twl-regulator.c')
-rw-r--r-- | drivers/regulator/twl-regulator.c | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 88bc32bc31a0..7384d277ef40 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c | |||
@@ -787,11 +787,7 @@ twl6030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, | |||
787 | vsel = 0; | 787 | vsel = 0; |
788 | else if ((min_uV >= 600000) && (min_uV <= 1300000)) { | 788 | else if ((min_uV >= 600000) && (min_uV <= 1300000)) { |
789 | int calc_uV; | 789 | int calc_uV; |
790 | vsel = (min_uV - 600000) / 125; | 790 | vsel = DIV_ROUND_UP(min_uV - 600000, 12500); |
791 | if (vsel % 100) | ||
792 | vsel += 100; | ||
793 | vsel /= 100; | ||
794 | vsel++; | ||
795 | calc_uV = twl6030smps_list_voltage(rdev, vsel); | 791 | calc_uV = twl6030smps_list_voltage(rdev, vsel); |
796 | if (calc_uV > max_uV) | 792 | if (calc_uV > max_uV) |
797 | return -EINVAL; | 793 | return -EINVAL; |
@@ -817,11 +813,7 @@ twl6030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, | |||
817 | vsel = 0; | 813 | vsel = 0; |
818 | else if ((min_uV >= 700000) && (min_uV <= 1420000)) { | 814 | else if ((min_uV >= 700000) && (min_uV <= 1420000)) { |
819 | int calc_uV; | 815 | int calc_uV; |
820 | vsel = (min_uV - 700000) / 125; | 816 | vsel = DIV_ROUND_UP(min_uV - 700000, 12500); |
821 | if (vsel % 100) | ||
822 | vsel += 100; | ||
823 | vsel /= 100; | ||
824 | vsel++; | ||
825 | calc_uV = twl6030smps_list_voltage(rdev, vsel); | 817 | calc_uV = twl6030smps_list_voltage(rdev, vsel); |
826 | if (calc_uV > max_uV) | 818 | if (calc_uV > max_uV) |
827 | return -EINVAL; | 819 | return -EINVAL; |
@@ -845,24 +837,14 @@ twl6030smps_set_voltage(struct regulator_dev *rdev, int min_uV, int max_uV, | |||
845 | case SMPS_EXTENDED_EN: | 837 | case SMPS_EXTENDED_EN: |
846 | if (min_uV == 0) | 838 | if (min_uV == 0) |
847 | vsel = 0; | 839 | vsel = 0; |
848 | else if ((min_uV >= 1852000) && (max_uV <= 4013600)) { | 840 | else if ((min_uV >= 1852000) && (max_uV <= 4013600)) |
849 | vsel = (min_uV - 1852000) / 386; | 841 | vsel = DIV_ROUND_UP(min_uV - 1852000, 38600); |
850 | if (vsel % 100) | ||
851 | vsel += 100; | ||
852 | vsel /= 100; | ||
853 | vsel++; | ||
854 | } | ||
855 | break; | 842 | break; |
856 | case SMPS_OFFSET_EN|SMPS_EXTENDED_EN: | 843 | case SMPS_OFFSET_EN|SMPS_EXTENDED_EN: |
857 | if (min_uV == 0) | 844 | if (min_uV == 0) |
858 | vsel = 0; | 845 | vsel = 0; |
859 | else if ((min_uV >= 2161000) && (max_uV <= 4321000)) { | 846 | else if ((min_uV >= 2161000) && (max_uV <= 4321000)) |
860 | vsel = (min_uV - 2161000) / 386; | 847 | vsel = DIV_ROUND_UP(min_uV - 2161000, 38600); |
861 | if (vsel % 100) | ||
862 | vsel += 100; | ||
863 | vsel /= 100; | ||
864 | vsel++; | ||
865 | } | ||
866 | break; | 848 | break; |
867 | } | 849 | } |
868 | 850 | ||