Commit 63c7c2962ae715f3e1ed042db9046b36af637611
Committed by
Mark Brown
1 parent
ce62ba3afd
regulator: ltc3589: Get rid of struct ltc3589_regulator
After converting to use simplified DT parsing, the struct ltc3589_regulator only has a desc member. So let's remove struct ltc3589_regulator and use struct regulator_desc instead. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Showing 1 changed file with 31 additions and 38 deletions Side-by-side Diff
drivers/regulator/ltc3589.c
... | ... | @@ -84,15 +84,11 @@ |
84 | 84 | LTC3589_NUM_REGULATORS, |
85 | 85 | }; |
86 | 86 | |
87 | -struct ltc3589_regulator { | |
88 | - struct regulator_desc desc; | |
89 | -}; | |
90 | - | |
91 | 87 | struct ltc3589 { |
92 | 88 | struct regmap *regmap; |
93 | 89 | struct device *dev; |
94 | 90 | enum ltc3589_variant variant; |
95 | - struct ltc3589_regulator regulator_descs[LTC3589_NUM_REGULATORS]; | |
91 | + struct regulator_desc regulator_descs[LTC3589_NUM_REGULATORS]; | |
96 | 92 | struct regulator_dev *regulators[LTC3589_NUM_REGULATORS]; |
97 | 93 | }; |
98 | 94 | |
... | ... | @@ -209,7 +205,7 @@ |
209 | 205 | struct regulator_config *config) |
210 | 206 | { |
211 | 207 | struct ltc3589 *ltc3589 = config->driver_data; |
212 | - struct ltc3589_regulator *rdesc = <c3589->regulator_descs[desc->id]; | |
208 | + struct regulator_desc *rdesc = <c3589->regulator_descs[desc->id]; | |
213 | 209 | u32 r[2]; |
214 | 210 | int ret; |
215 | 211 | |
216 | 212 | |
... | ... | @@ -227,36 +223,34 @@ |
227 | 223 | if (!r[0] || !r[1]) |
228 | 224 | return 0; |
229 | 225 | |
230 | - rdesc->desc.min_uV = ltc3589_scale(desc->min_uV, r[0], r[1]); | |
231 | - rdesc->desc.uV_step = ltc3589_scale(desc->uV_step, r[0], r[1]); | |
232 | - rdesc->desc.fixed_uV = ltc3589_scale(desc->fixed_uV, r[0], r[1]); | |
226 | + rdesc->min_uV = ltc3589_scale(desc->min_uV, r[0], r[1]); | |
227 | + rdesc->uV_step = ltc3589_scale(desc->uV_step, r[0], r[1]); | |
228 | + rdesc->fixed_uV = ltc3589_scale(desc->fixed_uV, r[0], r[1]); | |
233 | 229 | |
234 | 230 | return 0; |
235 | 231 | } |
236 | 232 | |
237 | 233 | #define LTC3589_REG(_name, _of_name, _ops, en_bit, dtv1_reg, dtv_mask, go_bit)\ |
238 | 234 | [LTC3589_ ## _name] = { \ |
239 | - .desc = { \ | |
240 | - .name = #_name, \ | |
241 | - .of_match = of_match_ptr(#_of_name), \ | |
242 | - .regulators_node = of_match_ptr("regulators"), \ | |
243 | - .of_parse_cb = ltc3589_of_parse_cb, \ | |
244 | - .n_voltages = (dtv_mask) + 1, \ | |
245 | - .min_uV = (go_bit) ? 362500 : 0, \ | |
246 | - .uV_step = (go_bit) ? 12500 : 0, \ | |
247 | - .ramp_delay = (go_bit) ? 1750 : 0, \ | |
248 | - .fixed_uV = (dtv_mask) ? 0 : 800000, \ | |
249 | - .ops = <c3589_ ## _ops ## _regulator_ops, \ | |
250 | - .type = REGULATOR_VOLTAGE, \ | |
251 | - .id = LTC3589_ ## _name, \ | |
252 | - .owner = THIS_MODULE, \ | |
253 | - .vsel_reg = (dtv1_reg), \ | |
254 | - .vsel_mask = (dtv_mask), \ | |
255 | - .apply_reg = (go_bit) ? LTC3589_VCCR : 0, \ | |
256 | - .apply_bit = (go_bit), \ | |
257 | - .enable_reg = (en_bit) ? LTC3589_OVEN : 0, \ | |
258 | - .enable_mask = (en_bit), \ | |
259 | - }, \ | |
235 | + .name = #_name, \ | |
236 | + .of_match = of_match_ptr(#_of_name), \ | |
237 | + .regulators_node = of_match_ptr("regulators"), \ | |
238 | + .of_parse_cb = ltc3589_of_parse_cb, \ | |
239 | + .n_voltages = (dtv_mask) + 1, \ | |
240 | + .min_uV = (go_bit) ? 362500 : 0, \ | |
241 | + .uV_step = (go_bit) ? 12500 : 0, \ | |
242 | + .ramp_delay = (go_bit) ? 1750 : 0, \ | |
243 | + .fixed_uV = (dtv_mask) ? 0 : 800000, \ | |
244 | + .ops = <c3589_ ## _ops ## _regulator_ops, \ | |
245 | + .type = REGULATOR_VOLTAGE, \ | |
246 | + .id = LTC3589_ ## _name, \ | |
247 | + .owner = THIS_MODULE, \ | |
248 | + .vsel_reg = (dtv1_reg), \ | |
249 | + .vsel_mask = (dtv_mask), \ | |
250 | + .apply_reg = (go_bit) ? LTC3589_VCCR : 0, \ | |
251 | + .apply_bit = (go_bit), \ | |
252 | + .enable_reg = (en_bit) ? LTC3589_OVEN : 0, \ | |
253 | + .enable_mask = (en_bit), \ | |
260 | 254 | } |
261 | 255 | |
262 | 256 | #define LTC3589_LINEAR_REG(_name, _of_name, _dtv1) \ |
... | ... | @@ -267,7 +261,7 @@ |
267 | 261 | #define LTC3589_FIXED_REG(_name, _of_name) \ |
268 | 262 | LTC3589_REG(_name, _of_name, fixed, LTC3589_OVEN_ ## _name, 0, 0, 0) |
269 | 263 | |
270 | -static struct ltc3589_regulator ltc3589_regulators[LTC3589_NUM_REGULATORS] = { | |
264 | +static const struct regulator_desc ltc3589_regulators[] = { | |
271 | 265 | LTC3589_LINEAR_REG(SW1, sw1, B1DTV1), |
272 | 266 | LTC3589_LINEAR_REG(SW2, sw2, B2DTV1), |
273 | 267 | LTC3589_LINEAR_REG(SW3, sw3, B3DTV1), |
... | ... | @@ -403,7 +397,7 @@ |
403 | 397 | const struct i2c_device_id *id) |
404 | 398 | { |
405 | 399 | struct device *dev = &client->dev; |
406 | - struct ltc3589_regulator *descs; | |
400 | + struct regulator_desc *descs; | |
407 | 401 | struct ltc3589 *ltc3589; |
408 | 402 | int i, ret; |
409 | 403 | |
410 | 404 | |
... | ... | @@ -422,11 +416,11 @@ |
422 | 416 | descs = ltc3589->regulator_descs; |
423 | 417 | memcpy(descs, ltc3589_regulators, sizeof(ltc3589_regulators)); |
424 | 418 | if (ltc3589->variant == LTC3589) { |
425 | - descs[LTC3589_LDO3].desc.fixed_uV = 1800000; | |
426 | - descs[LTC3589_LDO4].desc.volt_table = ltc3589_ldo4; | |
419 | + descs[LTC3589_LDO3].fixed_uV = 1800000; | |
420 | + descs[LTC3589_LDO4].volt_table = ltc3589_ldo4; | |
427 | 421 | } else { |
428 | - descs[LTC3589_LDO3].desc.fixed_uV = 2800000; | |
429 | - descs[LTC3589_LDO4].desc.volt_table = ltc3589_12_ldo4; | |
422 | + descs[LTC3589_LDO3].fixed_uV = 2800000; | |
423 | + descs[LTC3589_LDO4].volt_table = ltc3589_12_ldo4; | |
430 | 424 | } |
431 | 425 | |
432 | 426 | ltc3589->regmap = devm_regmap_init_i2c(client, <c3589_regmap_config); |
... | ... | @@ -437,8 +431,7 @@ |
437 | 431 | } |
438 | 432 | |
439 | 433 | for (i = 0; i < LTC3589_NUM_REGULATORS; i++) { |
440 | - struct ltc3589_regulator *rdesc = <c3589->regulator_descs[i]; | |
441 | - struct regulator_desc *desc = &rdesc->desc; | |
434 | + struct regulator_desc *desc = <c3589->regulator_descs[i]; | |
442 | 435 | struct regulator_config config = { }; |
443 | 436 | |
444 | 437 | config.dev = dev; |