diff options
author | Axel Lin <axel.lin@gmail.com> | 2012-04-11 10:56:11 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-04-17 10:25:10 -0400 |
commit | 9e96b3a7ade72cb66b95f2ad3c849bab702ed87b (patch) | |
tree | 11736f5342c4f24b7cfad472e17842a6a29106b7 /drivers/regulator/max8997.c | |
parent | 82b719b11fd750188c125078ad6a6c0d23219dfb (diff) |
regulator: Convert max8997 to get_voltage_sel
Also rename get_current_limit and set_current_limit callbacks
to max8997_get_current_limit and max8997_set_current_limit for
better readability.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max8997.c')
-rw-r--r-- | drivers/regulator/max8997.c | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index db09244bb3ed..56402e87925e 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
@@ -382,7 +382,7 @@ static int max8997_get_voltage_register(struct regulator_dev *rdev, | |||
382 | return 0; | 382 | return 0; |
383 | } | 383 | } |
384 | 384 | ||
385 | static int max8997_get_voltage(struct regulator_dev *rdev) | 385 | static int max8997_get_voltage_sel(struct regulator_dev *rdev) |
386 | { | 386 | { |
387 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); | 387 | struct max8997_data *max8997 = rdev_get_drvdata(rdev); |
388 | struct i2c_client *i2c = max8997->iodev->i2c; | 388 | struct i2c_client *i2c = max8997->iodev->i2c; |
@@ -400,15 +400,7 @@ static int max8997_get_voltage(struct regulator_dev *rdev) | |||
400 | val >>= shift; | 400 | val >>= shift; |
401 | val &= mask; | 401 | val &= mask; |
402 | 402 | ||
403 | if (rdev->desc && rdev->desc->ops && rdev->desc->ops->list_voltage) | 403 | return val; |
404 | return rdev->desc->ops->list_voltage(rdev, val); | ||
405 | |||
406 | /* | ||
407 | * max8997_list_voltage returns value for any rdev with voltage_map, | ||
408 | * which works for "CHARGER" and "CHARGER TOPOFF" that do not have | ||
409 | * list_voltage ops (they are current regulators). | ||
410 | */ | ||
411 | return max8997_list_voltage(rdev, val); | ||
412 | } | 404 | } |
413 | 405 | ||
414 | static inline int max8997_get_voltage_proper_val( | 406 | static inline int max8997_get_voltage_proper_val( |
@@ -786,7 +778,7 @@ static struct regulator_ops max8997_ldo_ops = { | |||
786 | .is_enabled = max8997_reg_is_enabled, | 778 | .is_enabled = max8997_reg_is_enabled, |
787 | .enable = max8997_reg_enable, | 779 | .enable = max8997_reg_enable, |
788 | .disable = max8997_reg_disable, | 780 | .disable = max8997_reg_disable, |
789 | .get_voltage = max8997_get_voltage, | 781 | .get_voltage_sel = max8997_get_voltage_sel, |
790 | .set_voltage = max8997_set_voltage_ldobuck, | 782 | .set_voltage = max8997_set_voltage_ldobuck, |
791 | .set_suspend_enable = max8997_reg_enable_suspend, | 783 | .set_suspend_enable = max8997_reg_enable_suspend, |
792 | .set_suspend_disable = max8997_reg_disable_suspend, | 784 | .set_suspend_disable = max8997_reg_disable_suspend, |
@@ -797,7 +789,7 @@ static struct regulator_ops max8997_buck_ops = { | |||
797 | .is_enabled = max8997_reg_is_enabled, | 789 | .is_enabled = max8997_reg_is_enabled, |
798 | .enable = max8997_reg_enable, | 790 | .enable = max8997_reg_enable, |
799 | .disable = max8997_reg_disable, | 791 | .disable = max8997_reg_disable, |
800 | .get_voltage = max8997_get_voltage, | 792 | .get_voltage_sel = max8997_get_voltage_sel, |
801 | .set_voltage = max8997_set_voltage_buck, | 793 | .set_voltage = max8997_set_voltage_buck, |
802 | .set_suspend_enable = max8997_reg_enable_suspend, | 794 | .set_suspend_enable = max8997_reg_enable_suspend, |
803 | .set_suspend_disable = max8997_reg_disable_suspend, | 795 | .set_suspend_disable = max8997_reg_disable_suspend, |
@@ -817,7 +809,7 @@ static struct regulator_ops max8997_safeout_ops = { | |||
817 | .is_enabled = max8997_reg_is_enabled, | 809 | .is_enabled = max8997_reg_is_enabled, |
818 | .enable = max8997_reg_enable, | 810 | .enable = max8997_reg_enable, |
819 | .disable = max8997_reg_disable, | 811 | .disable = max8997_reg_disable, |
820 | .get_voltage = max8997_get_voltage, | 812 | .get_voltage_sel = max8997_get_voltage_sel, |
821 | .set_voltage = max8997_set_voltage_safeout, | 813 | .set_voltage = max8997_set_voltage_safeout, |
822 | .set_suspend_enable = max8997_reg_enable_suspend, | 814 | .set_suspend_enable = max8997_reg_enable_suspend, |
823 | .set_suspend_disable = max8997_reg_disable_suspend, | 815 | .set_suspend_disable = max8997_reg_disable_suspend, |
@@ -825,31 +817,50 @@ static struct regulator_ops max8997_safeout_ops = { | |||
825 | 817 | ||
826 | static struct regulator_ops max8997_fixedstate_ops = { | 818 | static struct regulator_ops max8997_fixedstate_ops = { |
827 | .list_voltage = max8997_list_voltage_charger_cv, | 819 | .list_voltage = max8997_list_voltage_charger_cv, |
828 | .get_voltage = max8997_get_voltage, | 820 | .get_voltage_sel = max8997_get_voltage_sel, |
829 | .set_voltage = max8997_set_voltage_charger_cv, | 821 | .set_voltage = max8997_set_voltage_charger_cv, |
830 | }; | 822 | }; |
831 | 823 | ||
832 | static int max8997_set_voltage_ldobuck_wrap(struct regulator_dev *rdev, | 824 | static int max8997_set_current_limit(struct regulator_dev *rdev, |
833 | int min_uV, int max_uV) | 825 | int min_uA, int max_uA) |
834 | { | 826 | { |
835 | unsigned dummy; | 827 | unsigned dummy; |
828 | int rid = rdev_get_id(rdev); | ||
829 | |||
830 | if (rid != MAX8997_CHARGER && rid != MAX8997_CHARGER_TOPOFF) | ||
831 | return -EINVAL; | ||
836 | 832 | ||
837 | return max8997_set_voltage_ldobuck(rdev, min_uV, max_uV, &dummy); | 833 | /* Reuse max8997_set_voltage_ldobuck to set current_limit. */ |
834 | return max8997_set_voltage_ldobuck(rdev, min_uA, max_uA, &dummy); | ||
838 | } | 835 | } |
839 | 836 | ||
837 | static int max8997_get_current_limit(struct regulator_dev *rdev) | ||
838 | { | ||
839 | int sel, rid = rdev_get_id(rdev); | ||
840 | |||
841 | if (rid != MAX8997_CHARGER && rid != MAX8997_CHARGER_TOPOFF) | ||
842 | return -EINVAL; | ||
843 | |||
844 | sel = max8997_get_voltage_sel(rdev); | ||
845 | if (sel < 0) | ||
846 | return sel; | ||
847 | |||
848 | /* Reuse max8997_list_voltage to get current_limit. */ | ||
849 | return max8997_list_voltage(rdev, sel); | ||
850 | } | ||
840 | 851 | ||
841 | static struct regulator_ops max8997_charger_ops = { | 852 | static struct regulator_ops max8997_charger_ops = { |
842 | .is_enabled = max8997_reg_is_enabled, | 853 | .is_enabled = max8997_reg_is_enabled, |
843 | .enable = max8997_reg_enable, | 854 | .enable = max8997_reg_enable, |
844 | .disable = max8997_reg_disable, | 855 | .disable = max8997_reg_disable, |
845 | .get_current_limit = max8997_get_voltage, | 856 | .get_current_limit = max8997_get_current_limit, |
846 | .set_current_limit = max8997_set_voltage_ldobuck_wrap, | 857 | .set_current_limit = max8997_set_current_limit, |
847 | }; | 858 | }; |
848 | 859 | ||
849 | static struct regulator_ops max8997_charger_fixedstate_ops = { | 860 | static struct regulator_ops max8997_charger_fixedstate_ops = { |
850 | .is_enabled = max8997_reg_is_enabled, | 861 | .is_enabled = max8997_reg_is_enabled, |
851 | .get_current_limit = max8997_get_voltage, | 862 | .get_current_limit = max8997_get_current_limit, |
852 | .set_current_limit = max8997_set_voltage_ldobuck_wrap, | 863 | .set_current_limit = max8997_set_current_limit, |
853 | }; | 864 | }; |
854 | 865 | ||
855 | #define MAX8997_VOLTAGE_REGULATOR(_name, _ops) {\ | 866 | #define MAX8997_VOLTAGE_REGULATOR(_name, _ops) {\ |