diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2016-02-18 00:57:03 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-02-19 11:07:40 -0500 |
commit | 7ddec641214914ad878811822ec24e01f3d1c97e (patch) | |
tree | 7ab64eccb48c5a36c62c9b2504f5aa651ac8c69f /drivers/regulator | |
parent | 297eaaa6d0bf09a91045e1d8c9b1e555d8b91d8a (diff) |
regulator: s2mps11: Use local variable for number of regulators
Remove the s2mps11_info.rdev_num because it is not used outside of
probe.
Suggested-by: Andi Shyti <andi.shyti@samsung.com>
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Andi Shyti <andi.shyti@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/s2mps11.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index df553fb40d82..d24e2c783dc5 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c | |||
@@ -38,7 +38,6 @@ | |||
38 | /* The highest number of possible regulators for supported devices. */ | 38 | /* The highest number of possible regulators for supported devices. */ |
39 | #define S2MPS_REGULATOR_MAX S2MPS13_REGULATOR_MAX | 39 | #define S2MPS_REGULATOR_MAX S2MPS13_REGULATOR_MAX |
40 | struct s2mps11_info { | 40 | struct s2mps11_info { |
41 | unsigned int rdev_num; | ||
42 | int ramp_delay2; | 41 | int ramp_delay2; |
43 | int ramp_delay34; | 42 | int ramp_delay34; |
44 | int ramp_delay5; | 43 | int ramp_delay5; |
@@ -54,7 +53,10 @@ struct s2mps11_info { | |||
54 | */ | 53 | */ |
55 | DECLARE_BITMAP(suspend_state, S2MPS_REGULATOR_MAX); | 54 | DECLARE_BITMAP(suspend_state, S2MPS_REGULATOR_MAX); |
56 | 55 | ||
57 | /* Array of size rdev_num with GPIO-s for external sleep control */ | 56 | /* |
57 | * Array (size: number of regulators) with GPIO-s for external | ||
58 | * sleep control. | ||
59 | */ | ||
58 | int *ext_control_gpio; | 60 | int *ext_control_gpio; |
59 | }; | 61 | }; |
60 | 62 | ||
@@ -819,7 +821,8 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, | |||
819 | } | 821 | } |
820 | 822 | ||
821 | static int s2mps11_pmic_dt_parse(struct platform_device *pdev, | 823 | static int s2mps11_pmic_dt_parse(struct platform_device *pdev, |
822 | struct of_regulator_match *rdata, struct s2mps11_info *s2mps11) | 824 | struct of_regulator_match *rdata, struct s2mps11_info *s2mps11, |
825 | unsigned int rdev_num) | ||
823 | { | 826 | { |
824 | struct device_node *reg_np; | 827 | struct device_node *reg_np; |
825 | 828 | ||
@@ -829,7 +832,7 @@ static int s2mps11_pmic_dt_parse(struct platform_device *pdev, | |||
829 | return -EINVAL; | 832 | return -EINVAL; |
830 | } | 833 | } |
831 | 834 | ||
832 | of_regulator_match(&pdev->dev, reg_np, rdata, s2mps11->rdev_num); | 835 | of_regulator_match(&pdev->dev, reg_np, rdata, rdev_num); |
833 | if (s2mps11->dev_type == S2MPS14X) | 836 | if (s2mps11->dev_type == S2MPS14X) |
834 | s2mps14_pmic_dt_parse_ext_control_gpio(pdev, rdata, s2mps11); | 837 | s2mps14_pmic_dt_parse_ext_control_gpio(pdev, rdata, s2mps11); |
835 | 838 | ||
@@ -1077,6 +1080,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
1077 | struct of_regulator_match *rdata = NULL; | 1080 | struct of_regulator_match *rdata = NULL; |
1078 | struct regulator_config config = { }; | 1081 | struct regulator_config config = { }; |
1079 | struct s2mps11_info *s2mps11; | 1082 | struct s2mps11_info *s2mps11; |
1083 | unsigned int rdev_num = 0; | ||
1080 | int i, ret = 0; | 1084 | int i, ret = 0; |
1081 | const struct regulator_desc *regulators; | 1085 | const struct regulator_desc *regulators; |
1082 | 1086 | ||
@@ -1088,27 +1092,27 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
1088 | s2mps11->dev_type = platform_get_device_id(pdev)->driver_data; | 1092 | s2mps11->dev_type = platform_get_device_id(pdev)->driver_data; |
1089 | switch (s2mps11->dev_type) { | 1093 | switch (s2mps11->dev_type) { |
1090 | case S2MPS11X: | 1094 | case S2MPS11X: |
1091 | s2mps11->rdev_num = ARRAY_SIZE(s2mps11_regulators); | 1095 | rdev_num = ARRAY_SIZE(s2mps11_regulators); |
1092 | regulators = s2mps11_regulators; | 1096 | regulators = s2mps11_regulators; |
1093 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps11_regulators)); | 1097 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps11_regulators)); |
1094 | break; | 1098 | break; |
1095 | case S2MPS13X: | 1099 | case S2MPS13X: |
1096 | s2mps11->rdev_num = ARRAY_SIZE(s2mps13_regulators); | 1100 | rdev_num = ARRAY_SIZE(s2mps13_regulators); |
1097 | regulators = s2mps13_regulators; | 1101 | regulators = s2mps13_regulators; |
1098 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps13_regulators)); | 1102 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps13_regulators)); |
1099 | break; | 1103 | break; |
1100 | case S2MPS14X: | 1104 | case S2MPS14X: |
1101 | s2mps11->rdev_num = ARRAY_SIZE(s2mps14_regulators); | 1105 | rdev_num = ARRAY_SIZE(s2mps14_regulators); |
1102 | regulators = s2mps14_regulators; | 1106 | regulators = s2mps14_regulators; |
1103 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps14_regulators)); | 1107 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps14_regulators)); |
1104 | break; | 1108 | break; |
1105 | case S2MPS15X: | 1109 | case S2MPS15X: |
1106 | s2mps11->rdev_num = ARRAY_SIZE(s2mps15_regulators); | 1110 | rdev_num = ARRAY_SIZE(s2mps15_regulators); |
1107 | regulators = s2mps15_regulators; | 1111 | regulators = s2mps15_regulators; |
1108 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps15_regulators)); | 1112 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mps15_regulators)); |
1109 | break; | 1113 | break; |
1110 | case S2MPU02: | 1114 | case S2MPU02: |
1111 | s2mps11->rdev_num = ARRAY_SIZE(s2mpu02_regulators); | 1115 | rdev_num = ARRAY_SIZE(s2mpu02_regulators); |
1112 | regulators = s2mpu02_regulators; | 1116 | regulators = s2mpu02_regulators; |
1113 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mpu02_regulators)); | 1117 | BUILD_BUG_ON(S2MPS_REGULATOR_MAX < ARRAY_SIZE(s2mpu02_regulators)); |
1114 | break; | 1118 | break; |
@@ -1119,7 +1123,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
1119 | } | 1123 | } |
1120 | 1124 | ||
1121 | s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev, | 1125 | s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev, |
1122 | sizeof(*s2mps11->ext_control_gpio) * s2mps11->rdev_num, | 1126 | sizeof(*s2mps11->ext_control_gpio) * rdev_num, |
1123 | GFP_KERNEL); | 1127 | GFP_KERNEL); |
1124 | if (!s2mps11->ext_control_gpio) | 1128 | if (!s2mps11->ext_control_gpio) |
1125 | return -ENOMEM; | 1129 | return -ENOMEM; |
@@ -1127,7 +1131,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
1127 | * 0 is a valid GPIO so initialize all GPIO-s to negative value | 1131 | * 0 is a valid GPIO so initialize all GPIO-s to negative value |
1128 | * to indicate that external control won't be used for this regulator. | 1132 | * to indicate that external control won't be used for this regulator. |
1129 | */ | 1133 | */ |
1130 | for (i = 0; i < s2mps11->rdev_num; i++) | 1134 | for (i = 0; i < rdev_num; i++) |
1131 | s2mps11->ext_control_gpio[i] = -EINVAL; | 1135 | s2mps11->ext_control_gpio[i] = -EINVAL; |
1132 | 1136 | ||
1133 | if (!iodev->dev->of_node) { | 1137 | if (!iodev->dev->of_node) { |
@@ -1141,14 +1145,14 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
1141 | } | 1145 | } |
1142 | } | 1146 | } |
1143 | 1147 | ||
1144 | rdata = kzalloc(sizeof(*rdata) * s2mps11->rdev_num, GFP_KERNEL); | 1148 | rdata = kzalloc(sizeof(*rdata) * rdev_num, GFP_KERNEL); |
1145 | if (!rdata) | 1149 | if (!rdata) |
1146 | return -ENOMEM; | 1150 | return -ENOMEM; |
1147 | 1151 | ||
1148 | for (i = 0; i < s2mps11->rdev_num; i++) | 1152 | for (i = 0; i < rdev_num; i++) |
1149 | rdata[i].name = regulators[i].name; | 1153 | rdata[i].name = regulators[i].name; |
1150 | 1154 | ||
1151 | ret = s2mps11_pmic_dt_parse(pdev, rdata, s2mps11); | 1155 | ret = s2mps11_pmic_dt_parse(pdev, rdata, s2mps11, rdev_num); |
1152 | if (ret) | 1156 | if (ret) |
1153 | goto out; | 1157 | goto out; |
1154 | 1158 | ||
@@ -1160,7 +1164,7 @@ common_reg: | |||
1160 | config.driver_data = s2mps11; | 1164 | config.driver_data = s2mps11; |
1161 | config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; | 1165 | config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; |
1162 | config.ena_gpio_initialized = true; | 1166 | config.ena_gpio_initialized = true; |
1163 | for (i = 0; i < s2mps11->rdev_num; i++) { | 1167 | for (i = 0; i < rdev_num; i++) { |
1164 | struct regulator_dev *regulator; | 1168 | struct regulator_dev *regulator; |
1165 | 1169 | ||
1166 | if (pdata) { | 1170 | if (pdata) { |