aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/ab8500.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/ab8500.c')
-rw-r--r--drivers/regulator/ab8500.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index ccb0bfd71f23..2a15b6300e18 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -100,12 +100,13 @@ static const int ldo_vintcore_voltages[] = {
100 100
101static int ab8500_regulator_enable(struct regulator_dev *rdev) 101static int ab8500_regulator_enable(struct regulator_dev *rdev)
102{ 102{
103 int regulator_id, ret; 103 int ret;
104 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); 104 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
105 105
106 regulator_id = rdev_get_id(rdev); 106 if (info == NULL) {
107 if (regulator_id >= AB8500_NUM_REGULATORS) 107 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
108 return -EINVAL; 108 return -EINVAL;
109 }
109 110
110 ret = abx500_mask_and_set_register_interruptible(info->dev, 111 ret = abx500_mask_and_set_register_interruptible(info->dev,
111 info->update_bank, info->update_reg, 112 info->update_bank, info->update_reg,
@@ -118,12 +119,13 @@ static int ab8500_regulator_enable(struct regulator_dev *rdev)
118 119
119static int ab8500_regulator_disable(struct regulator_dev *rdev) 120static int ab8500_regulator_disable(struct regulator_dev *rdev)
120{ 121{
121 int regulator_id, ret; 122 int ret;
122 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); 123 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
123 124
124 regulator_id = rdev_get_id(rdev); 125 if (info == NULL) {
125 if (regulator_id >= AB8500_NUM_REGULATORS) 126 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
126 return -EINVAL; 127 return -EINVAL;
128 }
127 129
128 ret = abx500_mask_and_set_register_interruptible(info->dev, 130 ret = abx500_mask_and_set_register_interruptible(info->dev,
129 info->update_bank, info->update_reg, 131 info->update_bank, info->update_reg,
@@ -136,13 +138,14 @@ static int ab8500_regulator_disable(struct regulator_dev *rdev)
136 138
137static int ab8500_regulator_is_enabled(struct regulator_dev *rdev) 139static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
138{ 140{
139 int regulator_id, ret; 141 int ret;
140 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); 142 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
141 u8 value; 143 u8 value;
142 144
143 regulator_id = rdev_get_id(rdev); 145 if (info == NULL) {
144 if (regulator_id >= AB8500_NUM_REGULATORS) 146 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
145 return -EINVAL; 147 return -EINVAL;
148 }
146 149
147 ret = abx500_get_register_interruptible(info->dev, 150 ret = abx500_get_register_interruptible(info->dev,
148 info->update_bank, info->update_reg, &value); 151 info->update_bank, info->update_reg, &value);
@@ -160,12 +163,12 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
160 163
161static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector) 164static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector)
162{ 165{
163 int regulator_id;
164 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); 166 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
165 167
166 regulator_id = rdev_get_id(rdev); 168 if (info == NULL) {
167 if (regulator_id >= AB8500_NUM_REGULATORS) 169 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
168 return -EINVAL; 170 return -EINVAL;
171 }
169 172
170 /* return the uV for the fixed regulators */ 173 /* return the uV for the fixed regulators */
171 if (info->fixed_uV) 174 if (info->fixed_uV)
@@ -179,13 +182,14 @@ static int ab8500_list_voltage(struct regulator_dev *rdev, unsigned selector)
179 182
180static int ab8500_regulator_get_voltage(struct regulator_dev *rdev) 183static int ab8500_regulator_get_voltage(struct regulator_dev *rdev)
181{ 184{
182 int regulator_id, ret; 185 int ret;
183 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); 186 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
184 u8 value; 187 u8 value;
185 188
186 regulator_id = rdev_get_id(rdev); 189 if (info == NULL) {
187 if (regulator_id >= AB8500_NUM_REGULATORS) 190 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
188 return -EINVAL; 191 return -EINVAL;
192 }
189 193
190 ret = abx500_get_register_interruptible(info->dev, info->voltage_bank, 194 ret = abx500_get_register_interruptible(info->dev, info->voltage_bank,
191 info->voltage_reg, &value); 195 info->voltage_reg, &value);
@@ -197,7 +201,7 @@ static int ab8500_regulator_get_voltage(struct regulator_dev *rdev)
197 201
198 /* vintcore has a different layout */ 202 /* vintcore has a different layout */
199 value &= info->voltage_mask; 203 value &= info->voltage_mask;
200 if (regulator_id == AB8500_LDO_INTCORE) 204 if (info->desc.id == AB8500_LDO_INTCORE)
201 ret = info->voltages[value >> 0x3]; 205 ret = info->voltages[value >> 0x3];
202 else 206 else
203 ret = info->voltages[value]; 207 ret = info->voltages[value];
@@ -225,12 +229,13 @@ static int ab8500_regulator_set_voltage(struct regulator_dev *rdev,
225 int min_uV, int max_uV, 229 int min_uV, int max_uV,
226 unsigned *selector) 230 unsigned *selector)
227{ 231{
228 int regulator_id, ret; 232 int ret;
229 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); 233 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
230 234
231 regulator_id = rdev_get_id(rdev); 235 if (info == NULL) {
232 if (regulator_id >= AB8500_NUM_REGULATORS) 236 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
233 return -EINVAL; 237 return -EINVAL;
238 }
234 239
235 /* get the appropriate voltages within the range */ 240 /* get the appropriate voltages within the range */
236 ret = ab8500_get_best_voltage_index(rdev, min_uV, max_uV); 241 ret = ab8500_get_best_voltage_index(rdev, min_uV, max_uV);
@@ -264,12 +269,12 @@ static struct regulator_ops ab8500_regulator_ops = {
264 269
265static int ab8500_fixed_get_voltage(struct regulator_dev *rdev) 270static int ab8500_fixed_get_voltage(struct regulator_dev *rdev)
266{ 271{
267 int regulator_id;
268 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); 272 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
269 273
270 regulator_id = rdev_get_id(rdev); 274 if (info == NULL) {
271 if (regulator_id >= AB8500_NUM_REGULATORS) 275 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
272 return -EINVAL; 276 return -EINVAL;
277 }
273 278
274 return info->fixed_uV; 279 return info->fixed_uV;
275} 280}
@@ -368,6 +373,10 @@ static __devinit int ab8500_regulator_probe(struct platform_device *pdev)
368 return -EINVAL; 373 return -EINVAL;
369 } 374 }
370 pdata = dev_get_platdata(ab8500->dev); 375 pdata = dev_get_platdata(ab8500->dev);
376 if (!pdata) {
377 dev_err(&pdev->dev, "null pdata\n");
378 return -EINVAL;
379 }
371 380
372 /* make sure the platform data has the correct size */ 381 /* make sure the platform data has the correct size */
373 if (pdata->num_regulator != ARRAY_SIZE(ab8500_regulator_info)) { 382 if (pdata->num_regulator != ARRAY_SIZE(ab8500_regulator_info)) {