diff options
Diffstat (limited to 'drivers/regulator/as3711-regulator.c')
| -rw-r--r-- | drivers/regulator/as3711-regulator.c | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/drivers/regulator/as3711-regulator.c b/drivers/regulator/as3711-regulator.c index 8406cd745da2..c77a58478cca 100644 --- a/drivers/regulator/as3711-regulator.c +++ b/drivers/regulator/as3711-regulator.c | |||
| @@ -117,26 +117,19 @@ static struct regulator_ops as3711_dldo_ops = { | |||
| 117 | }; | 117 | }; |
| 118 | 118 | ||
| 119 | static const struct regulator_linear_range as3711_sd_ranges[] = { | 119 | static const struct regulator_linear_range as3711_sd_ranges[] = { |
| 120 | { .min_uV = 612500, .max_uV = 1400000, | 120 | REGULATOR_LINEAR_RANGE(612500, 0x1, 0x40, 12500), |
| 121 | .min_sel = 0x1, .max_sel = 0x40, .uV_step = 12500 }, | 121 | REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000), |
| 122 | { .min_uV = 1425000, .max_uV = 2600000, | 122 | REGULATOR_LINEAR_RANGE(2650000, 0x71, 0x7f, 50000), |
| 123 | .min_sel = 0x41, .max_sel = 0x70, .uV_step = 25000 }, | ||
| 124 | { .min_uV = 2650000, .max_uV = 3350000, | ||
| 125 | .min_sel = 0x71, .max_sel = 0x7f, .uV_step = 50000 }, | ||
| 126 | }; | 123 | }; |
| 127 | 124 | ||
| 128 | static const struct regulator_linear_range as3711_aldo_ranges[] = { | 125 | static const struct regulator_linear_range as3711_aldo_ranges[] = { |
| 129 | { .min_uV = 1200000, .max_uV = 1950000, | 126 | REGULATOR_LINEAR_RANGE(1200000, 0, 0xf, 50000), |
| 130 | .min_sel = 0, .max_sel = 0xf, .uV_step = 50000 }, | 127 | REGULATOR_LINEAR_RANGE(1800000, 0x10, 0x1f, 100000), |
| 131 | { .min_uV = 1800000, .max_uV = 3300000, | ||
| 132 | .min_sel = 0x10, .max_sel = 0x1f, .uV_step = 100000 }, | ||
| 133 | }; | 128 | }; |
| 134 | 129 | ||
| 135 | static const struct regulator_linear_range as3711_dldo_ranges[] = { | 130 | static const struct regulator_linear_range as3711_dldo_ranges[] = { |
| 136 | { .min_uV = 900000, .max_uV = 1700000, | 131 | REGULATOR_LINEAR_RANGE(900000, 0, 0x10, 50000), |
| 137 | .min_sel = 0, .max_sel = 0x10, .uV_step = 50000 }, | 132 | REGULATOR_LINEAR_RANGE(1750000, 0x20, 0x3f, 50000), |
| 138 | { .min_uV = 1750000, .max_uV = 3300000, | ||
| 139 | .min_sel = 0x20, .max_sel = 0x3f, .uV_step = 50000 }, | ||
| 140 | }; | 133 | }; |
| 141 | 134 | ||
| 142 | #define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \ | 135 | #define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \ |
| @@ -273,33 +266,16 @@ static int as3711_regulator_probe(struct platform_device *pdev) | |||
| 273 | config.regmap = as3711->regmap; | 266 | config.regmap = as3711->regmap; |
| 274 | config.of_node = of_node[id]; | 267 | config.of_node = of_node[id]; |
| 275 | 268 | ||
| 276 | rdev = regulator_register(&ri->desc, &config); | 269 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
| 277 | if (IS_ERR(rdev)) { | 270 | if (IS_ERR(rdev)) { |
| 278 | dev_err(&pdev->dev, "Failed to register regulator %s\n", | 271 | dev_err(&pdev->dev, "Failed to register regulator %s\n", |
| 279 | ri->desc.name); | 272 | ri->desc.name); |
| 280 | ret = PTR_ERR(rdev); | 273 | return PTR_ERR(rdev); |
| 281 | goto eregreg; | ||
| 282 | } | 274 | } |
| 283 | reg->rdev = rdev; | 275 | reg->rdev = rdev; |
| 284 | } | 276 | } |
| 285 | platform_set_drvdata(pdev, regs); | 277 | platform_set_drvdata(pdev, regs); |
| 286 | return 0; | 278 | return 0; |
| 287 | |||
| 288 | eregreg: | ||
| 289 | while (--id >= 0) | ||
| 290 | regulator_unregister(regs[id].rdev); | ||
| 291 | |||
| 292 | return ret; | ||
| 293 | } | ||
| 294 | |||
| 295 | static int as3711_regulator_remove(struct platform_device *pdev) | ||
| 296 | { | ||
| 297 | struct as3711_regulator *regs = platform_get_drvdata(pdev); | ||
| 298 | int id; | ||
| 299 | |||
| 300 | for (id = 0; id < AS3711_REGULATOR_NUM; ++id) | ||
| 301 | regulator_unregister(regs[id].rdev); | ||
| 302 | return 0; | ||
| 303 | } | 279 | } |
| 304 | 280 | ||
| 305 | static struct platform_driver as3711_regulator_driver = { | 281 | static struct platform_driver as3711_regulator_driver = { |
| @@ -308,7 +284,6 @@ static struct platform_driver as3711_regulator_driver = { | |||
| 308 | .owner = THIS_MODULE, | 284 | .owner = THIS_MODULE, |
| 309 | }, | 285 | }, |
| 310 | .probe = as3711_regulator_probe, | 286 | .probe = as3711_regulator_probe, |
| 311 | .remove = as3711_regulator_remove, | ||
| 312 | }; | 287 | }; |
| 313 | 288 | ||
| 314 | static int __init as3711_regulator_init(void) | 289 | static int __init as3711_regulator_init(void) |
