diff options
50 files changed, 514 insertions, 1099 deletions
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index fcb34a5697ea..3d9c2a766230 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt | |||
| @@ -283,6 +283,7 @@ REGULATOR | |||
| 283 | devm_regulator_get() | 283 | devm_regulator_get() |
| 284 | devm_regulator_put() | 284 | devm_regulator_put() |
| 285 | devm_regulator_bulk_get() | 285 | devm_regulator_bulk_get() |
| 286 | devm_regulator_register() | ||
| 286 | 287 | ||
| 287 | CLOCK | 288 | CLOCK |
| 288 | devm_clk_get() | 289 | devm_clk_get() |
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c index 70230974468c..f704d83c93c4 100644 --- a/drivers/regulator/88pm8607.c +++ b/drivers/regulator/88pm8607.c | |||
| @@ -391,7 +391,8 @@ static int pm8607_regulator_probe(struct platform_device *pdev) | |||
| 391 | else | 391 | else |
| 392 | config.regmap = chip->regmap_companion; | 392 | config.regmap = chip->regmap_companion; |
| 393 | 393 | ||
| 394 | info->regulator = regulator_register(&info->desc, &config); | 394 | info->regulator = devm_regulator_register(&pdev->dev, &info->desc, |
| 395 | &config); | ||
| 395 | if (IS_ERR(info->regulator)) { | 396 | if (IS_ERR(info->regulator)) { |
| 396 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 397 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
| 397 | info->desc.name); | 398 | info->desc.name); |
| @@ -402,14 +403,6 @@ static int pm8607_regulator_probe(struct platform_device *pdev) | |||
| 402 | return 0; | 403 | return 0; |
| 403 | } | 404 | } |
| 404 | 405 | ||
| 405 | static int pm8607_regulator_remove(struct platform_device *pdev) | ||
| 406 | { | ||
| 407 | struct pm8607_regulator_info *info = platform_get_drvdata(pdev); | ||
| 408 | |||
| 409 | regulator_unregister(info->regulator); | ||
| 410 | return 0; | ||
| 411 | } | ||
| 412 | |||
| 413 | static struct platform_device_id pm8607_regulator_driver_ids[] = { | 406 | static struct platform_device_id pm8607_regulator_driver_ids[] = { |
| 414 | { | 407 | { |
| 415 | .name = "88pm860x-regulator", | 408 | .name = "88pm860x-regulator", |
| @@ -428,7 +421,6 @@ static struct platform_driver pm8607_regulator_driver = { | |||
| 428 | .owner = THIS_MODULE, | 421 | .owner = THIS_MODULE, |
| 429 | }, | 422 | }, |
| 430 | .probe = pm8607_regulator_probe, | 423 | .probe = pm8607_regulator_probe, |
| 431 | .remove = pm8607_regulator_remove, | ||
| 432 | .id_table = pm8607_regulator_driver_ids, | 424 | .id_table = pm8607_regulator_driver_ids, |
| 433 | }; | 425 | }; |
| 434 | 426 | ||
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 185cce246022..69db4c8bb5c9 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | # | 3 | # |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o | 6 | obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o devres.o |
| 7 | obj-$(CONFIG_OF) += of_regulator.o | 7 | obj-$(CONFIG_OF) += of_regulator.o |
| 8 | obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o | 8 | obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o |
| 9 | obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o | 9 | obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o |
diff --git a/drivers/regulator/aat2870-regulator.c b/drivers/regulator/aat2870-regulator.c index 881159dfcb5e..f70a9bfa5ff2 100644 --- a/drivers/regulator/aat2870-regulator.c +++ b/drivers/regulator/aat2870-regulator.c | |||
| @@ -176,7 +176,7 @@ static int aat2870_regulator_probe(struct platform_device *pdev) | |||
| 176 | config.driver_data = ri; | 176 | config.driver_data = ri; |
| 177 | config.init_data = dev_get_platdata(&pdev->dev); | 177 | config.init_data = dev_get_platdata(&pdev->dev); |
| 178 | 178 | ||
| 179 | rdev = regulator_register(&ri->desc, &config); | 179 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
| 180 | if (IS_ERR(rdev)) { | 180 | if (IS_ERR(rdev)) { |
| 181 | dev_err(&pdev->dev, "Failed to register regulator %s\n", | 181 | dev_err(&pdev->dev, "Failed to register regulator %s\n", |
| 182 | ri->desc.name); | 182 | ri->desc.name); |
| @@ -187,21 +187,12 @@ static int aat2870_regulator_probe(struct platform_device *pdev) | |||
| 187 | return 0; | 187 | return 0; |
| 188 | } | 188 | } |
| 189 | 189 | ||
| 190 | static int aat2870_regulator_remove(struct platform_device *pdev) | ||
| 191 | { | ||
| 192 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
| 193 | |||
| 194 | regulator_unregister(rdev); | ||
| 195 | return 0; | ||
| 196 | } | ||
| 197 | |||
| 198 | static struct platform_driver aat2870_regulator_driver = { | 190 | static struct platform_driver aat2870_regulator_driver = { |
| 199 | .driver = { | 191 | .driver = { |
| 200 | .name = "aat2870-regulator", | 192 | .name = "aat2870-regulator", |
| 201 | .owner = THIS_MODULE, | 193 | .owner = THIS_MODULE, |
| 202 | }, | 194 | }, |
| 203 | .probe = aat2870_regulator_probe, | 195 | .probe = aat2870_regulator_probe, |
| 204 | .remove = aat2870_regulator_remove, | ||
| 205 | }; | 196 | }; |
| 206 | 197 | ||
| 207 | static int __init aat2870_regulator_init(void) | 198 | static int __init aat2870_regulator_init(void) |
diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c index b2b203cb6b2f..48016a050d5f 100644 --- a/drivers/regulator/ad5398.c +++ b/drivers/regulator/ad5398.c | |||
| @@ -219,7 +219,6 @@ static int ad5398_probe(struct i2c_client *client, | |||
| 219 | struct ad5398_chip_info *chip; | 219 | struct ad5398_chip_info *chip; |
| 220 | const struct ad5398_current_data_format *df = | 220 | const struct ad5398_current_data_format *df = |
| 221 | (struct ad5398_current_data_format *)id->driver_data; | 221 | (struct ad5398_current_data_format *)id->driver_data; |
| 222 | int ret; | ||
| 223 | 222 | ||
| 224 | if (!init_data) | 223 | if (!init_data) |
| 225 | return -EINVAL; | 224 | return -EINVAL; |
| @@ -240,33 +239,21 @@ static int ad5398_probe(struct i2c_client *client, | |||
| 240 | chip->current_offset = df->current_offset; | 239 | chip->current_offset = df->current_offset; |
| 241 | chip->current_mask = (chip->current_level - 1) << chip->current_offset; | 240 | chip->current_mask = (chip->current_level - 1) << chip->current_offset; |
| 242 | 241 | ||
| 243 | chip->rdev = regulator_register(&ad5398_reg, &config); | 242 | chip->rdev = devm_regulator_register(&client->dev, &ad5398_reg, |
| 243 | &config); | ||
| 244 | if (IS_ERR(chip->rdev)) { | 244 | if (IS_ERR(chip->rdev)) { |
| 245 | ret = PTR_ERR(chip->rdev); | ||
| 246 | dev_err(&client->dev, "failed to register %s %s\n", | 245 | dev_err(&client->dev, "failed to register %s %s\n", |
| 247 | id->name, ad5398_reg.name); | 246 | id->name, ad5398_reg.name); |
| 248 | goto err; | 247 | return PTR_ERR(chip->rdev); |
| 249 | } | 248 | } |
| 250 | 249 | ||
| 251 | i2c_set_clientdata(client, chip); | 250 | i2c_set_clientdata(client, chip); |
| 252 | dev_dbg(&client->dev, "%s regulator driver is registered.\n", id->name); | 251 | dev_dbg(&client->dev, "%s regulator driver is registered.\n", id->name); |
| 253 | return 0; | 252 | return 0; |
| 254 | |||
| 255 | err: | ||
| 256 | return ret; | ||
| 257 | } | ||
| 258 | |||
| 259 | static int ad5398_remove(struct i2c_client *client) | ||
| 260 | { | ||
| 261 | struct ad5398_chip_info *chip = i2c_get_clientdata(client); | ||
| 262 | |||
| 263 | regulator_unregister(chip->rdev); | ||
| 264 | return 0; | ||
| 265 | } | 253 | } |
| 266 | 254 | ||
| 267 | static struct i2c_driver ad5398_driver = { | 255 | static struct i2c_driver ad5398_driver = { |
| 268 | .probe = ad5398_probe, | 256 | .probe = ad5398_probe, |
| 269 | .remove = ad5398_remove, | ||
| 270 | .driver = { | 257 | .driver = { |
| 271 | .name = "ad5398", | 258 | .name = "ad5398", |
| 272 | }, | 259 | }, |
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index 0d4a8ccbb536..e42bfd17562a 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c | |||
| @@ -200,7 +200,7 @@ static int anatop_regulator_probe(struct platform_device *pdev) | |||
| 200 | config.regmap = sreg->anatop; | 200 | config.regmap = sreg->anatop; |
| 201 | 201 | ||
| 202 | /* register regulator */ | 202 | /* register regulator */ |
| 203 | rdev = regulator_register(rdesc, &config); | 203 | rdev = devm_regulator_register(dev, rdesc, &config); |
| 204 | if (IS_ERR(rdev)) { | 204 | if (IS_ERR(rdev)) { |
| 205 | dev_err(dev, "failed to register %s\n", | 205 | dev_err(dev, "failed to register %s\n", |
| 206 | rdesc->name); | 206 | rdesc->name); |
| @@ -223,7 +223,6 @@ static int anatop_regulator_remove(struct platform_device *pdev) | |||
| 223 | struct anatop_regulator *sreg = rdev_get_drvdata(rdev); | 223 | struct anatop_regulator *sreg = rdev_get_drvdata(rdev); |
| 224 | const char *name = sreg->name; | 224 | const char *name = sreg->name; |
| 225 | 225 | ||
| 226 | regulator_unregister(rdev); | ||
| 227 | kfree(name); | 226 | kfree(name); |
| 228 | 227 | ||
| 229 | return 0; | 228 | return 0; |
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c index 81d8681c3195..4f6c2055f6b2 100644 --- a/drivers/regulator/arizona-ldo1.c +++ b/drivers/regulator/arizona-ldo1.c | |||
| @@ -226,7 +226,7 @@ static int arizona_ldo1_probe(struct platform_device *pdev) | |||
| 226 | else | 226 | else |
| 227 | config.init_data = &ldo1->init_data; | 227 | config.init_data = &ldo1->init_data; |
| 228 | 228 | ||
| 229 | ldo1->regulator = regulator_register(desc, &config); | 229 | ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config); |
| 230 | if (IS_ERR(ldo1->regulator)) { | 230 | if (IS_ERR(ldo1->regulator)) { |
| 231 | ret = PTR_ERR(ldo1->regulator); | 231 | ret = PTR_ERR(ldo1->regulator); |
| 232 | dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n", | 232 | dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n", |
| @@ -239,18 +239,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev) | |||
| 239 | return 0; | 239 | return 0; |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | static int arizona_ldo1_remove(struct platform_device *pdev) | ||
| 243 | { | ||
| 244 | struct arizona_ldo1 *ldo1 = platform_get_drvdata(pdev); | ||
| 245 | |||
| 246 | regulator_unregister(ldo1->regulator); | ||
| 247 | |||
| 248 | return 0; | ||
| 249 | } | ||
| 250 | |||
| 251 | static struct platform_driver arizona_ldo1_driver = { | 242 | static struct platform_driver arizona_ldo1_driver = { |
| 252 | .probe = arizona_ldo1_probe, | 243 | .probe = arizona_ldo1_probe, |
| 253 | .remove = arizona_ldo1_remove, | ||
| 254 | .driver = { | 244 | .driver = { |
| 255 | .name = "arizona-ldo1", | 245 | .name = "arizona-ldo1", |
| 256 | .owner = THIS_MODULE, | 246 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c index e87536bf0bed..724706a97dc4 100644 --- a/drivers/regulator/arizona-micsupp.c +++ b/drivers/regulator/arizona-micsupp.c | |||
| @@ -225,7 +225,9 @@ static int arizona_micsupp_probe(struct platform_device *pdev) | |||
| 225 | regmap_update_bits(arizona->regmap, ARIZONA_MIC_CHARGE_PUMP_1, | 225 | regmap_update_bits(arizona->regmap, ARIZONA_MIC_CHARGE_PUMP_1, |
| 226 | ARIZONA_CPMIC_BYPASS, 0); | 226 | ARIZONA_CPMIC_BYPASS, 0); |
| 227 | 227 | ||
| 228 | micsupp->regulator = regulator_register(&arizona_micsupp, &config); | 228 | micsupp->regulator = devm_regulator_register(&pdev->dev, |
| 229 | &arizona_micsupp, | ||
| 230 | &config); | ||
| 229 | if (IS_ERR(micsupp->regulator)) { | 231 | if (IS_ERR(micsupp->regulator)) { |
| 230 | ret = PTR_ERR(micsupp->regulator); | 232 | ret = PTR_ERR(micsupp->regulator); |
| 231 | dev_err(arizona->dev, "Failed to register mic supply: %d\n", | 233 | dev_err(arizona->dev, "Failed to register mic supply: %d\n", |
| @@ -238,18 +240,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev) | |||
| 238 | return 0; | 240 | return 0; |
| 239 | } | 241 | } |
| 240 | 242 | ||
| 241 | static int arizona_micsupp_remove(struct platform_device *pdev) | ||
| 242 | { | ||
| 243 | struct arizona_micsupp *micsupp = platform_get_drvdata(pdev); | ||
| 244 | |||
| 245 | regulator_unregister(micsupp->regulator); | ||
| 246 | |||
| 247 | return 0; | ||
| 248 | } | ||
| 249 | |||
| 250 | static struct platform_driver arizona_micsupp_driver = { | 243 | static struct platform_driver arizona_micsupp_driver = { |
| 251 | .probe = arizona_micsupp_probe, | 244 | .probe = arizona_micsupp_probe, |
| 252 | .remove = arizona_micsupp_remove, | ||
| 253 | .driver = { | 245 | .driver = { |
| 254 | .name = "arizona-micsupp", | 246 | .name = "arizona-micsupp", |
| 255 | .owner = THIS_MODULE, | 247 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/as3711-regulator.c b/drivers/regulator/as3711-regulator.c index 8406cd745da2..fb27e6c8887c 100644 --- a/drivers/regulator/as3711-regulator.c +++ b/drivers/regulator/as3711-regulator.c | |||
| @@ -273,33 +273,16 @@ static int as3711_regulator_probe(struct platform_device *pdev) | |||
| 273 | config.regmap = as3711->regmap; | 273 | config.regmap = as3711->regmap; |
| 274 | config.of_node = of_node[id]; | 274 | config.of_node = of_node[id]; |
| 275 | 275 | ||
| 276 | rdev = regulator_register(&ri->desc, &config); | 276 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
| 277 | if (IS_ERR(rdev)) { | 277 | if (IS_ERR(rdev)) { |
| 278 | dev_err(&pdev->dev, "Failed to register regulator %s\n", | 278 | dev_err(&pdev->dev, "Failed to register regulator %s\n", |
| 279 | ri->desc.name); | 279 | ri->desc.name); |
| 280 | ret = PTR_ERR(rdev); | 280 | return PTR_ERR(rdev); |
| 281 | goto eregreg; | ||
| 282 | } | 281 | } |
| 283 | reg->rdev = rdev; | 282 | reg->rdev = rdev; |
| 284 | } | 283 | } |
| 285 | platform_set_drvdata(pdev, regs); | 284 | platform_set_drvdata(pdev, regs); |
| 286 | return 0; | 285 | 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 | } | 286 | } |
| 304 | 287 | ||
| 305 | static struct platform_driver as3711_regulator_driver = { | 288 | static struct platform_driver as3711_regulator_driver = { |
| @@ -308,7 +291,6 @@ static struct platform_driver as3711_regulator_driver = { | |||
| 308 | .owner = THIS_MODULE, | 291 | .owner = THIS_MODULE, |
| 309 | }, | 292 | }, |
| 310 | .probe = as3711_regulator_probe, | 293 | .probe = as3711_regulator_probe, |
| 311 | .remove = as3711_regulator_remove, | ||
| 312 | }; | 294 | }; |
| 313 | 295 | ||
| 314 | static int __init as3711_regulator_init(void) | 296 | static int __init as3711_regulator_init(void) |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index a01b8b3b70ca..906deb7354ed 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #include <trace/events/regulator.h> | 36 | #include <trace/events/regulator.h> |
| 37 | 37 | ||
| 38 | #include "dummy.h" | 38 | #include "dummy.h" |
| 39 | #include "internal.h" | ||
| 39 | 40 | ||
| 40 | #define rdev_crit(rdev, fmt, ...) \ | 41 | #define rdev_crit(rdev, fmt, ...) \ |
| 41 | pr_crit("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__) | 42 | pr_crit("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__) |
| @@ -82,25 +83,6 @@ struct regulator_enable_gpio { | |||
| 82 | unsigned int ena_gpio_invert:1; | 83 | unsigned int ena_gpio_invert:1; |
| 83 | }; | 84 | }; |
| 84 | 85 | ||
| 85 | /* | ||
| 86 | * struct regulator | ||
| 87 | * | ||
| 88 | * One for each consumer device. | ||
| 89 | */ | ||
| 90 | struct regulator { | ||
| 91 | struct device *dev; | ||
| 92 | struct list_head list; | ||
| 93 | unsigned int always_on:1; | ||
| 94 | unsigned int bypass:1; | ||
| 95 | int uA_load; | ||
| 96 | int min_uV; | ||
| 97 | int max_uV; | ||
| 98 | char *supply_name; | ||
| 99 | struct device_attribute dev_attr; | ||
| 100 | struct regulator_dev *rdev; | ||
| 101 | struct dentry *debugfs; | ||
| 102 | }; | ||
| 103 | |||
| 104 | static int _regulator_is_enabled(struct regulator_dev *rdev); | 86 | static int _regulator_is_enabled(struct regulator_dev *rdev); |
| 105 | static int _regulator_disable(struct regulator_dev *rdev); | 87 | static int _regulator_disable(struct regulator_dev *rdev); |
| 106 | static int _regulator_get_voltage(struct regulator_dev *rdev); | 88 | static int _regulator_get_voltage(struct regulator_dev *rdev); |
| @@ -1353,40 +1335,6 @@ struct regulator *regulator_get(struct device *dev, const char *id) | |||
| 1353 | } | 1335 | } |
| 1354 | EXPORT_SYMBOL_GPL(regulator_get); | 1336 | EXPORT_SYMBOL_GPL(regulator_get); |
| 1355 | 1337 | ||
| 1356 | static void devm_regulator_release(struct device *dev, void *res) | ||
| 1357 | { | ||
| 1358 | regulator_put(*(struct regulator **)res); | ||
| 1359 | } | ||
| 1360 | |||
| 1361 | /** | ||
| 1362 | * devm_regulator_get - Resource managed regulator_get() | ||
| 1363 | * @dev: device for regulator "consumer" | ||
| 1364 | * @id: Supply name or regulator ID. | ||
| 1365 | * | ||
| 1366 | * Managed regulator_get(). Regulators returned from this function are | ||
| 1367 | * automatically regulator_put() on driver detach. See regulator_get() for more | ||
| 1368 | * information. | ||
| 1369 | */ | ||
| 1370 | struct regulator *devm_regulator_get(struct device *dev, const char *id) | ||
| 1371 | { | ||
| 1372 | struct regulator **ptr, *regulator; | ||
| 1373 | |||
| 1374 | ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); | ||
| 1375 | if (!ptr) | ||
| 1376 | return ERR_PTR(-ENOMEM); | ||
| 1377 | |||
| 1378 | regulator = regulator_get(dev, id); | ||
| 1379 | if (!IS_ERR(regulator)) { | ||
| 1380 | *ptr = regulator; | ||
| 1381 | devres_add(dev, ptr); | ||
| 1382 | } else { | ||
| 1383 | devres_free(ptr); | ||
| 1384 | } | ||
| 1385 | |||
| 1386 | return regulator; | ||
| 1387 | } | ||
| 1388 | EXPORT_SYMBOL_GPL(devm_regulator_get); | ||
| 1389 | |||
| 1390 | /** | 1338 | /** |
| 1391 | * regulator_get_exclusive - obtain exclusive access to a regulator. | 1339 | * regulator_get_exclusive - obtain exclusive access to a regulator. |
| 1392 | * @dev: device for regulator "consumer" | 1340 | * @dev: device for regulator "consumer" |
| @@ -1443,36 +1391,6 @@ struct regulator *regulator_get_optional(struct device *dev, const char *id) | |||
| 1443 | } | 1391 | } |
| 1444 | EXPORT_SYMBOL_GPL(regulator_get_optional); | 1392 | EXPORT_SYMBOL_GPL(regulator_get_optional); |
| 1445 | 1393 | ||
| 1446 | /** | ||
| 1447 | * devm_regulator_get_optional - Resource managed regulator_get_optional() | ||
| 1448 | * @dev: device for regulator "consumer" | ||
| 1449 | * @id: Supply name or regulator ID. | ||
| 1450 | * | ||
| 1451 | * Managed regulator_get_optional(). Regulators returned from this | ||
| 1452 | * function are automatically regulator_put() on driver detach. See | ||
| 1453 | * regulator_get_optional() for more information. | ||
| 1454 | */ | ||
| 1455 | struct regulator *devm_regulator_get_optional(struct device *dev, | ||
| 1456 | const char *id) | ||
| 1457 | { | ||
| 1458 | struct regulator **ptr, *regulator; | ||
| 1459 | |||
| 1460 | ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); | ||
| 1461 | if (!ptr) | ||
| 1462 | return ERR_PTR(-ENOMEM); | ||
| 1463 | |||
| 1464 | regulator = regulator_get_optional(dev, id); | ||
| 1465 | if (!IS_ERR(regulator)) { | ||
| 1466 | *ptr = regulator; | ||
| 1467 | devres_add(dev, ptr); | ||
| 1468 | } else { | ||
| 1469 | devres_free(ptr); | ||
| 1470 | } | ||
| 1471 | |||
| 1472 | return regulator; | ||
| 1473 | } | ||
| 1474 | EXPORT_SYMBOL_GPL(devm_regulator_get_optional); | ||
| 1475 | |||
| 1476 | /* Locks held by regulator_put() */ | 1394 | /* Locks held by regulator_put() */ |
| 1477 | static void _regulator_put(struct regulator *regulator) | 1395 | static void _regulator_put(struct regulator *regulator) |
| 1478 | { | 1396 | { |
| @@ -1499,36 +1417,6 @@ static void _regulator_put(struct regulator *regulator) | |||
| 1499 | } | 1417 | } |
| 1500 | 1418 | ||
| 1501 | /** | 1419 | /** |
| 1502 | * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive() | ||
| 1503 | * @dev: device for regulator "consumer" | ||
| 1504 | * @id: Supply name or regulator ID. | ||
| 1505 | * | ||
| 1506 | * Managed regulator_get_exclusive(). Regulators returned from this function | ||
| 1507 | * are automatically regulator_put() on driver detach. See regulator_get() for | ||
| 1508 | * more information. | ||
| 1509 | */ | ||
| 1510 | struct regulator *devm_regulator_get_exclusive(struct device *dev, | ||
| 1511 | const char *id) | ||
| 1512 | { | ||
| 1513 | struct regulator **ptr, *regulator; | ||
| 1514 | |||
| 1515 | ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); | ||
| 1516 | if (!ptr) | ||
| 1517 | return ERR_PTR(-ENOMEM); | ||
| 1518 | |||
| 1519 | regulator = _regulator_get(dev, id, 1); | ||
| 1520 | if (!IS_ERR(regulator)) { | ||
| 1521 | *ptr = regulator; | ||
| 1522 | devres_add(dev, ptr); | ||
| 1523 | } else { | ||
| 1524 | devres_free(ptr); | ||
| 1525 | } | ||
| 1526 | |||
| 1527 | return regulator; | ||
| 1528 | } | ||
| 1529 | EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); | ||
| 1530 | |||
| 1531 | /** | ||
| 1532 | * regulator_put - "free" the regulator source | 1420 | * regulator_put - "free" the regulator source |
| 1533 | * @regulator: regulator source | 1421 | * @regulator: regulator source |
| 1534 | * | 1422 | * |
| @@ -1544,35 +1432,6 @@ void regulator_put(struct regulator *regulator) | |||
| 1544 | } | 1432 | } |
| 1545 | EXPORT_SYMBOL_GPL(regulator_put); | 1433 | EXPORT_SYMBOL_GPL(regulator_put); |
| 1546 | 1434 | ||
| 1547 | static int devm_regulator_match(struct device *dev, void *res, void *data) | ||
| 1548 | { | ||
| 1549 | struct regulator **r = res; | ||
| 1550 | if (!r || !*r) { | ||
| 1551 | WARN_ON(!r || !*r); | ||
| 1552 | return 0; | ||
| 1553 | } | ||
| 1554 | return *r == data; | ||
| 1555 | } | ||
| 1556 | |||
| 1557 | /** | ||
| 1558 | * devm_regulator_put - Resource managed regulator_put() | ||
| 1559 | * @regulator: regulator to free | ||
| 1560 | * | ||
| 1561 | * Deallocate a regulator allocated with devm_regulator_get(). Normally | ||
| 1562 | * this function will not need to be called and the resource management | ||
| 1563 | * code will ensure that the resource is freed. | ||
| 1564 | */ | ||
| 1565 | void devm_regulator_put(struct regulator *regulator) | ||
| 1566 | { | ||
| 1567 | int rc; | ||
| 1568 | |||
| 1569 | rc = devres_release(regulator->dev, devm_regulator_release, | ||
| 1570 | devm_regulator_match, regulator); | ||
| 1571 | if (rc != 0) | ||
| 1572 | WARN_ON(rc); | ||
| 1573 | } | ||
| 1574 | EXPORT_SYMBOL_GPL(devm_regulator_put); | ||
| 1575 | |||
| 1576 | /* Manage enable GPIO list. Same GPIO pin can be shared among regulators */ | 1435 | /* Manage enable GPIO list. Same GPIO pin can be shared among regulators */ |
| 1577 | static int regulator_ena_gpio_request(struct regulator_dev *rdev, | 1436 | static int regulator_ena_gpio_request(struct regulator_dev *rdev, |
| 1578 | const struct regulator_config *config) | 1437 | const struct regulator_config *config) |
| @@ -2912,52 +2771,6 @@ err: | |||
| 2912 | } | 2771 | } |
| 2913 | EXPORT_SYMBOL_GPL(regulator_bulk_get); | 2772 | EXPORT_SYMBOL_GPL(regulator_bulk_get); |
| 2914 | 2773 | ||
| 2915 | /** | ||
| 2916 | * devm_regulator_bulk_get - managed get multiple regulator consumers | ||
| 2917 | * | ||
| 2918 | * @dev: Device to supply | ||
| 2919 | * @num_consumers: Number of consumers to register | ||
| 2920 | * @consumers: Configuration of consumers; clients are stored here. | ||
| 2921 | * | ||
| 2922 | * @return 0 on success, an errno on failure. | ||
| 2923 | * | ||
| 2924 | * This helper function allows drivers to get several regulator | ||
| 2925 | * consumers in one operation with management, the regulators will | ||
| 2926 | * automatically be freed when the device is unbound. If any of the | ||
| 2927 | * regulators cannot be acquired then any regulators that were | ||
| 2928 | * allocated will be freed before returning to the caller. | ||
| 2929 | */ | ||
| 2930 | int devm_regulator_bulk_get(struct device *dev, int num_consumers, | ||
| 2931 | struct regulator_bulk_data *consumers) | ||
| 2932 | { | ||
| 2933 | int i; | ||
| 2934 | int ret; | ||
| 2935 | |||
| 2936 | for (i = 0; i < num_consumers; i++) | ||
| 2937 | consumers[i].consumer = NULL; | ||
| 2938 | |||
| 2939 | for (i = 0; i < num_consumers; i++) { | ||
| 2940 | consumers[i].consumer = devm_regulator_get(dev, | ||
| 2941 | consumers[i].supply); | ||
| 2942 | if (IS_ERR(consumers[i].consumer)) { | ||
| 2943 | ret = PTR_ERR(consumers[i].consumer); | ||
| 2944 | dev_err(dev, "Failed to get supply '%s': %d\n", | ||
| 2945 | consumers[i].supply, ret); | ||
| 2946 | consumers[i].consumer = NULL; | ||
| 2947 | goto err; | ||
| 2948 | } | ||
| 2949 | } | ||
| 2950 | |||
| 2951 | return 0; | ||
| 2952 | |||
| 2953 | err: | ||
| 2954 | for (i = 0; i < num_consumers && consumers[i].consumer; i++) | ||
| 2955 | devm_regulator_put(consumers[i].consumer); | ||
| 2956 | |||
| 2957 | return ret; | ||
| 2958 | } | ||
| 2959 | EXPORT_SYMBOL_GPL(devm_regulator_bulk_get); | ||
| 2960 | |||
| 2961 | static void regulator_bulk_enable_async(void *data, async_cookie_t cookie) | 2774 | static void regulator_bulk_enable_async(void *data, async_cookie_t cookie) |
| 2962 | { | 2775 | { |
| 2963 | struct regulator_bulk_data *bulk = data; | 2776 | struct regulator_bulk_data *bulk = data; |
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c index f06854cf8cf5..c61d96e9d925 100644 --- a/drivers/regulator/da903x.c +++ b/drivers/regulator/da903x.c | |||
| @@ -463,7 +463,7 @@ static int da903x_regulator_probe(struct platform_device *pdev) | |||
| 463 | config.init_data = dev_get_platdata(&pdev->dev); | 463 | config.init_data = dev_get_platdata(&pdev->dev); |
| 464 | config.driver_data = ri; | 464 | config.driver_data = ri; |
| 465 | 465 | ||
| 466 | rdev = regulator_register(&ri->desc, &config); | 466 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
| 467 | if (IS_ERR(rdev)) { | 467 | if (IS_ERR(rdev)) { |
| 468 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 468 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
| 469 | ri->desc.name); | 469 | ri->desc.name); |
| @@ -474,21 +474,12 @@ static int da903x_regulator_probe(struct platform_device *pdev) | |||
| 474 | return 0; | 474 | return 0; |
| 475 | } | 475 | } |
| 476 | 476 | ||
| 477 | static int da903x_regulator_remove(struct platform_device *pdev) | ||
| 478 | { | ||
| 479 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
| 480 | |||
| 481 | regulator_unregister(rdev); | ||
| 482 | return 0; | ||
| 483 | } | ||
| 484 | |||
| 485 | static struct platform_driver da903x_regulator_driver = { | 477 | static struct platform_driver da903x_regulator_driver = { |
| 486 | .driver = { | 478 | .driver = { |
| 487 | .name = "da903x-regulator", | 479 | .name = "da903x-regulator", |
| 488 | .owner = THIS_MODULE, | 480 | .owner = THIS_MODULE, |
| 489 | }, | 481 | }, |
| 490 | .probe = da903x_regulator_probe, | 482 | .probe = da903x_regulator_probe, |
| 491 | .remove = da903x_regulator_remove, | ||
| 492 | }; | 483 | }; |
| 493 | 484 | ||
| 494 | static int __init da903x_regulator_init(void) | 485 | static int __init da903x_regulator_init(void) |
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c index 1e4d483f6163..c427e42472e8 100644 --- a/drivers/regulator/da9052-regulator.c +++ b/drivers/regulator/da9052-regulator.c | |||
| @@ -389,8 +389,9 @@ static int da9052_regulator_probe(struct platform_device *pdev) | |||
| 389 | #endif | 389 | #endif |
| 390 | } | 390 | } |
| 391 | 391 | ||
| 392 | regulator->rdev = regulator_register(®ulator->info->reg_desc, | 392 | regulator->rdev = devm_regulator_register(&pdev->dev, |
| 393 | &config); | 393 | ®ulator->info->reg_desc, |
| 394 | &config); | ||
| 394 | if (IS_ERR(regulator->rdev)) { | 395 | if (IS_ERR(regulator->rdev)) { |
| 395 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 396 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
| 396 | regulator->info->reg_desc.name); | 397 | regulator->info->reg_desc.name); |
| @@ -402,17 +403,8 @@ static int da9052_regulator_probe(struct platform_device *pdev) | |||
| 402 | return 0; | 403 | return 0; |
| 403 | } | 404 | } |
| 404 | 405 | ||
| 405 | static int da9052_regulator_remove(struct platform_device *pdev) | ||
| 406 | { | ||
| 407 | struct da9052_regulator *regulator = platform_get_drvdata(pdev); | ||
| 408 | |||
| 409 | regulator_unregister(regulator->rdev); | ||
| 410 | return 0; | ||
| 411 | } | ||
| 412 | |||
| 413 | static struct platform_driver da9052_regulator_driver = { | 406 | static struct platform_driver da9052_regulator_driver = { |
| 414 | .probe = da9052_regulator_probe, | 407 | .probe = da9052_regulator_probe, |
| 415 | .remove = da9052_regulator_remove, | ||
| 416 | .driver = { | 408 | .driver = { |
| 417 | .name = "da9052-regulator", | 409 | .name = "da9052-regulator", |
| 418 | .owner = THIS_MODULE, | 410 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/da9055-regulator.c b/drivers/regulator/da9055-regulator.c index 77b53e5a231c..7f340206d329 100644 --- a/drivers/regulator/da9055-regulator.c +++ b/drivers/regulator/da9055-regulator.c | |||
| @@ -564,13 +564,13 @@ static int da9055_regulator_probe(struct platform_device *pdev) | |||
| 564 | if (ret < 0) | 564 | if (ret < 0) |
| 565 | return ret; | 565 | return ret; |
| 566 | 566 | ||
| 567 | regulator->rdev = regulator_register(®ulator->info->reg_desc, | 567 | regulator->rdev = devm_regulator_register(&pdev->dev, |
| 568 | &config); | 568 | ®ulator->info->reg_desc, |
| 569 | &config); | ||
| 569 | if (IS_ERR(regulator->rdev)) { | 570 | if (IS_ERR(regulator->rdev)) { |
| 570 | dev_err(&pdev->dev, "Failed to register regulator %s\n", | 571 | dev_err(&pdev->dev, "Failed to register regulator %s\n", |
| 571 | regulator->info->reg_desc.name); | 572 | regulator->info->reg_desc.name); |
| 572 | ret = PTR_ERR(regulator->rdev); | 573 | return PTR_ERR(regulator->rdev); |
| 573 | return ret; | ||
| 574 | } | 574 | } |
| 575 | 575 | ||
| 576 | /* Only LDO 5 and 6 has got the over current interrupt */ | 576 | /* Only LDO 5 and 6 has got the over current interrupt */ |
| @@ -588,7 +588,7 @@ static int da9055_regulator_probe(struct platform_device *pdev) | |||
| 588 | dev_err(&pdev->dev, | 588 | dev_err(&pdev->dev, |
| 589 | "Failed to request Regulator IRQ %d: %d\n", | 589 | "Failed to request Regulator IRQ %d: %d\n", |
| 590 | irq, ret); | 590 | irq, ret); |
| 591 | goto err_regulator; | 591 | return ret; |
| 592 | } | 592 | } |
| 593 | } | 593 | } |
| 594 | } | 594 | } |
| @@ -596,24 +596,10 @@ static int da9055_regulator_probe(struct platform_device *pdev) | |||
| 596 | platform_set_drvdata(pdev, regulator); | 596 | platform_set_drvdata(pdev, regulator); |
| 597 | 597 | ||
| 598 | return 0; | 598 | return 0; |
| 599 | |||
| 600 | err_regulator: | ||
| 601 | regulator_unregister(regulator->rdev); | ||
| 602 | return ret; | ||
| 603 | } | ||
| 604 | |||
| 605 | static int da9055_regulator_remove(struct platform_device *pdev) | ||
| 606 | { | ||
| 607 | struct da9055_regulator *regulator = platform_get_drvdata(pdev); | ||
| 608 | |||
| 609 | regulator_unregister(regulator->rdev); | ||
| 610 | |||
| 611 | return 0; | ||
| 612 | } | 599 | } |
| 613 | 600 | ||
| 614 | static struct platform_driver da9055_regulator_driver = { | 601 | static struct platform_driver da9055_regulator_driver = { |
| 615 | .probe = da9055_regulator_probe, | 602 | .probe = da9055_regulator_probe, |
| 616 | .remove = da9055_regulator_remove, | ||
| 617 | .driver = { | 603 | .driver = { |
| 618 | .name = "da9055-regulator", | 604 | .name = "da9055-regulator", |
| 619 | .owner = THIS_MODULE, | 605 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c new file mode 100644 index 000000000000..2672a029fa25 --- /dev/null +++ b/drivers/regulator/devres.c | |||
| @@ -0,0 +1,252 @@ | |||
| 1 | /* | ||
| 2 | * devres.c -- Voltage/Current Regulator framework devres implementation. | ||
| 3 | * | ||
| 4 | * Copyright 2013 Linaro Ltd | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify it | ||
| 7 | * under the terms of the GNU General Public License as published by the | ||
| 8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 9 | * option) any later version. | ||
| 10 | * | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/kernel.h> | ||
| 14 | #include <linux/err.h> | ||
| 15 | #include <linux/regmap.h> | ||
| 16 | #include <linux/regulator/consumer.h> | ||
| 17 | #include <linux/regulator/driver.h> | ||
| 18 | #include <linux/module.h> | ||
| 19 | |||
| 20 | #include "internal.h" | ||
| 21 | |||
| 22 | enum { | ||
| 23 | NORMAL_GET, | ||
| 24 | EXCLUSIVE_GET, | ||
| 25 | OPTIONAL_GET, | ||
| 26 | }; | ||
| 27 | |||
| 28 | static void devm_regulator_release(struct device *dev, void *res) | ||
| 29 | { | ||
| 30 | regulator_put(*(struct regulator **)res); | ||
| 31 | } | ||
| 32 | |||
| 33 | static struct regulator *_devm_regulator_get(struct device *dev, const char *id, | ||
| 34 | int get_type) | ||
| 35 | { | ||
| 36 | struct regulator **ptr, *regulator; | ||
| 37 | |||
| 38 | ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL); | ||
| 39 | if (!ptr) | ||
| 40 | return ERR_PTR(-ENOMEM); | ||
| 41 | |||
| 42 | switch (get_type) { | ||
| 43 | case NORMAL_GET: | ||
| 44 | regulator = regulator_get(dev, id); | ||
| 45 | break; | ||
| 46 | case EXCLUSIVE_GET: | ||
| 47 | regulator = regulator_get_exclusive(dev, id); | ||
| 48 | break; | ||
| 49 | case OPTIONAL_GET: | ||
| 50 | regulator = regulator_get_optional(dev, id); | ||
| 51 | break; | ||
| 52 | default: | ||
| 53 | regulator = ERR_PTR(-EINVAL); | ||
| 54 | } | ||
| 55 | |||
| 56 | if (!IS_ERR(regulator)) { | ||
| 57 | *ptr = regulator; | ||
| 58 | devres_add(dev, ptr); | ||
| 59 | } else { | ||
| 60 | devres_free(ptr); | ||
| 61 | } | ||
| 62 | |||
| 63 | return regulator; | ||
| 64 | } | ||
| 65 | |||
| 66 | /** | ||
| 67 | * devm_regulator_get - Resource managed regulator_get() | ||
| 68 | * @dev: device for regulator "consumer" | ||
| 69 | * @id: Supply name or regulator ID. | ||
| 70 | * | ||
| 71 | * Managed regulator_get(). Regulators returned from this function are | ||
| 72 | * automatically regulator_put() on driver detach. See regulator_get() for more | ||
| 73 | * information. | ||
| 74 | */ | ||
| 75 | struct regulator *devm_regulator_get(struct device *dev, const char *id) | ||
| 76 | { | ||
| 77 | return _devm_regulator_get(dev, id, NORMAL_GET); | ||
| 78 | } | ||
| 79 | EXPORT_SYMBOL_GPL(devm_regulator_get); | ||
| 80 | |||
| 81 | /** | ||
| 82 | * devm_regulator_get_exclusive - Resource managed regulator_get_exclusive() | ||
| 83 | * @dev: device for regulator "consumer" | ||
| 84 | * @id: Supply name or regulator ID. | ||
| 85 | * | ||
| 86 | * Managed regulator_get_exclusive(). Regulators returned from this function | ||
| 87 | * are automatically regulator_put() on driver detach. See regulator_get() for | ||
| 88 | * more information. | ||
| 89 | */ | ||
| 90 | struct regulator *devm_regulator_get_exclusive(struct device *dev, | ||
| 91 | const char *id) | ||
| 92 | { | ||
| 93 | return _devm_regulator_get(dev, id, EXCLUSIVE_GET); | ||
| 94 | } | ||
| 95 | EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive); | ||
| 96 | |||
| 97 | /** | ||
| 98 | * devm_regulator_get_optional - Resource managed regulator_get_optional() | ||
| 99 | * @dev: device for regulator "consumer" | ||
| 100 | * @id: Supply name or regulator ID. | ||
| 101 | * | ||
| 102 | * Managed regulator_get_optional(). Regulators returned from this | ||
| 103 | * function are automatically regulator_put() on driver detach. See | ||
| 104 | * regulator_get_optional() for more information. | ||
| 105 | */ | ||
| 106 | struct regulator *devm_regulator_get_optional(struct device *dev, | ||
| 107 | const char *id) | ||
| 108 | { | ||
| 109 | return _devm_regulator_get(dev, id, OPTIONAL_GET); | ||
| 110 | } | ||
| 111 | EXPORT_SYMBOL_GPL(devm_regulator_get_optional); | ||
| 112 | |||
| 113 | static int devm_regulator_match(struct device *dev, void *res, void *data) | ||
| 114 | { | ||
| 115 | struct regulator **r = res; | ||
| 116 | if (!r || !*r) { | ||
| 117 | WARN_ON(!r || !*r); | ||
| 118 | return 0; | ||
| 119 | } | ||
| 120 | return *r == data; | ||
| 121 | } | ||
| 122 | |||
| 123 | /** | ||
| 124 | * devm_regulator_put - Resource managed regulator_put() | ||
| 125 | * @regulator: regulator to free | ||
| 126 | * | ||
| 127 | * Deallocate a regulator allocated with devm_regulator_get(). Normally | ||
| 128 | * this function will not need to be called and the resource management | ||
| 129 | * code will ensure that the resource is freed. | ||
| 130 | */ | ||
| 131 | void devm_regulator_put(struct regulator *regulator) | ||
| 132 | { | ||
| 133 | int rc; | ||
| 134 | |||
| 135 | rc = devres_release(regulator->dev, devm_regulator_release, | ||
| 136 | devm_regulator_match, regulator); | ||
| 137 | if (rc != 0) | ||
| 138 | WARN_ON(rc); | ||
| 139 | } | ||
| 140 | EXPORT_SYMBOL_GPL(devm_regulator_put); | ||
| 141 | |||
| 142 | /** | ||
| 143 | * devm_regulator_bulk_get - managed get multiple regulator consumers | ||
| 144 | * | ||
| 145 | * @dev: Device to supply | ||
| 146 | * @num_consumers: Number of consumers to register | ||
| 147 | * @consumers: Configuration of consumers; clients are stored here. | ||
| 148 | * | ||
| 149 | * @return 0 on success, an errno on failure. | ||
| 150 | * | ||
| 151 | * This helper function allows drivers to get several regulator | ||
| 152 | * consumers in one operation with management, the regulators will | ||
| 153 | * automatically be freed when the device is unbound. If any of the | ||
| 154 | * regulators cannot be acquired then any regulators that were | ||
| 155 | * allocated will be freed before returning to the caller. | ||
| 156 | */ | ||
| 157 | int devm_regulator_bulk_get(struct device *dev, int num_consumers, | ||
| 158 | struct regulator_bulk_data *consumers) | ||
| 159 | { | ||
| 160 | int i; | ||
| 161 | int ret; | ||
| 162 | |||
| 163 | for (i = 0; i < num_consumers; i++) | ||
| 164 | consumers[i].consumer = NULL; | ||
| 165 | |||
| 166 | for (i = 0; i < num_consumers; i++) { | ||
| 167 | consumers[i].consumer = devm_regulator_get(dev, | ||
| 168 | consumers[i].supply); | ||
| 169 | if (IS_ERR(consumers[i].consumer)) { | ||
| 170 | ret = PTR_ERR(consumers[i].consumer); | ||
| 171 | dev_err(dev, "Failed to get supply '%s': %d\n", | ||
| 172 | consumers[i].supply, ret); | ||
| 173 | consumers[i].consumer = NULL; | ||
| 174 | goto err; | ||
| 175 | } | ||
| 176 | } | ||
| 177 | |||
| 178 | return 0; | ||
| 179 | |||
| 180 | err: | ||
| 181 | for (i = 0; i < num_consumers && consumers[i].consumer; i++) | ||
| 182 | devm_regulator_put(consumers[i].consumer); | ||
| 183 | |||
| 184 | return ret; | ||
| 185 | } | ||
| 186 | EXPORT_SYMBOL_GPL(devm_regulator_bulk_get); | ||
| 187 | |||
| 188 | static void devm_rdev_release(struct device *dev, void *res) | ||
| 189 | { | ||
| 190 | regulator_unregister(*(struct regulator_dev **)res); | ||
| 191 | } | ||
| 192 | |||
| 193 | /** | ||
| 194 | * devm_regulator_register - Resource managed regulator_register() | ||
| 195 | * @regulator_desc: regulator to register | ||
| 196 | * @config: runtime configuration for regulator | ||
| 197 | * | ||
| 198 | * Called by regulator drivers to register a regulator. Returns a | ||
| 199 | * valid pointer to struct regulator_dev on success or an ERR_PTR() on | ||
| 200 | * error. The regulator will automatically be released when the device | ||
| 201 | * is unbound. | ||
| 202 | */ | ||
| 203 | struct regulator_dev *devm_regulator_register(struct device *dev, | ||
| 204 | const struct regulator_desc *regulator_desc, | ||
| 205 | const struct regulator_config *config) | ||
| 206 | { | ||
| 207 | struct regulator_dev **ptr, *rdev; | ||
| 208 | |||
| 209 | ptr = devres_alloc(devm_rdev_release, sizeof(*ptr), | ||
| 210 | GFP_KERNEL); | ||
| 211 | if (!ptr) | ||
| 212 | return ERR_PTR(-ENOMEM); | ||
| 213 | |||
| 214 | rdev = regulator_register(regulator_desc, config); | ||
| 215 | if (!IS_ERR(rdev)) { | ||
| 216 | *ptr = rdev; | ||
| 217 | devres_add(dev, ptr); | ||
| 218 | } else { | ||
| 219 | devres_free(ptr); | ||
| 220 | } | ||
| 221 | |||
| 222 | return rdev; | ||
| 223 | } | ||
| 224 | EXPORT_SYMBOL_GPL(devm_regulator_register); | ||
| 225 | |||
| 226 | static int devm_rdev_match(struct device *dev, void *res, void *data) | ||
| 227 | { | ||
| 228 | struct regulator_dev **r = res; | ||
| 229 | if (!r || !*r) { | ||
| 230 | WARN_ON(!r || !*r); | ||
| 231 | return 0; | ||
| 232 | } | ||
| 233 | return *r == data; | ||
| 234 | } | ||
| 235 | |||
| 236 | /** | ||
| 237 | * devm_regulator_unregister - Resource managed regulator_unregister() | ||
| 238 | * @regulator: regulator to free | ||
| 239 | * | ||
| 240 | * Unregister a regulator registered with devm_regulator_register(). | ||
| 241 | * Normally this function will not need to be called and the resource | ||
| 242 | * management code will ensure that the resource is freed. | ||
| 243 | */ | ||
| 244 | void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev) | ||
| 245 | { | ||
| 246 | int rc; | ||
| 247 | |||
| 248 | rc = devres_release(dev, devm_rdev_release, devm_rdev_match, rdev); | ||
| 249 | if (rc != 0) | ||
| 250 | WARN_ON(rc); | ||
| 251 | } | ||
| 252 | EXPORT_SYMBOL_GPL(devm_regulator_unregister); | ||
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c index 70b7220c587f..7ca3d9e3b0fe 100644 --- a/drivers/regulator/fan53555.c +++ b/drivers/regulator/fan53555.c | |||
| @@ -218,9 +218,8 @@ static int fan53555_regulator_register(struct fan53555_device_info *di, | |||
| 218 | rdesc->vsel_mask = VSEL_NSEL_MASK; | 218 | rdesc->vsel_mask = VSEL_NSEL_MASK; |
| 219 | rdesc->owner = THIS_MODULE; | 219 | rdesc->owner = THIS_MODULE; |
| 220 | 220 | ||
| 221 | di->rdev = regulator_register(&di->desc, config); | 221 | di->rdev = devm_regulator_register(di->dev, &di->desc, config); |
| 222 | return PTR_ERR_OR_ZERO(di->rdev); | 222 | return PTR_ERR_OR_ZERO(di->rdev); |
| 223 | |||
| 224 | } | 223 | } |
| 225 | 224 | ||
| 226 | static struct regmap_config fan53555_regmap_config = { | 225 | static struct regmap_config fan53555_regmap_config = { |
| @@ -291,14 +290,6 @@ static int fan53555_regulator_probe(struct i2c_client *client, | |||
| 291 | 290 | ||
| 292 | } | 291 | } |
| 293 | 292 | ||
| 294 | static int fan53555_regulator_remove(struct i2c_client *client) | ||
| 295 | { | ||
| 296 | struct fan53555_device_info *di = i2c_get_clientdata(client); | ||
| 297 | |||
| 298 | regulator_unregister(di->rdev); | ||
| 299 | return 0; | ||
| 300 | } | ||
| 301 | |||
| 302 | static const struct i2c_device_id fan53555_id[] = { | 293 | static const struct i2c_device_id fan53555_id[] = { |
| 303 | {"fan53555", -1}, | 294 | {"fan53555", -1}, |
| 304 | { }, | 295 | { }, |
| @@ -309,7 +300,6 @@ static struct i2c_driver fan53555_regulator_driver = { | |||
| 309 | .name = "fan53555-regulator", | 300 | .name = "fan53555-regulator", |
| 310 | }, | 301 | }, |
| 311 | .probe = fan53555_regulator_probe, | 302 | .probe = fan53555_regulator_probe, |
| 312 | .remove = fan53555_regulator_remove, | ||
| 313 | .id_table = fan53555_id, | 303 | .id_table = fan53555_id, |
| 314 | }; | 304 | }; |
| 315 | 305 | ||
diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h new file mode 100644 index 000000000000..84bbda10c396 --- /dev/null +++ b/drivers/regulator/internal.h | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | /* | ||
| 2 | * internal.h -- Voltage/Current Regulator framework internal code | ||
| 3 | * | ||
| 4 | * Copyright 2007, 2008 Wolfson Microelectronics PLC. | ||
| 5 | * Copyright 2008 SlimLogic Ltd. | ||
| 6 | * | ||
| 7 | * Author: Liam Girdwood <lrg@slimlogic.co.uk> | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify it | ||
| 10 | * under the terms of the GNU General Public License as published by the | ||
| 11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 12 | * option) any later version. | ||
| 13 | * | ||
| 14 | */ | ||
| 15 | |||
| 16 | #ifndef __REGULATOR_INTERNAL_H | ||
| 17 | #define __REGULATOR_INTERNAL_H | ||
| 18 | |||
| 19 | /* | ||
| 20 | * struct regulator | ||
| 21 | * | ||
| 22 | * One for each consumer device. | ||
| 23 | */ | ||
| 24 | struct regulator { | ||
| 25 | struct device *dev; | ||
| 26 | struct list_head list; | ||
| 27 | unsigned int always_on:1; | ||
| 28 | unsigned int bypass:1; | ||
| 29 | int uA_load; | ||
| 30 | int min_uV; | ||
| 31 | int max_uV; | ||
| 32 | char *supply_name; | ||
| 33 | struct device_attribute dev_attr; | ||
| 34 | struct regulator_dev *rdev; | ||
| 35 | struct dentry *debugfs; | ||
| 36 | }; | ||
| 37 | |||
| 38 | #endif | ||
diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c index 88c1a3acf563..6e5da95fa025 100644 --- a/drivers/regulator/isl6271a-regulator.c +++ b/drivers/regulator/isl6271a-regulator.c | |||
| @@ -112,7 +112,7 @@ static int isl6271a_probe(struct i2c_client *i2c, | |||
| 112 | struct regulator_config config = { }; | 112 | struct regulator_config config = { }; |
| 113 | struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev); | 113 | struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev); |
| 114 | struct isl_pmic *pmic; | 114 | struct isl_pmic *pmic; |
| 115 | int err, i; | 115 | int i; |
| 116 | 116 | ||
| 117 | if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | 117 | if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) |
| 118 | return -EIO; | 118 | return -EIO; |
| @@ -133,32 +133,17 @@ static int isl6271a_probe(struct i2c_client *i2c, | |||
| 133 | config.init_data = NULL; | 133 | config.init_data = NULL; |
| 134 | config.driver_data = pmic; | 134 | config.driver_data = pmic; |
| 135 | 135 | ||
| 136 | pmic->rdev[i] = regulator_register(&isl_rd[i], &config); | 136 | pmic->rdev[i] = devm_regulator_register(&i2c->dev, &isl_rd[i], |
| 137 | &config); | ||
| 137 | if (IS_ERR(pmic->rdev[i])) { | 138 | if (IS_ERR(pmic->rdev[i])) { |
| 138 | dev_err(&i2c->dev, "failed to register %s\n", id->name); | 139 | dev_err(&i2c->dev, "failed to register %s\n", id->name); |
| 139 | err = PTR_ERR(pmic->rdev[i]); | 140 | return PTR_ERR(pmic->rdev[i]); |
| 140 | goto error; | ||
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | i2c_set_clientdata(i2c, pmic); | 144 | i2c_set_clientdata(i2c, pmic); |
| 145 | 145 | ||
| 146 | return 0; | 146 | return 0; |
| 147 | |||
| 148 | error: | ||
| 149 | while (--i >= 0) | ||
| 150 | regulator_unregister(pmic->rdev[i]); | ||
| 151 | return err; | ||
| 152 | } | ||
| 153 | |||
| 154 | static int isl6271a_remove(struct i2c_client *i2c) | ||
| 155 | { | ||
| 156 | struct isl_pmic *pmic = i2c_get_clientdata(i2c); | ||
| 157 | int i; | ||
| 158 | |||
| 159 | for (i = 0; i < 3; i++) | ||
| 160 | regulator_unregister(pmic->rdev[i]); | ||
| 161 | return 0; | ||
| 162 | } | 147 | } |
| 163 | 148 | ||
| 164 | static const struct i2c_device_id isl6271a_id[] = { | 149 | static const struct i2c_device_id isl6271a_id[] = { |
| @@ -174,7 +159,6 @@ static struct i2c_driver isl6271a_i2c_driver = { | |||
| 174 | .owner = THIS_MODULE, | 159 | .owner = THIS_MODULE, |
| 175 | }, | 160 | }, |
| 176 | .probe = isl6271a_probe, | 161 | .probe = isl6271a_probe, |
| 177 | .remove = isl6271a_remove, | ||
| 178 | .id_table = isl6271a_id, | 162 | .id_table = isl6271a_id, |
| 179 | }; | 163 | }; |
| 180 | 164 | ||
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index 3a599ee0a456..e242dd316d36 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c | |||
| @@ -166,7 +166,7 @@ static int max1586_pmic_probe(struct i2c_client *client, | |||
| 166 | struct max1586_platform_data *pdata = dev_get_platdata(&client->dev); | 166 | struct max1586_platform_data *pdata = dev_get_platdata(&client->dev); |
| 167 | struct regulator_config config = { }; | 167 | struct regulator_config config = { }; |
| 168 | struct max1586_data *max1586; | 168 | struct max1586_data *max1586; |
| 169 | int i, id, ret = -ENOMEM; | 169 | int i, id; |
| 170 | 170 | ||
| 171 | max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) + | 171 | max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) + |
| 172 | sizeof(struct regulator_dev *) * (MAX1586_V6 + 1), | 172 | sizeof(struct regulator_dev *) * (MAX1586_V6 + 1), |
| @@ -193,7 +193,7 @@ static int max1586_pmic_probe(struct i2c_client *client, | |||
| 193 | continue; | 193 | continue; |
| 194 | if (id < MAX1586_V3 || id > MAX1586_V6) { | 194 | if (id < MAX1586_V3 || id > MAX1586_V6) { |
| 195 | dev_err(&client->dev, "invalid regulator id %d\n", id); | 195 | dev_err(&client->dev, "invalid regulator id %d\n", id); |
| 196 | goto err; | 196 | return -EINVAL; |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | if (id == MAX1586_V3) { | 199 | if (id == MAX1586_V3) { |
| @@ -207,33 +207,18 @@ static int max1586_pmic_probe(struct i2c_client *client, | |||
| 207 | config.init_data = pdata->subdevs[i].platform_data; | 207 | config.init_data = pdata->subdevs[i].platform_data; |
| 208 | config.driver_data = max1586; | 208 | config.driver_data = max1586; |
| 209 | 209 | ||
| 210 | rdev[i] = regulator_register(&max1586_reg[id], &config); | 210 | rdev[i] = devm_regulator_register(&client->dev, |
| 211 | &max1586_reg[id], &config); | ||
| 211 | if (IS_ERR(rdev[i])) { | 212 | if (IS_ERR(rdev[i])) { |
| 212 | ret = PTR_ERR(rdev[i]); | ||
| 213 | dev_err(&client->dev, "failed to register %s\n", | 213 | dev_err(&client->dev, "failed to register %s\n", |
| 214 | max1586_reg[id].name); | 214 | max1586_reg[id].name); |
| 215 | goto err; | 215 | return PTR_ERR(rdev[i]); |
| 216 | } | 216 | } |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | i2c_set_clientdata(client, max1586); | 219 | i2c_set_clientdata(client, max1586); |
| 220 | dev_info(&client->dev, "Maxim 1586 regulator driver loaded\n"); | 220 | dev_info(&client->dev, "Maxim 1586 regulator driver loaded\n"); |
| 221 | return 0; | 221 | return 0; |
| 222 | |||
| 223 | err: | ||
| 224 | while (--i >= 0) | ||
| 225 | regulator_unregister(rdev[i]); | ||
| 226 | return ret; | ||
| 227 | } | ||
| 228 | |||
| 229 | static int max1586_pmic_remove(struct i2c_client *client) | ||
| 230 | { | ||
| 231 | struct max1586_data *max1586 = i2c_get_clientdata(client); | ||
| 232 | int i; | ||
| 233 | |||
| 234 | for (i = 0; i <= MAX1586_V6; i++) | ||
| 235 | regulator_unregister(max1586->rdev[i]); | ||
| 236 | return 0; | ||
| 237 | } | 222 | } |
| 238 | 223 | ||
| 239 | static const struct i2c_device_id max1586_id[] = { | 224 | static const struct i2c_device_id max1586_id[] = { |
| @@ -244,7 +229,6 @@ MODULE_DEVICE_TABLE(i2c, max1586_id); | |||
| 244 | 229 | ||
| 245 | static struct i2c_driver max1586_pmic_driver = { | 230 | static struct i2c_driver max1586_pmic_driver = { |
| 246 | .probe = max1586_pmic_probe, | 231 | .probe = max1586_pmic_probe, |
| 247 | .remove = max1586_pmic_remove, | ||
| 248 | .driver = { | 232 | .driver = { |
| 249 | .name = "max1586", | 233 | .name = "max1586", |
| 250 | .owner = THIS_MODULE, | 234 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c index f563057e5690..ae001ccf26f4 100644 --- a/drivers/regulator/max77686.c +++ b/drivers/regulator/max77686.c | |||
| @@ -478,32 +478,16 @@ static int max77686_pmic_probe(struct platform_device *pdev) | |||
| 478 | config.of_node = pdata->regulators[i].of_node; | 478 | config.of_node = pdata->regulators[i].of_node; |
| 479 | 479 | ||
| 480 | max77686->opmode[i] = regulators[i].enable_mask; | 480 | max77686->opmode[i] = regulators[i].enable_mask; |
| 481 | max77686->rdev[i] = regulator_register(®ulators[i], &config); | 481 | max77686->rdev[i] = devm_regulator_register(&pdev->dev, |
| 482 | ®ulators[i], &config); | ||
| 482 | if (IS_ERR(max77686->rdev[i])) { | 483 | if (IS_ERR(max77686->rdev[i])) { |
| 483 | ret = PTR_ERR(max77686->rdev[i]); | ||
| 484 | dev_err(&pdev->dev, | 484 | dev_err(&pdev->dev, |
| 485 | "regulator init failed for %d\n", i); | 485 | "regulator init failed for %d\n", i); |
| 486 | max77686->rdev[i] = NULL; | 486 | return PTR_ERR(max77686->rdev[i]); |
| 487 | goto err; | ||
| 488 | } | 487 | } |
| 489 | } | 488 | } |
| 490 | 489 | ||
| 491 | return 0; | 490 | return 0; |
| 492 | err: | ||
| 493 | while (--i >= 0) | ||
| 494 | regulator_unregister(max77686->rdev[i]); | ||
| 495 | return ret; | ||
| 496 | } | ||
| 497 | |||
| 498 | static int max77686_pmic_remove(struct platform_device *pdev) | ||
| 499 | { | ||
| 500 | struct max77686_data *max77686 = platform_get_drvdata(pdev); | ||
| 501 | int i; | ||
| 502 | |||
| 503 | for (i = 0; i < MAX77686_REGULATORS; i++) | ||
| 504 | regulator_unregister(max77686->rdev[i]); | ||
| 505 | |||
| 506 | return 0; | ||
| 507 | } | 491 | } |
| 508 | 492 | ||
| 509 | static const struct platform_device_id max77686_pmic_id[] = { | 493 | static const struct platform_device_id max77686_pmic_id[] = { |
| @@ -518,7 +502,6 @@ static struct platform_driver max77686_pmic_driver = { | |||
| 518 | .owner = THIS_MODULE, | 502 | .owner = THIS_MODULE, |
| 519 | }, | 503 | }, |
| 520 | .probe = max77686_pmic_probe, | 504 | .probe = max77686_pmic_probe, |
| 521 | .remove = max77686_pmic_remove, | ||
| 522 | .id_table = max77686_pmic_id, | 505 | .id_table = max77686_pmic_id, |
| 523 | }; | 506 | }; |
| 524 | 507 | ||
diff --git a/drivers/regulator/max77693.c b/drivers/regulator/max77693.c index ce4b96c15eba..feb20bf4ccab 100644 --- a/drivers/regulator/max77693.c +++ b/drivers/regulator/max77693.c | |||
| @@ -230,7 +230,7 @@ static int max77693_pmic_probe(struct platform_device *pdev) | |||
| 230 | struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); | 230 | struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
| 231 | struct max77693_pmic_dev *max77693_pmic; | 231 | struct max77693_pmic_dev *max77693_pmic; |
| 232 | struct max77693_regulator_data *rdata = NULL; | 232 | struct max77693_regulator_data *rdata = NULL; |
| 233 | int num_rdata, i, ret; | 233 | int num_rdata, i; |
| 234 | struct regulator_config config; | 234 | struct regulator_config config; |
| 235 | 235 | ||
| 236 | num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata); | 236 | num_rdata = max77693_pmic_init_rdata(&pdev->dev, &rdata); |
| @@ -266,36 +266,16 @@ static int max77693_pmic_probe(struct platform_device *pdev) | |||
| 266 | config.init_data = rdata[i].initdata; | 266 | config.init_data = rdata[i].initdata; |
| 267 | config.of_node = rdata[i].of_node; | 267 | config.of_node = rdata[i].of_node; |
| 268 | 268 | ||
| 269 | max77693_pmic->rdev[i] = regulator_register(®ulators[id], | 269 | max77693_pmic->rdev[i] = devm_regulator_register(&pdev->dev, |
| 270 | &config); | 270 | ®ulators[id], &config); |
| 271 | if (IS_ERR(max77693_pmic->rdev[i])) { | 271 | if (IS_ERR(max77693_pmic->rdev[i])) { |
| 272 | ret = PTR_ERR(max77693_pmic->rdev[i]); | ||
| 273 | dev_err(max77693_pmic->dev, | 272 | dev_err(max77693_pmic->dev, |
| 274 | "Failed to initialize regulator-%d\n", id); | 273 | "Failed to initialize regulator-%d\n", id); |
| 275 | max77693_pmic->rdev[i] = NULL; | 274 | return PTR_ERR(max77693_pmic->rdev[i]); |
| 276 | goto err; | ||
| 277 | } | 275 | } |
| 278 | } | 276 | } |
| 279 | 277 | ||
| 280 | return 0; | 278 | return 0; |
| 281 | err: | ||
| 282 | while (--i >= 0) | ||
| 283 | regulator_unregister(max77693_pmic->rdev[i]); | ||
| 284 | |||
| 285 | return ret; | ||
| 286 | } | ||
| 287 | |||
| 288 | static int max77693_pmic_remove(struct platform_device *pdev) | ||
| 289 | { | ||
| 290 | struct max77693_pmic_dev *max77693_pmic = platform_get_drvdata(pdev); | ||
| 291 | struct regulator_dev **rdev = max77693_pmic->rdev; | ||
| 292 | int i; | ||
| 293 | |||
| 294 | for (i = 0; i < max77693_pmic->num_regulators; i++) | ||
| 295 | if (rdev[i]) | ||
| 296 | regulator_unregister(rdev[i]); | ||
| 297 | |||
| 298 | return 0; | ||
| 299 | } | 279 | } |
| 300 | 280 | ||
| 301 | static const struct platform_device_id max77693_pmic_id[] = { | 281 | static const struct platform_device_id max77693_pmic_id[] = { |
| @@ -311,7 +291,6 @@ static struct platform_driver max77693_pmic_driver = { | |||
| 311 | .owner = THIS_MODULE, | 291 | .owner = THIS_MODULE, |
| 312 | }, | 292 | }, |
| 313 | .probe = max77693_pmic_probe, | 293 | .probe = max77693_pmic_probe, |
| 314 | .remove = max77693_pmic_remove, | ||
| 315 | .id_table = max77693_pmic_id, | 294 | .id_table = max77693_pmic_id, |
| 316 | }; | 295 | }; |
| 317 | 296 | ||
diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c index 19c6f08eafd5..7f049c92ee52 100644 --- a/drivers/regulator/max8649.c +++ b/drivers/regulator/max8649.c | |||
| @@ -234,7 +234,8 @@ static int max8649_regulator_probe(struct i2c_client *client, | |||
| 234 | config.driver_data = info; | 234 | config.driver_data = info; |
| 235 | config.regmap = info->regmap; | 235 | config.regmap = info->regmap; |
| 236 | 236 | ||
| 237 | info->regulator = regulator_register(&dcdc_desc, &config); | 237 | info->regulator = devm_regulator_register(&client->dev, &dcdc_desc, |
| 238 | &config); | ||
| 238 | if (IS_ERR(info->regulator)) { | 239 | if (IS_ERR(info->regulator)) { |
| 239 | dev_err(info->dev, "failed to register regulator %s\n", | 240 | dev_err(info->dev, "failed to register regulator %s\n", |
| 240 | dcdc_desc.name); | 241 | dcdc_desc.name); |
| @@ -244,16 +245,6 @@ static int max8649_regulator_probe(struct i2c_client *client, | |||
| 244 | return 0; | 245 | return 0; |
| 245 | } | 246 | } |
| 246 | 247 | ||
| 247 | static int max8649_regulator_remove(struct i2c_client *client) | ||
| 248 | { | ||
| 249 | struct max8649_regulator_info *info = i2c_get_clientdata(client); | ||
| 250 | |||
| 251 | if (info) | ||
| 252 | regulator_unregister(info->regulator); | ||
| 253 | |||
| 254 | return 0; | ||
| 255 | } | ||
| 256 | |||
| 257 | static const struct i2c_device_id max8649_id[] = { | 248 | static const struct i2c_device_id max8649_id[] = { |
| 258 | { "max8649", 0 }, | 249 | { "max8649", 0 }, |
| 259 | { } | 250 | { } |
| @@ -262,7 +253,6 @@ MODULE_DEVICE_TABLE(i2c, max8649_id); | |||
| 262 | 253 | ||
| 263 | static struct i2c_driver max8649_driver = { | 254 | static struct i2c_driver max8649_driver = { |
| 264 | .probe = max8649_regulator_probe, | 255 | .probe = max8649_regulator_probe, |
| 265 | .remove = max8649_regulator_remove, | ||
| 266 | .driver = { | 256 | .driver = { |
| 267 | .name = "max8649", | 257 | .name = "max8649", |
| 268 | }, | 258 | }, |
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index 144bcacd734d..8d94d3d7f97f 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c | |||
| @@ -439,7 +439,7 @@ static int max8660_probe(struct i2c_client *client, | |||
| 439 | for (i = 0; i < pdata->num_subdevs; i++) { | 439 | for (i = 0; i < pdata->num_subdevs; i++) { |
| 440 | 440 | ||
| 441 | if (!pdata->subdevs[i].platform_data) | 441 | if (!pdata->subdevs[i].platform_data) |
| 442 | goto err_out; | 442 | return ret; |
| 443 | 443 | ||
| 444 | boot_on = pdata->subdevs[i].platform_data->constraints.boot_on; | 444 | boot_on = pdata->subdevs[i].platform_data->constraints.boot_on; |
| 445 | 445 | ||
| @@ -465,7 +465,7 @@ static int max8660_probe(struct i2c_client *client, | |||
| 465 | case MAX8660_V7: | 465 | case MAX8660_V7: |
| 466 | if (type == MAX8661) { | 466 | if (type == MAX8661) { |
| 467 | dev_err(dev, "Regulator not on this chip!\n"); | 467 | dev_err(dev, "Regulator not on this chip!\n"); |
| 468 | goto err_out; | 468 | return -EINVAL; |
| 469 | } | 469 | } |
| 470 | 470 | ||
| 471 | if (boot_on) | 471 | if (boot_on) |
| @@ -475,7 +475,7 @@ static int max8660_probe(struct i2c_client *client, | |||
| 475 | default: | 475 | default: |
| 476 | dev_err(dev, "invalid regulator %s\n", | 476 | dev_err(dev, "invalid regulator %s\n", |
| 477 | pdata->subdevs[i].name); | 477 | pdata->subdevs[i].name); |
| 478 | goto err_out; | 478 | return ret; |
| 479 | } | 479 | } |
| 480 | } | 480 | } |
| 481 | 481 | ||
| @@ -489,33 +489,18 @@ static int max8660_probe(struct i2c_client *client, | |||
| 489 | config.of_node = of_node[i]; | 489 | config.of_node = of_node[i]; |
| 490 | config.driver_data = max8660; | 490 | config.driver_data = max8660; |
| 491 | 491 | ||
| 492 | rdev[i] = regulator_register(&max8660_reg[id], &config); | 492 | rdev[i] = devm_regulator_register(&client->dev, |
| 493 | &max8660_reg[id], &config); | ||
| 493 | if (IS_ERR(rdev[i])) { | 494 | if (IS_ERR(rdev[i])) { |
| 494 | ret = PTR_ERR(rdev[i]); | 495 | ret = PTR_ERR(rdev[i]); |
| 495 | dev_err(dev, "failed to register %s\n", | 496 | dev_err(&client->dev, "failed to register %s\n", |
| 496 | max8660_reg[id].name); | 497 | max8660_reg[id].name); |
| 497 | goto err_unregister; | 498 | return PTR_ERR(rdev[i]); |
| 498 | } | 499 | } |
| 499 | } | 500 | } |
| 500 | 501 | ||
| 501 | i2c_set_clientdata(client, max8660); | 502 | i2c_set_clientdata(client, max8660); |
| 502 | return 0; | 503 | return 0; |
| 503 | |||
| 504 | err_unregister: | ||
| 505 | while (--i >= 0) | ||
| 506 | regulator_unregister(rdev[i]); | ||
| 507 | err_out: | ||
| 508 | return ret; | ||
| 509 | } | ||
| 510 | |||
| 511 | static int max8660_remove(struct i2c_client *client) | ||
| 512 | { | ||
| 513 | struct max8660 *max8660 = i2c_get_clientdata(client); | ||
| 514 | int i; | ||
| 515 | |||
| 516 | for (i = 0; i < MAX8660_V_END; i++) | ||
| 517 | regulator_unregister(max8660->rdev[i]); | ||
| 518 | return 0; | ||
| 519 | } | 504 | } |
| 520 | 505 | ||
| 521 | static const struct i2c_device_id max8660_id[] = { | 506 | static const struct i2c_device_id max8660_id[] = { |
| @@ -527,7 +512,6 @@ MODULE_DEVICE_TABLE(i2c, max8660_id); | |||
| 527 | 512 | ||
| 528 | static struct i2c_driver max8660_driver = { | 513 | static struct i2c_driver max8660_driver = { |
| 529 | .probe = max8660_probe, | 514 | .probe = max8660_probe, |
| 530 | .remove = max8660_remove, | ||
| 531 | .driver = { | 515 | .driver = { |
| 532 | .name = "max8660", | 516 | .name = "max8660", |
| 533 | .owner = THIS_MODULE, | 517 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/max8907-regulator.c b/drivers/regulator/max8907-regulator.c index 4568c15fa78d..0c5fe6c6ac26 100644 --- a/drivers/regulator/max8907-regulator.c +++ b/drivers/regulator/max8907-regulator.c | |||
| @@ -350,33 +350,17 @@ static int max8907_regulator_probe(struct platform_device *pdev) | |||
| 350 | pmic->desc[i].ops = &max8907_out5v_hwctl_ops; | 350 | pmic->desc[i].ops = &max8907_out5v_hwctl_ops; |
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | pmic->rdev[i] = regulator_register(&pmic->desc[i], &config); | 353 | pmic->rdev[i] = devm_regulator_register(&pdev->dev, |
| 354 | &pmic->desc[i], &config); | ||
| 354 | if (IS_ERR(pmic->rdev[i])) { | 355 | if (IS_ERR(pmic->rdev[i])) { |
| 355 | dev_err(&pdev->dev, | 356 | dev_err(&pdev->dev, |
| 356 | "failed to register %s regulator\n", | 357 | "failed to register %s regulator\n", |
| 357 | pmic->desc[i].name); | 358 | pmic->desc[i].name); |
| 358 | ret = PTR_ERR(pmic->rdev[i]); | 359 | return PTR_ERR(pmic->rdev[i]); |
| 359 | goto err_unregister_regulator; | ||
| 360 | } | 360 | } |
| 361 | } | 361 | } |
| 362 | 362 | ||
| 363 | return 0; | 363 | return 0; |
| 364 | |||
| 365 | err_unregister_regulator: | ||
| 366 | while (--i >= 0) | ||
| 367 | regulator_unregister(pmic->rdev[i]); | ||
| 368 | return ret; | ||
| 369 | } | ||
| 370 | |||
| 371 | static int max8907_regulator_remove(struct platform_device *pdev) | ||
| 372 | { | ||
| 373 | struct max8907_regulator *pmic = platform_get_drvdata(pdev); | ||
| 374 | int i; | ||
| 375 | |||
| 376 | for (i = 0; i < MAX8907_NUM_REGULATORS; i++) | ||
| 377 | regulator_unregister(pmic->rdev[i]); | ||
| 378 | |||
| 379 | return 0; | ||
| 380 | } | 364 | } |
| 381 | 365 | ||
| 382 | static struct platform_driver max8907_regulator_driver = { | 366 | static struct platform_driver max8907_regulator_driver = { |
| @@ -385,7 +369,6 @@ static struct platform_driver max8907_regulator_driver = { | |||
| 385 | .owner = THIS_MODULE, | 369 | .owner = THIS_MODULE, |
| 386 | }, | 370 | }, |
| 387 | .probe = max8907_regulator_probe, | 371 | .probe = max8907_regulator_probe, |
| 388 | .remove = max8907_regulator_remove, | ||
| 389 | }; | 372 | }; |
| 390 | 373 | ||
| 391 | static int __init max8907_regulator_init(void) | 374 | static int __init max8907_regulator_init(void) |
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index 5b77ab7762e4..892aa1e5b96c 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c | |||
| @@ -467,7 +467,7 @@ static int max8973_probe(struct i2c_client *client, | |||
| 467 | config.regmap = max->regmap; | 467 | config.regmap = max->regmap; |
| 468 | 468 | ||
| 469 | /* Register the regulators */ | 469 | /* Register the regulators */ |
| 470 | rdev = regulator_register(&max->desc, &config); | 470 | rdev = devm_regulator_register(&client->dev, &max->desc, &config); |
| 471 | if (IS_ERR(rdev)) { | 471 | if (IS_ERR(rdev)) { |
| 472 | ret = PTR_ERR(rdev); | 472 | ret = PTR_ERR(rdev); |
| 473 | dev_err(max->dev, "regulator register failed, err %d\n", ret); | 473 | dev_err(max->dev, "regulator register failed, err %d\n", ret); |
| @@ -478,14 +478,6 @@ static int max8973_probe(struct i2c_client *client, | |||
| 478 | return 0; | 478 | return 0; |
| 479 | } | 479 | } |
| 480 | 480 | ||
| 481 | static int max8973_remove(struct i2c_client *client) | ||
| 482 | { | ||
| 483 | struct max8973_chip *max = i2c_get_clientdata(client); | ||
| 484 | |||
| 485 | regulator_unregister(max->rdev); | ||
| 486 | return 0; | ||
| 487 | } | ||
| 488 | |||
| 489 | static const struct i2c_device_id max8973_id[] = { | 481 | static const struct i2c_device_id max8973_id[] = { |
| 490 | {.name = "max8973",}, | 482 | {.name = "max8973",}, |
| 491 | {}, | 483 | {}, |
| @@ -499,7 +491,6 @@ static struct i2c_driver max8973_i2c_driver = { | |||
| 499 | .owner = THIS_MODULE, | 491 | .owner = THIS_MODULE, |
| 500 | }, | 492 | }, |
| 501 | .probe = max8973_probe, | 493 | .probe = max8973_probe, |
| 502 | .remove = max8973_remove, | ||
| 503 | .id_table = max8973_id, | 494 | .id_table = max8973_id, |
| 504 | }; | 495 | }; |
| 505 | 496 | ||
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index df20069f0537..bcd2488d1252 100644 --- a/drivers/regulator/max8997.c +++ b/drivers/regulator/max8997.c | |||
| @@ -1081,7 +1081,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
| 1081 | pdata->buck1_voltage[i] + | 1081 | pdata->buck1_voltage[i] + |
| 1082 | buck1245_voltage_map_desc.step); | 1082 | buck1245_voltage_map_desc.step); |
| 1083 | if (ret < 0) | 1083 | if (ret < 0) |
| 1084 | goto err_out; | 1084 | return ret; |
| 1085 | 1085 | ||
| 1086 | max8997->buck2_vol[i] = ret = | 1086 | max8997->buck2_vol[i] = ret = |
| 1087 | max8997_get_voltage_proper_val( | 1087 | max8997_get_voltage_proper_val( |
| @@ -1090,7 +1090,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
| 1090 | pdata->buck2_voltage[i] + | 1090 | pdata->buck2_voltage[i] + |
| 1091 | buck1245_voltage_map_desc.step); | 1091 | buck1245_voltage_map_desc.step); |
| 1092 | if (ret < 0) | 1092 | if (ret < 0) |
| 1093 | goto err_out; | 1093 | return ret; |
| 1094 | 1094 | ||
| 1095 | max8997->buck5_vol[i] = ret = | 1095 | max8997->buck5_vol[i] = ret = |
| 1096 | max8997_get_voltage_proper_val( | 1096 | max8997_get_voltage_proper_val( |
| @@ -1099,7 +1099,7 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
| 1099 | pdata->buck5_voltage[i] + | 1099 | pdata->buck5_voltage[i] + |
| 1100 | buck1245_voltage_map_desc.step); | 1100 | buck1245_voltage_map_desc.step); |
| 1101 | if (ret < 0) | 1101 | if (ret < 0) |
| 1102 | goto err_out; | 1102 | return ret; |
| 1103 | 1103 | ||
| 1104 | if (max_buck1 < max8997->buck1_vol[i]) | 1104 | if (max_buck1 < max8997->buck1_vol[i]) |
| 1105 | max_buck1 = max8997->buck1_vol[i]; | 1105 | max_buck1 = max8997->buck1_vol[i]; |
| @@ -1143,24 +1143,23 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
| 1143 | !gpio_is_valid(pdata->buck125_gpios[1]) || | 1143 | !gpio_is_valid(pdata->buck125_gpios[1]) || |
| 1144 | !gpio_is_valid(pdata->buck125_gpios[2])) { | 1144 | !gpio_is_valid(pdata->buck125_gpios[2])) { |
| 1145 | dev_err(&pdev->dev, "GPIO NOT VALID\n"); | 1145 | dev_err(&pdev->dev, "GPIO NOT VALID\n"); |
| 1146 | ret = -EINVAL; | 1146 | return -EINVAL; |
| 1147 | goto err_out; | ||
| 1148 | } | 1147 | } |
| 1149 | 1148 | ||
| 1150 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[0], | 1149 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[0], |
| 1151 | "MAX8997 SET1"); | 1150 | "MAX8997 SET1"); |
| 1152 | if (ret) | 1151 | if (ret) |
| 1153 | goto err_out; | 1152 | return ret; |
| 1154 | 1153 | ||
| 1155 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[1], | 1154 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[1], |
| 1156 | "MAX8997 SET2"); | 1155 | "MAX8997 SET2"); |
| 1157 | if (ret) | 1156 | if (ret) |
| 1158 | goto err_out; | 1157 | return ret; |
| 1159 | 1158 | ||
| 1160 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[2], | 1159 | ret = devm_gpio_request(&pdev->dev, pdata->buck125_gpios[2], |
| 1161 | "MAX8997 SET3"); | 1160 | "MAX8997 SET3"); |
| 1162 | if (ret) | 1161 | if (ret) |
| 1163 | goto err_out; | 1162 | return ret; |
| 1164 | 1163 | ||
| 1165 | gpio_direction_output(pdata->buck125_gpios[0], | 1164 | gpio_direction_output(pdata->buck125_gpios[0], |
| 1166 | (max8997->buck125_gpioindex >> 2) | 1165 | (max8997->buck125_gpioindex >> 2) |
| @@ -1205,33 +1204,16 @@ static int max8997_pmic_probe(struct platform_device *pdev) | |||
| 1205 | config.driver_data = max8997; | 1204 | config.driver_data = max8997; |
| 1206 | config.of_node = pdata->regulators[i].reg_node; | 1205 | config.of_node = pdata->regulators[i].reg_node; |
| 1207 | 1206 | ||
| 1208 | rdev[i] = regulator_register(®ulators[id], &config); | 1207 | rdev[i] = devm_regulator_register(&pdev->dev, ®ulators[id], |
| 1208 | &config); | ||
| 1209 | if (IS_ERR(rdev[i])) { | 1209 | if (IS_ERR(rdev[i])) { |
| 1210 | ret = PTR_ERR(rdev[i]); | ||
| 1211 | dev_err(max8997->dev, "regulator init failed for %d\n", | 1210 | dev_err(max8997->dev, "regulator init failed for %d\n", |
| 1212 | id); | 1211 | id); |
| 1213 | rdev[i] = NULL; | 1212 | return PTR_ERR(rdev[i]); |
| 1214 | goto err; | ||
| 1215 | } | 1213 | } |
| 1216 | } | 1214 | } |
| 1217 | 1215 | ||
| 1218 | return 0; | 1216 | return 0; |
| 1219 | err: | ||
| 1220 | while (--i >= 0) | ||
| 1221 | regulator_unregister(rdev[i]); | ||
| 1222 | err_out: | ||
| 1223 | return ret; | ||
| 1224 | } | ||
| 1225 | |||
| 1226 | static int max8997_pmic_remove(struct platform_device *pdev) | ||
| 1227 | { | ||
| 1228 | struct max8997_data *max8997 = platform_get_drvdata(pdev); | ||
| 1229 | struct regulator_dev **rdev = max8997->rdev; | ||
| 1230 | int i; | ||
| 1231 | |||
| 1232 | for (i = 0; i < max8997->num_regulators; i++) | ||
| 1233 | regulator_unregister(rdev[i]); | ||
| 1234 | return 0; | ||
| 1235 | } | 1217 | } |
| 1236 | 1218 | ||
| 1237 | static const struct platform_device_id max8997_pmic_id[] = { | 1219 | static const struct platform_device_id max8997_pmic_id[] = { |
| @@ -1246,7 +1228,6 @@ static struct platform_driver max8997_pmic_driver = { | |||
| 1246 | .owner = THIS_MODULE, | 1228 | .owner = THIS_MODULE, |
| 1247 | }, | 1229 | }, |
| 1248 | .probe = max8997_pmic_probe, | 1230 | .probe = max8997_pmic_probe, |
| 1249 | .remove = max8997_pmic_remove, | ||
| 1250 | .id_table = max8997_pmic_id, | 1231 | .id_table = max8997_pmic_id, |
| 1251 | }; | 1232 | }; |
| 1252 | 1233 | ||
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index a4c53b2d1aaf..ae3f0656feb0 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
| @@ -790,16 +790,14 @@ static int max8998_pmic_probe(struct platform_device *pdev) | |||
| 790 | dev_err(&pdev->dev, | 790 | dev_err(&pdev->dev, |
| 791 | "MAX8998 SET1 GPIO defined as 0 !\n"); | 791 | "MAX8998 SET1 GPIO defined as 0 !\n"); |
| 792 | WARN_ON(!pdata->buck1_set1); | 792 | WARN_ON(!pdata->buck1_set1); |
| 793 | ret = -EIO; | 793 | return -EIO; |
| 794 | goto err_out; | ||
| 795 | } | 794 | } |
| 796 | /* Check if SET2 is not equal to 0 */ | 795 | /* Check if SET2 is not equal to 0 */ |
| 797 | if (!pdata->buck1_set2) { | 796 | if (!pdata->buck1_set2) { |
| 798 | dev_err(&pdev->dev, | 797 | dev_err(&pdev->dev, |
| 799 | "MAX8998 SET2 GPIO defined as 0 !\n"); | 798 | "MAX8998 SET2 GPIO defined as 0 !\n"); |
| 800 | WARN_ON(!pdata->buck1_set2); | 799 | WARN_ON(!pdata->buck1_set2); |
| 801 | ret = -EIO; | 800 | return -EIO; |
| 802 | goto err_out; | ||
| 803 | } | 801 | } |
| 804 | 802 | ||
| 805 | gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); | 803 | gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1"); |
| @@ -823,7 +821,7 @@ static int max8998_pmic_probe(struct platform_device *pdev) | |||
| 823 | ret = max8998_write_reg(i2c, | 821 | ret = max8998_write_reg(i2c, |
| 824 | MAX8998_REG_BUCK1_VOLTAGE1 + v, i); | 822 | MAX8998_REG_BUCK1_VOLTAGE1 + v, i); |
| 825 | if (ret) | 823 | if (ret) |
| 826 | goto err_out; | 824 | return ret; |
| 827 | } | 825 | } |
| 828 | } | 826 | } |
| 829 | 827 | ||
| @@ -833,8 +831,7 @@ static int max8998_pmic_probe(struct platform_device *pdev) | |||
| 833 | dev_err(&pdev->dev, | 831 | dev_err(&pdev->dev, |
| 834 | "MAX8998 SET3 GPIO defined as 0 !\n"); | 832 | "MAX8998 SET3 GPIO defined as 0 !\n"); |
| 835 | WARN_ON(!pdata->buck2_set3); | 833 | WARN_ON(!pdata->buck2_set3); |
| 836 | ret = -EIO; | 834 | return -EIO; |
| 837 | goto err_out; | ||
| 838 | } | 835 | } |
| 839 | gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); | 836 | gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3"); |
| 840 | gpio_direction_output(pdata->buck2_set3, | 837 | gpio_direction_output(pdata->buck2_set3, |
| @@ -852,7 +849,7 @@ static int max8998_pmic_probe(struct platform_device *pdev) | |||
| 852 | ret = max8998_write_reg(i2c, | 849 | ret = max8998_write_reg(i2c, |
| 853 | MAX8998_REG_BUCK2_VOLTAGE1 + v, i); | 850 | MAX8998_REG_BUCK2_VOLTAGE1 + v, i); |
| 854 | if (ret) | 851 | if (ret) |
| 855 | goto err_out; | 852 | return ret; |
| 856 | } | 853 | } |
| 857 | } | 854 | } |
| 858 | 855 | ||
| @@ -875,34 +872,19 @@ static int max8998_pmic_probe(struct platform_device *pdev) | |||
| 875 | config.init_data = pdata->regulators[i].initdata; | 872 | config.init_data = pdata->regulators[i].initdata; |
| 876 | config.driver_data = max8998; | 873 | config.driver_data = max8998; |
| 877 | 874 | ||
| 878 | rdev[i] = regulator_register(®ulators[index], &config); | 875 | rdev[i] = devm_regulator_register(&pdev->dev, |
| 876 | ®ulators[index], &config); | ||
| 879 | if (IS_ERR(rdev[i])) { | 877 | if (IS_ERR(rdev[i])) { |
| 880 | ret = PTR_ERR(rdev[i]); | 878 | ret = PTR_ERR(rdev[i]); |
| 881 | dev_err(max8998->dev, "regulator %s init failed (%d)\n", | 879 | dev_err(max8998->dev, "regulator %s init failed (%d)\n", |
| 882 | regulators[index].name, ret); | 880 | regulators[index].name, ret); |
| 883 | rdev[i] = NULL; | 881 | rdev[i] = NULL; |
| 884 | goto err; | 882 | return ret; |
| 885 | } | 883 | } |
| 886 | } | 884 | } |
| 887 | 885 | ||
| 888 | 886 | ||
| 889 | return 0; | 887 | return 0; |
| 890 | err: | ||
| 891 | while (--i >= 0) | ||
| 892 | regulator_unregister(rdev[i]); | ||
| 893 | err_out: | ||
| 894 | return ret; | ||
| 895 | } | ||
| 896 | |||
| 897 | static int max8998_pmic_remove(struct platform_device *pdev) | ||
| 898 | { | ||
| 899 | struct max8998_data *max8998 = platform_get_drvdata(pdev); | ||
| 900 | struct regulator_dev **rdev = max8998->rdev; | ||
| 901 | int i; | ||
| 902 | |||
| 903 | for (i = 0; i < max8998->num_regulators; i++) | ||
| 904 | regulator_unregister(rdev[i]); | ||
| 905 | return 0; | ||
| 906 | } | 888 | } |
| 907 | 889 | ||
| 908 | static const struct platform_device_id max8998_pmic_id[] = { | 890 | static const struct platform_device_id max8998_pmic_id[] = { |
| @@ -918,7 +900,6 @@ static struct platform_driver max8998_pmic_driver = { | |||
| 918 | .owner = THIS_MODULE, | 900 | .owner = THIS_MODULE, |
| 919 | }, | 901 | }, |
| 920 | .probe = max8998_pmic_probe, | 902 | .probe = max8998_pmic_probe, |
| 921 | .remove = max8998_pmic_remove, | ||
| 922 | .id_table = max8998_pmic_id, | 903 | .id_table = max8998_pmic_id, |
| 923 | }; | 904 | }; |
| 924 | 905 | ||
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c index 5ff99d2703db..f036b26d4cfc 100644 --- a/drivers/regulator/mc13783-regulator.c +++ b/drivers/regulator/mc13783-regulator.c | |||
| @@ -400,7 +400,7 @@ static int mc13783_regulator_probe(struct platform_device *pdev) | |||
| 400 | dev_get_platdata(&pdev->dev); | 400 | dev_get_platdata(&pdev->dev); |
| 401 | struct mc13xxx_regulator_init_data *mc13xxx_data; | 401 | struct mc13xxx_regulator_init_data *mc13xxx_data; |
| 402 | struct regulator_config config = { }; | 402 | struct regulator_config config = { }; |
| 403 | int i, ret, num_regulators; | 403 | int i, num_regulators; |
| 404 | 404 | ||
| 405 | num_regulators = mc13xxx_get_num_regulators_dt(pdev); | 405 | num_regulators = mc13xxx_get_num_regulators_dt(pdev); |
| 406 | 406 | ||
| @@ -444,32 +444,16 @@ static int mc13783_regulator_probe(struct platform_device *pdev) | |||
| 444 | config.driver_data = priv; | 444 | config.driver_data = priv; |
| 445 | config.of_node = node; | 445 | config.of_node = node; |
| 446 | 446 | ||
| 447 | priv->regulators[i] = regulator_register(desc, &config); | 447 | priv->regulators[i] = devm_regulator_register(&pdev->dev, desc, |
| 448 | &config); | ||
| 448 | if (IS_ERR(priv->regulators[i])) { | 449 | if (IS_ERR(priv->regulators[i])) { |
| 449 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 450 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
| 450 | mc13783_regulators[i].desc.name); | 451 | mc13783_regulators[i].desc.name); |
| 451 | ret = PTR_ERR(priv->regulators[i]); | 452 | return PTR_ERR(priv->regulators[i]); |
| 452 | goto err; | ||
| 453 | } | 453 | } |
| 454 | } | 454 | } |
| 455 | 455 | ||
| 456 | return 0; | 456 | return 0; |
| 457 | err: | ||
| 458 | while (--i >= 0) | ||
| 459 | regulator_unregister(priv->regulators[i]); | ||
| 460 | |||
| 461 | return ret; | ||
| 462 | } | ||
| 463 | |||
| 464 | static int mc13783_regulator_remove(struct platform_device *pdev) | ||
| 465 | { | ||
| 466 | struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); | ||
| 467 | int i; | ||
| 468 | |||
| 469 | for (i = 0; i < priv->num_regulators; i++) | ||
| 470 | regulator_unregister(priv->regulators[i]); | ||
| 471 | |||
| 472 | return 0; | ||
| 473 | } | 457 | } |
| 474 | 458 | ||
| 475 | static struct platform_driver mc13783_regulator_driver = { | 459 | static struct platform_driver mc13783_regulator_driver = { |
| @@ -477,7 +461,6 @@ static struct platform_driver mc13783_regulator_driver = { | |||
| 477 | .name = "mc13783-regulator", | 461 | .name = "mc13783-regulator", |
| 478 | .owner = THIS_MODULE, | 462 | .owner = THIS_MODULE, |
| 479 | }, | 463 | }, |
| 480 | .remove = mc13783_regulator_remove, | ||
| 481 | .probe = mc13783_regulator_probe, | 464 | .probe = mc13783_regulator_probe, |
| 482 | }; | 465 | }; |
| 483 | 466 | ||
diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c index 1037e07937cf..96c9f80d9550 100644 --- a/drivers/regulator/mc13892-regulator.c +++ b/drivers/regulator/mc13892-regulator.c | |||
| @@ -611,43 +611,27 @@ static int mc13892_regulator_probe(struct platform_device *pdev) | |||
| 611 | config.driver_data = priv; | 611 | config.driver_data = priv; |
| 612 | config.of_node = node; | 612 | config.of_node = node; |
| 613 | 613 | ||
| 614 | priv->regulators[i] = regulator_register(desc, &config); | 614 | priv->regulators[i] = devm_regulator_register(&pdev->dev, desc, |
| 615 | &config); | ||
| 615 | if (IS_ERR(priv->regulators[i])) { | 616 | if (IS_ERR(priv->regulators[i])) { |
| 616 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 617 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
| 617 | mc13892_regulators[i].desc.name); | 618 | mc13892_regulators[i].desc.name); |
| 618 | ret = PTR_ERR(priv->regulators[i]); | 619 | return PTR_ERR(priv->regulators[i]); |
| 619 | goto err; | ||
| 620 | } | 620 | } |
| 621 | } | 621 | } |
| 622 | 622 | ||
| 623 | return 0; | 623 | return 0; |
| 624 | err: | ||
| 625 | while (--i >= 0) | ||
| 626 | regulator_unregister(priv->regulators[i]); | ||
| 627 | return ret; | ||
| 628 | 624 | ||
| 629 | err_unlock: | 625 | err_unlock: |
| 630 | mc13xxx_unlock(mc13892); | 626 | mc13xxx_unlock(mc13892); |
| 631 | return ret; | 627 | return ret; |
| 632 | } | 628 | } |
| 633 | 629 | ||
| 634 | static int mc13892_regulator_remove(struct platform_device *pdev) | ||
| 635 | { | ||
| 636 | struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); | ||
| 637 | int i; | ||
| 638 | |||
| 639 | for (i = 0; i < priv->num_regulators; i++) | ||
| 640 | regulator_unregister(priv->regulators[i]); | ||
| 641 | |||
| 642 | return 0; | ||
| 643 | } | ||
| 644 | |||
| 645 | static struct platform_driver mc13892_regulator_driver = { | 630 | static struct platform_driver mc13892_regulator_driver = { |
| 646 | .driver = { | 631 | .driver = { |
| 647 | .name = "mc13892-regulator", | 632 | .name = "mc13892-regulator", |
| 648 | .owner = THIS_MODULE, | 633 | .owner = THIS_MODULE, |
| 649 | }, | 634 | }, |
| 650 | .remove = mc13892_regulator_remove, | ||
| 651 | .probe = mc13892_regulator_probe, | 635 | .probe = mc13892_regulator_probe, |
| 652 | }; | 636 | }; |
| 653 | 637 | ||
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c index 76ce09c6b594..1b31e414fde1 100644 --- a/drivers/regulator/palmas-regulator.c +++ b/drivers/regulator/palmas-regulator.c | |||
| @@ -996,7 +996,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
| 996 | if (ret < 0) { | 996 | if (ret < 0) { |
| 997 | dev_err(&pdev->dev, | 997 | dev_err(&pdev->dev, |
| 998 | "reading TSTEP reg failed: %d\n", ret); | 998 | "reading TSTEP reg failed: %d\n", ret); |
| 999 | goto err_unregister_regulator; | 999 | return ret; |
| 1000 | } | 1000 | } |
| 1001 | pmic->desc[id].ramp_delay = | 1001 | pmic->desc[id].ramp_delay = |
| 1002 | palmas_smps_ramp_delay[reg & 0x3]; | 1002 | palmas_smps_ramp_delay[reg & 0x3]; |
| @@ -1008,7 +1008,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
| 1008 | reg_init = pdata->reg_init[id]; | 1008 | reg_init = pdata->reg_init[id]; |
| 1009 | ret = palmas_smps_init(palmas, id, reg_init); | 1009 | ret = palmas_smps_init(palmas, id, reg_init); |
| 1010 | if (ret) | 1010 | if (ret) |
| 1011 | goto err_unregister_regulator; | 1011 | return ret; |
| 1012 | } else { | 1012 | } else { |
| 1013 | reg_init = NULL; | 1013 | reg_init = NULL; |
| 1014 | } | 1014 | } |
| @@ -1051,7 +1051,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
| 1051 | 1051 | ||
| 1052 | ret = palmas_smps_read(pmic->palmas, addr, ®); | 1052 | ret = palmas_smps_read(pmic->palmas, addr, ®); |
| 1053 | if (ret) | 1053 | if (ret) |
| 1054 | goto err_unregister_regulator; | 1054 | return ret; |
| 1055 | if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) | 1055 | if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) |
| 1056 | pmic->range[id] = 1; | 1056 | pmic->range[id] = 1; |
| 1057 | 1057 | ||
| @@ -1071,7 +1071,7 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
| 1071 | addr = palmas_regs_info[id].ctrl_addr; | 1071 | addr = palmas_regs_info[id].ctrl_addr; |
| 1072 | ret = palmas_smps_read(pmic->palmas, addr, ®); | 1072 | ret = palmas_smps_read(pmic->palmas, addr, ®); |
| 1073 | if (ret) | 1073 | if (ret) |
| 1074 | goto err_unregister_regulator; | 1074 | return ret; |
| 1075 | pmic->current_reg_mode[id] = reg & | 1075 | pmic->current_reg_mode[id] = reg & |
| 1076 | PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; | 1076 | PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; |
| 1077 | } | 1077 | } |
| @@ -1087,13 +1087,13 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
| 1087 | pmic->desc[id].supply_name = palmas_regs_info[id].sname; | 1087 | pmic->desc[id].supply_name = palmas_regs_info[id].sname; |
| 1088 | config.of_node = palmas_matches[id].of_node; | 1088 | config.of_node = palmas_matches[id].of_node; |
| 1089 | 1089 | ||
| 1090 | rdev = regulator_register(&pmic->desc[id], &config); | 1090 | rdev = devm_regulator_register(&pdev->dev, &pmic->desc[id], |
| 1091 | &config); | ||
| 1091 | if (IS_ERR(rdev)) { | 1092 | if (IS_ERR(rdev)) { |
| 1092 | dev_err(&pdev->dev, | 1093 | dev_err(&pdev->dev, |
| 1093 | "failed to register %s regulator\n", | 1094 | "failed to register %s regulator\n", |
| 1094 | pdev->name); | 1095 | pdev->name); |
| 1095 | ret = PTR_ERR(rdev); | 1096 | return PTR_ERR(rdev); |
| 1096 | goto err_unregister_regulator; | ||
| 1097 | } | 1097 | } |
| 1098 | 1098 | ||
| 1099 | /* Save regulator for cleanup */ | 1099 | /* Save regulator for cleanup */ |
| @@ -1173,13 +1173,13 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
| 1173 | pmic->desc[id].supply_name = palmas_regs_info[id].sname; | 1173 | pmic->desc[id].supply_name = palmas_regs_info[id].sname; |
| 1174 | config.of_node = palmas_matches[id].of_node; | 1174 | config.of_node = palmas_matches[id].of_node; |
| 1175 | 1175 | ||
| 1176 | rdev = regulator_register(&pmic->desc[id], &config); | 1176 | rdev = devm_regulator_register(&pdev->dev, &pmic->desc[id], |
| 1177 | &config); | ||
| 1177 | if (IS_ERR(rdev)) { | 1178 | if (IS_ERR(rdev)) { |
| 1178 | dev_err(&pdev->dev, | 1179 | dev_err(&pdev->dev, |
| 1179 | "failed to register %s regulator\n", | 1180 | "failed to register %s regulator\n", |
| 1180 | pdev->name); | 1181 | pdev->name); |
| 1181 | ret = PTR_ERR(rdev); | 1182 | return PTR_ERR(rdev); |
| 1182 | goto err_unregister_regulator; | ||
| 1183 | } | 1183 | } |
| 1184 | 1184 | ||
| 1185 | /* Save regulator for cleanup */ | 1185 | /* Save regulator for cleanup */ |
| @@ -1195,31 +1195,14 @@ static int palmas_regulators_probe(struct platform_device *pdev) | |||
| 1195 | else | 1195 | else |
| 1196 | ret = palmas_extreg_init(palmas, | 1196 | ret = palmas_extreg_init(palmas, |
| 1197 | id, reg_init); | 1197 | id, reg_init); |
| 1198 | if (ret) { | 1198 | if (ret) |
| 1199 | regulator_unregister(pmic->rdev[id]); | 1199 | return ret; |
| 1200 | goto err_unregister_regulator; | ||
| 1201 | } | ||
| 1202 | } | 1200 | } |
| 1203 | } | 1201 | } |
| 1204 | } | 1202 | } |
| 1205 | 1203 | ||
| 1206 | 1204 | ||
| 1207 | return 0; | 1205 | return 0; |
| 1208 | |||
| 1209 | err_unregister_regulator: | ||
| 1210 | while (--id >= 0) | ||
| 1211 | regulator_unregister(pmic->rdev[id]); | ||
| 1212 | return ret; | ||
| 1213 | } | ||
| 1214 | |||
| 1215 | static int palmas_regulators_remove(struct platform_device *pdev) | ||
| 1216 | { | ||
| 1217 | struct palmas_pmic *pmic = platform_get_drvdata(pdev); | ||
| 1218 | int id; | ||
| 1219 | |||
| 1220 | for (id = 0; id < PALMAS_NUM_REGS; id++) | ||
| 1221 | regulator_unregister(pmic->rdev[id]); | ||
| 1222 | return 0; | ||
| 1223 | } | 1206 | } |
| 1224 | 1207 | ||
| 1225 | static struct of_device_id of_palmas_match_tbl[] = { | 1208 | static struct of_device_id of_palmas_match_tbl[] = { |
| @@ -1241,7 +1224,6 @@ static struct platform_driver palmas_driver = { | |||
| 1241 | .owner = THIS_MODULE, | 1224 | .owner = THIS_MODULE, |
| 1242 | }, | 1225 | }, |
| 1243 | .probe = palmas_regulators_probe, | 1226 | .probe = palmas_regulators_probe, |
| 1244 | .remove = palmas_regulators_remove, | ||
| 1245 | }; | 1227 | }; |
| 1246 | 1228 | ||
| 1247 | static int __init palmas_init(void) | 1229 | static int __init palmas_init(void) |
diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c index 5885b4504596..b58affb33143 100644 --- a/drivers/regulator/rc5t583-regulator.c +++ b/drivers/regulator/rc5t583-regulator.c | |||
| @@ -173,33 +173,16 @@ skip_ext_pwr_config: | |||
| 173 | config.driver_data = reg; | 173 | config.driver_data = reg; |
| 174 | config.regmap = rc5t583->regmap; | 174 | config.regmap = rc5t583->regmap; |
| 175 | 175 | ||
| 176 | rdev = regulator_register(&ri->desc, &config); | 176 | rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); |
| 177 | if (IS_ERR(rdev)) { | 177 | if (IS_ERR(rdev)) { |
| 178 | dev_err(&pdev->dev, "Failed to register regulator %s\n", | 178 | dev_err(&pdev->dev, "Failed to register regulator %s\n", |
| 179 | ri->desc.name); | 179 | ri->desc.name); |
| 180 | ret = PTR_ERR(rdev); | 180 | return PTR_ERR(rdev); |
| 181 | goto clean_exit; | ||
| 182 | } | 181 | } |
| 183 | reg->rdev = rdev; | 182 | reg->rdev = rdev; |
| 184 | } | 183 | } |
| 185 | platform_set_drvdata(pdev, regs); | 184 | platform_set_drvdata(pdev, regs); |
| 186 | return 0; | 185 | return 0; |
| 187 | |||
| 188 | clean_exit: | ||
| 189 | while (--id >= 0) | ||
| 190 | regulator_unregister(regs[id].rdev); | ||
| 191 | |||
| 192 | return ret; | ||
| 193 | } | ||
| 194 | |||
| 195 | static int rc5t583_regulator_remove(struct platform_device *pdev) | ||
| 196 | { | ||
| 197 | struct rc5t583_regulator *regs = platform_get_drvdata(pdev); | ||
| 198 | int id; | ||
| 199 | |||
| 200 | for (id = 0; id < RC5T583_REGULATOR_MAX; ++id) | ||
| 201 | regulator_unregister(regs[id].rdev); | ||
| 202 | return 0; | ||
| 203 | } | 186 | } |
| 204 | 187 | ||
| 205 | static struct platform_driver rc5t583_regulator_driver = { | 188 | static struct platform_driver rc5t583_regulator_driver = { |
| @@ -208,7 +191,6 @@ static struct platform_driver rc5t583_regulator_driver = { | |||
| 208 | .owner = THIS_MODULE, | 191 | .owner = THIS_MODULE, |
| 209 | }, | 192 | }, |
| 210 | .probe = rc5t583_regulator_probe, | 193 | .probe = rc5t583_regulator_probe, |
| 211 | .remove = rc5t583_regulator_remove, | ||
| 212 | }; | 194 | }; |
| 213 | 195 | ||
| 214 | static int __init rc5t583_regulator_init(void) | 196 | static int __init rc5t583_regulator_init(void) |
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 5eba2ff8c0e8..333677d68d0e 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c | |||
| @@ -448,33 +448,17 @@ common_reg: | |||
| 448 | config.of_node = rdata[i].of_node; | 448 | config.of_node = rdata[i].of_node; |
| 449 | } | 449 | } |
| 450 | 450 | ||
| 451 | s2mps11->rdev[i] = regulator_register(®ulators[i], &config); | 451 | s2mps11->rdev[i] = devm_regulator_register(&pdev->dev, |
| 452 | ®ulators[i], &config); | ||
| 452 | if (IS_ERR(s2mps11->rdev[i])) { | 453 | if (IS_ERR(s2mps11->rdev[i])) { |
| 453 | ret = PTR_ERR(s2mps11->rdev[i]); | 454 | ret = PTR_ERR(s2mps11->rdev[i]); |
| 454 | dev_err(&pdev->dev, "regulator init failed for %d\n", | 455 | dev_err(&pdev->dev, "regulator init failed for %d\n", |
| 455 | i); | 456 | i); |
| 456 | s2mps11->rdev[i] = NULL; | 457 | return ret; |
| 457 | goto err; | ||
| 458 | } | 458 | } |
| 459 | } | 459 | } |
| 460 | 460 | ||
| 461 | return 0; | 461 | return 0; |
| 462 | err: | ||
| 463 | for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) | ||
| 464 | regulator_unregister(s2mps11->rdev[i]); | ||
| 465 | |||
| 466 | return ret; | ||
| 467 | } | ||
| 468 | |||
| 469 | static int s2mps11_pmic_remove(struct platform_device *pdev) | ||
| 470 | { | ||
| 471 | struct s2mps11_info *s2mps11 = platform_get_drvdata(pdev); | ||
| 472 | int i; | ||
| 473 | |||
| 474 | for (i = 0; i < S2MPS11_REGULATOR_MAX; i++) | ||
| 475 | regulator_unregister(s2mps11->rdev[i]); | ||
| 476 | |||
| 477 | return 0; | ||
| 478 | } | 462 | } |
| 479 | 463 | ||
| 480 | static const struct platform_device_id s2mps11_pmic_id[] = { | 464 | static const struct platform_device_id s2mps11_pmic_id[] = { |
| @@ -489,7 +473,6 @@ static struct platform_driver s2mps11_pmic_driver = { | |||
| 489 | .owner = THIS_MODULE, | 473 | .owner = THIS_MODULE, |
| 490 | }, | 474 | }, |
| 491 | .probe = s2mps11_pmic_probe, | 475 | .probe = s2mps11_pmic_probe, |
| 492 | .remove = s2mps11_pmic_remove, | ||
| 493 | .id_table = s2mps11_pmic_id, | 476 | .id_table = s2mps11_pmic_id, |
| 494 | }; | 477 | }; |
| 495 | 478 | ||
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index c24448bc43cf..2297fdf9ba7e 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
| @@ -910,34 +910,17 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
| 910 | config.regmap = iodev->regmap; | 910 | config.regmap = iodev->regmap; |
| 911 | config.of_node = pdata->regulators[i].reg_node; | 911 | config.of_node = pdata->regulators[i].reg_node; |
| 912 | 912 | ||
| 913 | rdev[i] = regulator_register(®ulators[id], &config); | 913 | rdev[i] = devm_regulator_register(&pdev->dev, ®ulators[id], |
| 914 | &config); | ||
| 914 | if (IS_ERR(rdev[i])) { | 915 | if (IS_ERR(rdev[i])) { |
| 915 | ret = PTR_ERR(rdev[i]); | 916 | ret = PTR_ERR(rdev[i]); |
| 916 | dev_err(s5m8767->dev, "regulator init failed for %d\n", | 917 | dev_err(s5m8767->dev, "regulator init failed for %d\n", |
| 917 | id); | 918 | id); |
| 918 | rdev[i] = NULL; | 919 | return ret; |
| 919 | goto err; | ||
| 920 | } | 920 | } |
| 921 | } | 921 | } |
| 922 | 922 | ||
| 923 | return 0; | 923 | return 0; |
| 924 | err: | ||
| 925 | for (i = 0; i < s5m8767->num_regulators; i++) | ||
| 926 | regulator_unregister(rdev[i]); | ||
| 927 | |||
| 928 | return ret; | ||
| 929 | } | ||
| 930 | |||
| 931 | static int s5m8767_pmic_remove(struct platform_device *pdev) | ||
| 932 | { | ||
| 933 | struct s5m8767_info *s5m8767 = platform_get_drvdata(pdev); | ||
| 934 | struct regulator_dev **rdev = s5m8767->rdev; | ||
| 935 | int i; | ||
| 936 | |||
| 937 | for (i = 0; i < s5m8767->num_regulators; i++) | ||
| 938 | regulator_unregister(rdev[i]); | ||
| 939 | |||
| 940 | return 0; | ||
| 941 | } | 924 | } |
| 942 | 925 | ||
| 943 | static const struct platform_device_id s5m8767_pmic_id[] = { | 926 | static const struct platform_device_id s5m8767_pmic_id[] = { |
| @@ -952,7 +935,6 @@ static struct platform_driver s5m8767_pmic_driver = { | |||
| 952 | .owner = THIS_MODULE, | 935 | .owner = THIS_MODULE, |
| 953 | }, | 936 | }, |
| 954 | .probe = s5m8767_pmic_probe, | 937 | .probe = s5m8767_pmic_probe, |
| 955 | .remove = s5m8767_pmic_remove, | ||
| 956 | .id_table = s5m8767_pmic_id, | 938 | .id_table = s5m8767_pmic_id, |
| 957 | }; | 939 | }; |
| 958 | 940 | ||
diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c index d8e3e1262bc2..8c2a8195d8a7 100644 --- a/drivers/regulator/ti-abb-regulator.c +++ b/drivers/regulator/ti-abb-regulator.c | |||
| @@ -696,39 +696,31 @@ static int ti_abb_probe(struct platform_device *pdev) | |||
| 696 | match = of_match_device(ti_abb_of_match, dev); | 696 | match = of_match_device(ti_abb_of_match, dev); |
| 697 | if (!match) { | 697 | if (!match) { |
| 698 | /* We do not expect this to happen */ | 698 | /* We do not expect this to happen */ |
| 699 | ret = -ENODEV; | ||
| 700 | dev_err(dev, "%s: Unable to match device\n", __func__); | 699 | dev_err(dev, "%s: Unable to match device\n", __func__); |
| 701 | goto err; | 700 | return -ENODEV; |
| 702 | } | 701 | } |
| 703 | if (!match->data) { | 702 | if (!match->data) { |
| 704 | ret = -EINVAL; | ||
| 705 | dev_err(dev, "%s: Bad data in match\n", __func__); | 703 | dev_err(dev, "%s: Bad data in match\n", __func__); |
| 706 | goto err; | 704 | return -EINVAL; |
| 707 | } | 705 | } |
| 708 | 706 | ||
| 709 | abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL); | 707 | abb = devm_kzalloc(dev, sizeof(struct ti_abb), GFP_KERNEL); |
| 710 | if (!abb) { | 708 | if (!abb) |
| 711 | dev_err(dev, "%s: Unable to allocate ABB struct\n", __func__); | 709 | return -ENOMEM; |
| 712 | ret = -ENOMEM; | ||
| 713 | goto err; | ||
| 714 | } | ||
| 715 | abb->regs = match->data; | 710 | abb->regs = match->data; |
| 716 | 711 | ||
| 717 | /* Map ABB resources */ | 712 | /* Map ABB resources */ |
| 718 | pname = "base-address"; | 713 | pname = "base-address"; |
| 719 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); | 714 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); |
| 720 | abb->base = devm_ioremap_resource(dev, res); | 715 | abb->base = devm_ioremap_resource(dev, res); |
| 721 | if (IS_ERR(abb->base)) { | 716 | if (IS_ERR(abb->base)) |
| 722 | ret = PTR_ERR(abb->base); | 717 | return PTR_ERR(abb->base); |
| 723 | goto err; | ||
| 724 | } | ||
| 725 | 718 | ||
| 726 | pname = "int-address"; | 719 | pname = "int-address"; |
| 727 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); | 720 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); |
| 728 | if (!res) { | 721 | if (!res) { |
| 729 | dev_err(dev, "Missing '%s' IO resource\n", pname); | 722 | dev_err(dev, "Missing '%s' IO resource\n", pname); |
| 730 | ret = -ENODEV; | 723 | return -ENODEV; |
| 731 | goto err; | ||
| 732 | } | 724 | } |
| 733 | /* | 725 | /* |
| 734 | * We may have shared interrupt register offsets which are | 726 | * We may have shared interrupt register offsets which are |
| @@ -738,8 +730,7 @@ static int ti_abb_probe(struct platform_device *pdev) | |||
| 738 | resource_size(res)); | 730 | resource_size(res)); |
| 739 | if (!abb->int_base) { | 731 | if (!abb->int_base) { |
| 740 | dev_err(dev, "Unable to map '%s'\n", pname); | 732 | dev_err(dev, "Unable to map '%s'\n", pname); |
| 741 | ret = -ENOMEM; | 733 | return -ENOMEM; |
| 742 | goto err; | ||
| 743 | } | 734 | } |
| 744 | 735 | ||
| 745 | /* Map Optional resources */ | 736 | /* Map Optional resources */ |
| @@ -759,17 +750,14 @@ static int ti_abb_probe(struct platform_device *pdev) | |||
| 759 | resource_size(res)); | 750 | resource_size(res)); |
| 760 | if (!abb->efuse_base) { | 751 | if (!abb->efuse_base) { |
| 761 | dev_err(dev, "Unable to map '%s'\n", pname); | 752 | dev_err(dev, "Unable to map '%s'\n", pname); |
| 762 | ret = -ENOMEM; | 753 | return -ENOMEM; |
| 763 | goto err; | ||
| 764 | } | 754 | } |
| 765 | 755 | ||
| 766 | pname = "ldo-address"; | 756 | pname = "ldo-address"; |
| 767 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); | 757 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname); |
| 768 | abb->ldo_base = devm_ioremap_resource(dev, res); | 758 | abb->ldo_base = devm_ioremap_resource(dev, res); |
| 769 | if (IS_ERR(abb->ldo_base)) { | 759 | if (IS_ERR(abb->ldo_base)) |
| 770 | ret = PTR_ERR(abb->ldo_base); | 760 | return PTR_ERR(abb->ldo_base); |
| 771 | goto err; | ||
| 772 | } | ||
| 773 | 761 | ||
| 774 | /* IF ldo_base is set, the following are mandatory */ | 762 | /* IF ldo_base is set, the following are mandatory */ |
| 775 | pname = "ti,ldovbb-override-mask"; | 763 | pname = "ti,ldovbb-override-mask"; |
| @@ -778,12 +766,11 @@ static int ti_abb_probe(struct platform_device *pdev) | |||
| 778 | &abb->ldovbb_override_mask); | 766 | &abb->ldovbb_override_mask); |
| 779 | if (ret) { | 767 | if (ret) { |
| 780 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); | 768 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); |
| 781 | goto err; | 769 | return ret; |
| 782 | } | 770 | } |
| 783 | if (!abb->ldovbb_override_mask) { | 771 | if (!abb->ldovbb_override_mask) { |
| 784 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); | 772 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); |
| 785 | ret = -EINVAL; | 773 | return -EINVAL; |
| 786 | goto err; | ||
| 787 | } | 774 | } |
| 788 | 775 | ||
| 789 | pname = "ti,ldovbb-vset-mask"; | 776 | pname = "ti,ldovbb-vset-mask"; |
| @@ -792,12 +779,11 @@ static int ti_abb_probe(struct platform_device *pdev) | |||
| 792 | &abb->ldovbb_vset_mask); | 779 | &abb->ldovbb_vset_mask); |
| 793 | if (ret) { | 780 | if (ret) { |
| 794 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); | 781 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); |
| 795 | goto err; | 782 | return ret; |
| 796 | } | 783 | } |
| 797 | if (!abb->ldovbb_vset_mask) { | 784 | if (!abb->ldovbb_vset_mask) { |
| 798 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); | 785 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); |
| 799 | ret = -EINVAL; | 786 | return -EINVAL; |
| 800 | goto err; | ||
| 801 | } | 787 | } |
| 802 | 788 | ||
| 803 | skip_opt: | 789 | skip_opt: |
| @@ -807,31 +793,29 @@ skip_opt: | |||
| 807 | &abb->txdone_mask); | 793 | &abb->txdone_mask); |
| 808 | if (ret) { | 794 | if (ret) { |
| 809 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); | 795 | dev_err(dev, "Missing '%s' (%d)\n", pname, ret); |
| 810 | goto err; | 796 | return ret; |
| 811 | } | 797 | } |
| 812 | if (!abb->txdone_mask) { | 798 | if (!abb->txdone_mask) { |
| 813 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); | 799 | dev_err(dev, "Invalid property:'%s' set as 0!\n", pname); |
| 814 | ret = -EINVAL; | 800 | return -EINVAL; |
| 815 | goto err; | ||
| 816 | } | 801 | } |
| 817 | 802 | ||
| 818 | initdata = of_get_regulator_init_data(dev, pdev->dev.of_node); | 803 | initdata = of_get_regulator_init_data(dev, pdev->dev.of_node); |
| 819 | if (!initdata) { | 804 | if (!initdata) { |
| 820 | ret = -ENOMEM; | ||
| 821 | dev_err(dev, "%s: Unable to alloc regulator init data\n", | 805 | dev_err(dev, "%s: Unable to alloc regulator init data\n", |
| 822 | __func__); | 806 | __func__); |
| 823 | goto err; | 807 | return -ENOMEM; |
| 824 | } | 808 | } |
| 825 | 809 | ||
| 826 | /* init ABB opp_sel table */ | 810 | /* init ABB opp_sel table */ |
| 827 | ret = ti_abb_init_table(dev, abb, initdata); | 811 | ret = ti_abb_init_table(dev, abb, initdata); |
| 828 | if (ret) | 812 | if (ret) |
| 829 | goto err; | 813 | return ret; |
| 830 | 814 | ||
| 831 | /* init ABB timing */ | 815 | /* init ABB timing */ |
| 832 | ret = ti_abb_init_timings(dev, abb); | 816 | ret = ti_abb_init_timings(dev, abb); |
| 833 | if (ret) | 817 | if (ret) |
| 834 | goto err; | 818 | return ret; |
| 835 | 819 | ||
| 836 | desc = &abb->rdesc; | 820 | desc = &abb->rdesc; |
| 837 | desc->name = dev_name(dev); | 821 | desc->name = dev_name(dev); |
| @@ -849,12 +833,12 @@ skip_opt: | |||
| 849 | config.driver_data = abb; | 833 | config.driver_data = abb; |
| 850 | config.of_node = pdev->dev.of_node; | 834 | config.of_node = pdev->dev.of_node; |
| 851 | 835 | ||
| 852 | rdev = regulator_register(desc, &config); | 836 | rdev = devm_regulator_register(dev, desc, &config); |
| 853 | if (IS_ERR(rdev)) { | 837 | if (IS_ERR(rdev)) { |
| 854 | ret = PTR_ERR(rdev); | 838 | ret = PTR_ERR(rdev); |
| 855 | dev_err(dev, "%s: failed to register regulator(%d)\n", | 839 | dev_err(dev, "%s: failed to register regulator(%d)\n", |
| 856 | __func__, ret); | 840 | __func__, ret); |
| 857 | goto err; | 841 | return ret; |
| 858 | } | 842 | } |
| 859 | platform_set_drvdata(pdev, rdev); | 843 | platform_set_drvdata(pdev, rdev); |
| 860 | 844 | ||
| @@ -862,31 +846,12 @@ skip_opt: | |||
| 862 | ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->regs->setup_reg, abb->base); | 846 | ti_abb_rmw(abb->regs->sr2_en_mask, 1, abb->regs->setup_reg, abb->base); |
| 863 | 847 | ||
| 864 | return 0; | 848 | return 0; |
| 865 | |||
| 866 | err: | ||
| 867 | dev_err(dev, "%s: Failed to initialize(%d)\n", __func__, ret); | ||
| 868 | return ret; | ||
| 869 | } | ||
| 870 | |||
| 871 | /** | ||
| 872 | * ti_abb_remove() - cleanups | ||
| 873 | * @pdev: ABB platform device | ||
| 874 | * | ||
| 875 | * Return: 0 | ||
| 876 | */ | ||
| 877 | static int ti_abb_remove(struct platform_device *pdev) | ||
| 878 | { | ||
| 879 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
| 880 | |||
| 881 | regulator_unregister(rdev); | ||
| 882 | return 0; | ||
| 883 | } | 849 | } |
| 884 | 850 | ||
| 885 | MODULE_ALIAS("platform:ti_abb"); | 851 | MODULE_ALIAS("platform:ti_abb"); |
| 886 | 852 | ||
| 887 | static struct platform_driver ti_abb_driver = { | 853 | static struct platform_driver ti_abb_driver = { |
| 888 | .probe = ti_abb_probe, | 854 | .probe = ti_abb_probe, |
| 889 | .remove = ti_abb_remove, | ||
| 890 | .driver = { | 855 | .driver = { |
| 891 | .name = "ti_abb", | 856 | .name = "ti_abb", |
| 892 | .owner = THIS_MODULE, | 857 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c index 9392a7ca3d2d..b0a3f0917a27 100644 --- a/drivers/regulator/tps51632-regulator.c +++ b/drivers/regulator/tps51632-regulator.c | |||
| @@ -343,7 +343,7 @@ static int tps51632_probe(struct i2c_client *client, | |||
| 343 | config.regmap = tps->regmap; | 343 | config.regmap = tps->regmap; |
| 344 | config.of_node = client->dev.of_node; | 344 | config.of_node = client->dev.of_node; |
| 345 | 345 | ||
| 346 | rdev = regulator_register(&tps->desc, &config); | 346 | rdev = devm_regulator_register(&client->dev, &tps->desc, &config); |
| 347 | if (IS_ERR(rdev)) { | 347 | if (IS_ERR(rdev)) { |
| 348 | dev_err(tps->dev, "regulator register failed\n"); | 348 | dev_err(tps->dev, "regulator register failed\n"); |
| 349 | return PTR_ERR(rdev); | 349 | return PTR_ERR(rdev); |
| @@ -353,14 +353,6 @@ static int tps51632_probe(struct i2c_client *client, | |||
| 353 | return 0; | 353 | return 0; |
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | static int tps51632_remove(struct i2c_client *client) | ||
| 357 | { | ||
| 358 | struct tps51632_chip *tps = i2c_get_clientdata(client); | ||
| 359 | |||
| 360 | regulator_unregister(tps->rdev); | ||
| 361 | return 0; | ||
| 362 | } | ||
| 363 | |||
| 364 | static const struct i2c_device_id tps51632_id[] = { | 356 | static const struct i2c_device_id tps51632_id[] = { |
| 365 | {.name = "tps51632",}, | 357 | {.name = "tps51632",}, |
| 366 | {}, | 358 | {}, |
| @@ -375,7 +367,6 @@ static struct i2c_driver tps51632_i2c_driver = { | |||
| 375 | .of_match_table = of_match_ptr(tps51632_of_match), | 367 | .of_match_table = of_match_ptr(tps51632_of_match), |
| 376 | }, | 368 | }, |
| 377 | .probe = tps51632_probe, | 369 | .probe = tps51632_probe, |
| 378 | .remove = tps51632_remove, | ||
| 379 | .id_table = tps51632_id, | 370 | .id_table = tps51632_id, |
| 380 | }; | 371 | }; |
| 381 | 372 | ||
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index 0b7ebb1ebf85..c2c0185a2dcd 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c | |||
| @@ -476,7 +476,7 @@ static int tps62360_probe(struct i2c_client *client, | |||
| 476 | config.of_node = client->dev.of_node; | 476 | config.of_node = client->dev.of_node; |
| 477 | 477 | ||
| 478 | /* Register the regulators */ | 478 | /* Register the regulators */ |
| 479 | rdev = regulator_register(&tps->desc, &config); | 479 | rdev = devm_regulator_register(&client->dev, &tps->desc, &config); |
| 480 | if (IS_ERR(rdev)) { | 480 | if (IS_ERR(rdev)) { |
| 481 | dev_err(tps->dev, | 481 | dev_err(tps->dev, |
| 482 | "%s(): regulator register failed with err %s\n", | 482 | "%s(): regulator register failed with err %s\n", |
| @@ -488,20 +488,6 @@ static int tps62360_probe(struct i2c_client *client, | |||
| 488 | return 0; | 488 | return 0; |
| 489 | } | 489 | } |
| 490 | 490 | ||
| 491 | /** | ||
| 492 | * tps62360_remove - tps62360 driver i2c remove handler | ||
| 493 | * @client: i2c driver client device structure | ||
| 494 | * | ||
| 495 | * Unregister TPS driver as an i2c client device driver | ||
| 496 | */ | ||
| 497 | static int tps62360_remove(struct i2c_client *client) | ||
| 498 | { | ||
| 499 | struct tps62360_chip *tps = i2c_get_clientdata(client); | ||
| 500 | |||
| 501 | regulator_unregister(tps->rdev); | ||
| 502 | return 0; | ||
| 503 | } | ||
| 504 | |||
| 505 | static void tps62360_shutdown(struct i2c_client *client) | 491 | static void tps62360_shutdown(struct i2c_client *client) |
| 506 | { | 492 | { |
| 507 | struct tps62360_chip *tps = i2c_get_clientdata(client); | 493 | struct tps62360_chip *tps = i2c_get_clientdata(client); |
| @@ -535,7 +521,6 @@ static struct i2c_driver tps62360_i2c_driver = { | |||
| 535 | .of_match_table = of_match_ptr(tps62360_of_match), | 521 | .of_match_table = of_match_ptr(tps62360_of_match), |
| 536 | }, | 522 | }, |
| 537 | .probe = tps62360_probe, | 523 | .probe = tps62360_probe, |
| 538 | .remove = tps62360_remove, | ||
| 539 | .shutdown = tps62360_shutdown, | 524 | .shutdown = tps62360_shutdown, |
| 540 | .id_table = tps62360_id, | 525 | .id_table = tps62360_id, |
| 541 | }; | 526 | }; |
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c index a15263d4bdff..a957579bd98b 100644 --- a/drivers/regulator/tps65023-regulator.c +++ b/drivers/regulator/tps65023-regulator.c | |||
| @@ -277,12 +277,12 @@ static int tps_65023_probe(struct i2c_client *client, | |||
| 277 | config.regmap = tps->regmap; | 277 | config.regmap = tps->regmap; |
| 278 | 278 | ||
| 279 | /* Register the regulators */ | 279 | /* Register the regulators */ |
| 280 | rdev = regulator_register(&tps->desc[i], &config); | 280 | rdev = devm_regulator_register(&client->dev, &tps->desc[i], |
| 281 | &config); | ||
| 281 | if (IS_ERR(rdev)) { | 282 | if (IS_ERR(rdev)) { |
| 282 | dev_err(&client->dev, "failed to register %s\n", | 283 | dev_err(&client->dev, "failed to register %s\n", |
| 283 | id->name); | 284 | id->name); |
| 284 | error = PTR_ERR(rdev); | 285 | return PTR_ERR(rdev); |
| 285 | goto fail; | ||
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | /* Save regulator for cleanup */ | 288 | /* Save regulator for cleanup */ |
| @@ -296,21 +296,6 @@ static int tps_65023_probe(struct i2c_client *client, | |||
| 296 | TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ); | 296 | TPS65023_REG_CTRL2_CORE_ADJ, TPS65023_REG_CTRL2_CORE_ADJ); |
| 297 | 297 | ||
| 298 | return 0; | 298 | return 0; |
| 299 | |||
| 300 | fail: | ||
| 301 | while (--i >= 0) | ||
| 302 | regulator_unregister(tps->rdev[i]); | ||
| 303 | return error; | ||
| 304 | } | ||
| 305 | |||
| 306 | static int tps_65023_remove(struct i2c_client *client) | ||
| 307 | { | ||
| 308 | struct tps_pmic *tps = i2c_get_clientdata(client); | ||
| 309 | int i; | ||
| 310 | |||
| 311 | for (i = 0; i < TPS65023_NUM_REGULATOR; i++) | ||
| 312 | regulator_unregister(tps->rdev[i]); | ||
| 313 | return 0; | ||
| 314 | } | 299 | } |
| 315 | 300 | ||
| 316 | static const struct tps_info tps65020_regs[] = { | 301 | static const struct tps_info tps65020_regs[] = { |
| @@ -430,7 +415,6 @@ static struct i2c_driver tps_65023_i2c_driver = { | |||
| 430 | .owner = THIS_MODULE, | 415 | .owner = THIS_MODULE, |
| 431 | }, | 416 | }, |
| 432 | .probe = tps_65023_probe, | 417 | .probe = tps_65023_probe, |
| 433 | .remove = tps_65023_remove, | ||
| 434 | .id_table = tps_65023_id, | 418 | .id_table = tps_65023_id, |
| 435 | }; | 419 | }; |
| 436 | 420 | ||
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c index 4117ff52dba1..162a0fae20b3 100644 --- a/drivers/regulator/tps6507x-regulator.c +++ b/drivers/regulator/tps6507x-regulator.c | |||
| @@ -508,13 +508,13 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) | |||
| 508 | config.of_node = tps6507x_reg_matches[i].of_node; | 508 | config.of_node = tps6507x_reg_matches[i].of_node; |
| 509 | } | 509 | } |
| 510 | 510 | ||
| 511 | rdev = regulator_register(&tps->desc[i], &config); | 511 | rdev = devm_regulator_register(&pdev->dev, &tps->desc[i], |
| 512 | &config); | ||
| 512 | if (IS_ERR(rdev)) { | 513 | if (IS_ERR(rdev)) { |
| 513 | dev_err(tps6507x_dev->dev, | 514 | dev_err(tps6507x_dev->dev, |
| 514 | "failed to register %s regulator\n", | 515 | "failed to register %s regulator\n", |
| 515 | pdev->name); | 516 | pdev->name); |
| 516 | error = PTR_ERR(rdev); | 517 | return PTR_ERR(rdev); |
| 517 | goto fail; | ||
| 518 | } | 518 | } |
| 519 | 519 | ||
| 520 | /* Save regulator for cleanup */ | 520 | /* Save regulator for cleanup */ |
| @@ -525,22 +525,6 @@ static int tps6507x_pmic_probe(struct platform_device *pdev) | |||
| 525 | platform_set_drvdata(pdev, tps6507x_dev); | 525 | platform_set_drvdata(pdev, tps6507x_dev); |
| 526 | 526 | ||
| 527 | return 0; | 527 | return 0; |
| 528 | |||
| 529 | fail: | ||
| 530 | while (--i >= 0) | ||
| 531 | regulator_unregister(tps->rdev[i]); | ||
| 532 | return error; | ||
| 533 | } | ||
| 534 | |||
| 535 | static int tps6507x_pmic_remove(struct platform_device *pdev) | ||
| 536 | { | ||
| 537 | struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev); | ||
| 538 | struct tps6507x_pmic *tps = tps6507x_dev->pmic; | ||
| 539 | int i; | ||
| 540 | |||
| 541 | for (i = 0; i < TPS6507X_NUM_REGULATOR; i++) | ||
| 542 | regulator_unregister(tps->rdev[i]); | ||
| 543 | return 0; | ||
| 544 | } | 528 | } |
| 545 | 529 | ||
| 546 | static struct platform_driver tps6507x_pmic_driver = { | 530 | static struct platform_driver tps6507x_pmic_driver = { |
| @@ -549,7 +533,6 @@ static struct platform_driver tps6507x_pmic_driver = { | |||
| 549 | .owner = THIS_MODULE, | 533 | .owner = THIS_MODULE, |
| 550 | }, | 534 | }, |
| 551 | .probe = tps6507x_pmic_probe, | 535 | .probe = tps6507x_pmic_probe, |
| 552 | .remove = tps6507x_pmic_remove, | ||
| 553 | }; | 536 | }; |
| 554 | 537 | ||
| 555 | static int __init tps6507x_pmic_init(void) | 538 | static int __init tps6507x_pmic_init(void) |
diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index c8e70451df38..bd611cdf6e1c 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c | |||
| @@ -279,7 +279,7 @@ static int tps65090_regulator_probe(struct platform_device *pdev) | |||
| 279 | if (ret < 0) { | 279 | if (ret < 0) { |
| 280 | dev_err(&pdev->dev, | 280 | dev_err(&pdev->dev, |
| 281 | "failed disable ext control\n"); | 281 | "failed disable ext control\n"); |
| 282 | goto scrub; | 282 | return ret; |
| 283 | } | 283 | } |
| 284 | } | 284 | } |
| 285 | } | 285 | } |
| @@ -296,12 +296,11 @@ static int tps65090_regulator_probe(struct platform_device *pdev) | |||
| 296 | else | 296 | else |
| 297 | config.of_node = NULL; | 297 | config.of_node = NULL; |
| 298 | 298 | ||
| 299 | rdev = regulator_register(ri->desc, &config); | 299 | rdev = devm_regulator_register(&pdev->dev, ri->desc, &config); |
| 300 | if (IS_ERR(rdev)) { | 300 | if (IS_ERR(rdev)) { |
| 301 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 301 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
| 302 | ri->desc->name); | 302 | ri->desc->name); |
| 303 | ret = PTR_ERR(rdev); | 303 | return PTR_ERR(rdev); |
| 304 | goto scrub; | ||
| 305 | } | 304 | } |
| 306 | ri->rdev = rdev; | 305 | ri->rdev = rdev; |
| 307 | 306 | ||
| @@ -309,36 +308,13 @@ static int tps65090_regulator_probe(struct platform_device *pdev) | |||
| 309 | if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data && | 308 | if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data && |
| 310 | tps_pdata->enable_ext_control) { | 309 | tps_pdata->enable_ext_control) { |
| 311 | ret = tps65090_config_ext_control(ri, true); | 310 | ret = tps65090_config_ext_control(ri, true); |
| 312 | if (ret < 0) { | 311 | if (ret < 0) |
| 313 | /* Increment num to get unregister rdev */ | 312 | return ret; |
| 314 | num++; | ||
| 315 | goto scrub; | ||
| 316 | } | ||
| 317 | } | 313 | } |
| 318 | } | 314 | } |
| 319 | 315 | ||
| 320 | platform_set_drvdata(pdev, pmic); | 316 | platform_set_drvdata(pdev, pmic); |
| 321 | return 0; | 317 | return 0; |
| 322 | |||
| 323 | scrub: | ||
| 324 | while (--num >= 0) { | ||
| 325 | ri = &pmic[num]; | ||
| 326 | regulator_unregister(ri->rdev); | ||
| 327 | } | ||
| 328 | return ret; | ||
| 329 | } | ||
| 330 | |||
| 331 | static int tps65090_regulator_remove(struct platform_device *pdev) | ||
| 332 | { | ||
| 333 | struct tps65090_regulator *pmic = platform_get_drvdata(pdev); | ||
| 334 | struct tps65090_regulator *ri; | ||
| 335 | int num; | ||
| 336 | |||
| 337 | for (num = 0; num < TPS65090_REGULATOR_MAX; ++num) { | ||
| 338 | ri = &pmic[num]; | ||
| 339 | regulator_unregister(ri->rdev); | ||
| 340 | } | ||
| 341 | return 0; | ||
| 342 | } | 318 | } |
| 343 | 319 | ||
| 344 | static struct platform_driver tps65090_regulator_driver = { | 320 | static struct platform_driver tps65090_regulator_driver = { |
| @@ -347,7 +323,6 @@ static struct platform_driver tps65090_regulator_driver = { | |||
| 347 | .owner = THIS_MODULE, | 323 | .owner = THIS_MODULE, |
| 348 | }, | 324 | }, |
| 349 | .probe = tps65090_regulator_probe, | 325 | .probe = tps65090_regulator_probe, |
| 350 | .remove = tps65090_regulator_remove, | ||
| 351 | }; | 326 | }; |
| 352 | 327 | ||
| 353 | static int __init tps65090_regulator_init(void) | 328 | static int __init tps65090_regulator_init(void) |
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index 90861d68a0b0..8860379fd6be 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c | |||
| @@ -233,7 +233,7 @@ static int tps65217_regulator_probe(struct platform_device *pdev) | |||
| 233 | struct regulator_init_data *reg_data; | 233 | struct regulator_init_data *reg_data; |
| 234 | struct regulator_dev *rdev; | 234 | struct regulator_dev *rdev; |
| 235 | struct regulator_config config = { }; | 235 | struct regulator_config config = { }; |
| 236 | int i, ret; | 236 | int i; |
| 237 | 237 | ||
| 238 | if (tps->dev->of_node) | 238 | if (tps->dev->of_node) |
| 239 | pdata = tps65217_parse_dt(pdev); | 239 | pdata = tps65217_parse_dt(pdev); |
| @@ -269,35 +269,18 @@ static int tps65217_regulator_probe(struct platform_device *pdev) | |||
| 269 | if (tps->dev->of_node) | 269 | if (tps->dev->of_node) |
| 270 | config.of_node = pdata->of_node[i]; | 270 | config.of_node = pdata->of_node[i]; |
| 271 | 271 | ||
| 272 | rdev = regulator_register(®ulators[i], &config); | 272 | rdev = devm_regulator_register(&pdev->dev, ®ulators[i], |
| 273 | &config); | ||
| 273 | if (IS_ERR(rdev)) { | 274 | if (IS_ERR(rdev)) { |
| 274 | dev_err(tps->dev, "failed to register %s regulator\n", | 275 | dev_err(tps->dev, "failed to register %s regulator\n", |
| 275 | pdev->name); | 276 | pdev->name); |
| 276 | ret = PTR_ERR(rdev); | 277 | return PTR_ERR(rdev); |
| 277 | goto err_unregister_regulator; | ||
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | /* Save regulator for cleanup */ | 280 | /* Save regulator for cleanup */ |
| 281 | tps->rdev[i] = rdev; | 281 | tps->rdev[i] = rdev; |
| 282 | } | 282 | } |
| 283 | return 0; | 283 | return 0; |
| 284 | |||
| 285 | err_unregister_regulator: | ||
| 286 | while (--i >= 0) | ||
| 287 | regulator_unregister(tps->rdev[i]); | ||
| 288 | |||
| 289 | return ret; | ||
| 290 | } | ||
| 291 | |||
| 292 | static int tps65217_regulator_remove(struct platform_device *pdev) | ||
| 293 | { | ||
| 294 | struct tps65217 *tps = platform_get_drvdata(pdev); | ||
| 295 | unsigned int i; | ||
| 296 | |||
| 297 | for (i = 0; i < TPS65217_NUM_REGULATOR; i++) | ||
| 298 | regulator_unregister(tps->rdev[i]); | ||
| 299 | |||
| 300 | return 0; | ||
| 301 | } | 284 | } |
| 302 | 285 | ||
| 303 | static struct platform_driver tps65217_regulator_driver = { | 286 | static struct platform_driver tps65217_regulator_driver = { |
| @@ -305,7 +288,6 @@ static struct platform_driver tps65217_regulator_driver = { | |||
| 305 | .name = "tps65217-pmic", | 288 | .name = "tps65217-pmic", |
| 306 | }, | 289 | }, |
| 307 | .probe = tps65217_regulator_probe, | 290 | .probe = tps65217_regulator_probe, |
| 308 | .remove = tps65217_regulator_remove, | ||
| 309 | }; | 291 | }; |
| 310 | 292 | ||
| 311 | static int __init tps65217_regulator_init(void) | 293 | static int __init tps65217_regulator_init(void) |
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c index 2c9155b66f09..45e5d683d3f8 100644 --- a/drivers/regulator/tps6586x-regulator.c +++ b/drivers/regulator/tps6586x-regulator.c | |||
| @@ -379,15 +379,14 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) | |||
| 379 | ri = find_regulator_info(id); | 379 | ri = find_regulator_info(id); |
| 380 | if (!ri) { | 380 | if (!ri) { |
| 381 | dev_err(&pdev->dev, "invalid regulator ID specified\n"); | 381 | dev_err(&pdev->dev, "invalid regulator ID specified\n"); |
| 382 | err = -EINVAL; | 382 | return -EINVAL; |
| 383 | goto fail; | ||
| 384 | } | 383 | } |
| 385 | 384 | ||
| 386 | err = tps6586x_regulator_preinit(pdev->dev.parent, ri); | 385 | err = tps6586x_regulator_preinit(pdev->dev.parent, ri); |
| 387 | if (err) { | 386 | if (err) { |
| 388 | dev_err(&pdev->dev, | 387 | dev_err(&pdev->dev, |
| 389 | "regulator %d preinit failed, e %d\n", id, err); | 388 | "regulator %d preinit failed, e %d\n", id, err); |
| 390 | goto fail; | 389 | return err; |
| 391 | } | 390 | } |
| 392 | 391 | ||
| 393 | config.dev = pdev->dev.parent; | 392 | config.dev = pdev->dev.parent; |
| @@ -397,12 +396,12 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) | |||
| 397 | if (tps6586x_reg_matches) | 396 | if (tps6586x_reg_matches) |
| 398 | config.of_node = tps6586x_reg_matches[id].of_node; | 397 | config.of_node = tps6586x_reg_matches[id].of_node; |
| 399 | 398 | ||
| 400 | rdev[id] = regulator_register(&ri->desc, &config); | 399 | rdev[id] = devm_regulator_register(&pdev->dev, &ri->desc, |
| 400 | &config); | ||
| 401 | if (IS_ERR(rdev[id])) { | 401 | if (IS_ERR(rdev[id])) { |
| 402 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 402 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
| 403 | ri->desc.name); | 403 | ri->desc.name); |
| 404 | err = PTR_ERR(rdev[id]); | 404 | return PTR_ERR(rdev[id]); |
| 405 | goto fail; | ||
| 406 | } | 405 | } |
| 407 | 406 | ||
| 408 | if (reg_data) { | 407 | if (reg_data) { |
| @@ -411,30 +410,13 @@ static int tps6586x_regulator_probe(struct platform_device *pdev) | |||
| 411 | if (err < 0) { | 410 | if (err < 0) { |
| 412 | dev_err(&pdev->dev, | 411 | dev_err(&pdev->dev, |
| 413 | "Slew rate config failed, e %d\n", err); | 412 | "Slew rate config failed, e %d\n", err); |
| 414 | regulator_unregister(rdev[id]); | 413 | return err; |
| 415 | goto fail; | ||
| 416 | } | 414 | } |
| 417 | } | 415 | } |
| 418 | } | 416 | } |
| 419 | 417 | ||
| 420 | platform_set_drvdata(pdev, rdev); | 418 | platform_set_drvdata(pdev, rdev); |
| 421 | return 0; | 419 | return 0; |
| 422 | |||
| 423 | fail: | ||
| 424 | while (--id >= 0) | ||
| 425 | regulator_unregister(rdev[id]); | ||
| 426 | return err; | ||
| 427 | } | ||
| 428 | |||
| 429 | static int tps6586x_regulator_remove(struct platform_device *pdev) | ||
| 430 | { | ||
| 431 | struct regulator_dev **rdev = platform_get_drvdata(pdev); | ||
| 432 | int id = TPS6586X_ID_MAX_REGULATOR; | ||
| 433 | |||
| 434 | while (--id >= 0) | ||
| 435 | regulator_unregister(rdev[id]); | ||
| 436 | |||
| 437 | return 0; | ||
| 438 | } | 420 | } |
| 439 | 421 | ||
| 440 | static struct platform_driver tps6586x_regulator_driver = { | 422 | static struct platform_driver tps6586x_regulator_driver = { |
| @@ -443,7 +425,6 @@ static struct platform_driver tps6586x_regulator_driver = { | |||
| 443 | .owner = THIS_MODULE, | 425 | .owner = THIS_MODULE, |
| 444 | }, | 426 | }, |
| 445 | .probe = tps6586x_regulator_probe, | 427 | .probe = tps6586x_regulator_probe, |
| 446 | .remove = tps6586x_regulator_remove, | ||
| 447 | }; | 428 | }; |
| 448 | 429 | ||
| 449 | static int __init tps6586x_regulator_init(void) | 430 | static int __init tps6586x_regulator_init(void) |
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 45c16447744b..b8167df71170 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c | |||
| @@ -1177,35 +1177,19 @@ static int tps65910_probe(struct platform_device *pdev) | |||
| 1177 | if (tps65910_reg_matches) | 1177 | if (tps65910_reg_matches) |
| 1178 | config.of_node = tps65910_reg_matches[i].of_node; | 1178 | config.of_node = tps65910_reg_matches[i].of_node; |
| 1179 | 1179 | ||
| 1180 | rdev = regulator_register(&pmic->desc[i], &config); | 1180 | rdev = devm_regulator_register(&pdev->dev, &pmic->desc[i], |
| 1181 | &config); | ||
| 1181 | if (IS_ERR(rdev)) { | 1182 | if (IS_ERR(rdev)) { |
| 1182 | dev_err(tps65910->dev, | 1183 | dev_err(tps65910->dev, |
| 1183 | "failed to register %s regulator\n", | 1184 | "failed to register %s regulator\n", |
| 1184 | pdev->name); | 1185 | pdev->name); |
| 1185 | err = PTR_ERR(rdev); | 1186 | return PTR_ERR(rdev); |
| 1186 | goto err_unregister_regulator; | ||
| 1187 | } | 1187 | } |
| 1188 | 1188 | ||
| 1189 | /* Save regulator for cleanup */ | 1189 | /* Save regulator for cleanup */ |
| 1190 | pmic->rdev[i] = rdev; | 1190 | pmic->rdev[i] = rdev; |
| 1191 | } | 1191 | } |
| 1192 | return 0; | 1192 | return 0; |
| 1193 | |||
| 1194 | err_unregister_regulator: | ||
| 1195 | while (--i >= 0) | ||
| 1196 | regulator_unregister(pmic->rdev[i]); | ||
| 1197 | return err; | ||
| 1198 | } | ||
| 1199 | |||
| 1200 | static int tps65910_remove(struct platform_device *pdev) | ||
| 1201 | { | ||
| 1202 | struct tps65910_reg *pmic = platform_get_drvdata(pdev); | ||
| 1203 | int i; | ||
| 1204 | |||
| 1205 | for (i = 0; i < pmic->num_regulators; i++) | ||
| 1206 | regulator_unregister(pmic->rdev[i]); | ||
| 1207 | |||
| 1208 | return 0; | ||
| 1209 | } | 1193 | } |
| 1210 | 1194 | ||
| 1211 | static void tps65910_shutdown(struct platform_device *pdev) | 1195 | static void tps65910_shutdown(struct platform_device *pdev) |
| @@ -1244,7 +1228,6 @@ static struct platform_driver tps65910_driver = { | |||
| 1244 | .owner = THIS_MODULE, | 1228 | .owner = THIS_MODULE, |
| 1245 | }, | 1229 | }, |
| 1246 | .probe = tps65910_probe, | 1230 | .probe = tps65910_probe, |
| 1247 | .remove = tps65910_remove, | ||
| 1248 | .shutdown = tps65910_shutdown, | 1231 | .shutdown = tps65910_shutdown, |
| 1249 | }; | 1232 | }; |
| 1250 | 1233 | ||
diff --git a/drivers/regulator/tps65912-regulator.c b/drivers/regulator/tps65912-regulator.c index 281e52ac64ba..1ed4d049abfe 100644 --- a/drivers/regulator/tps65912-regulator.c +++ b/drivers/regulator/tps65912-regulator.c | |||
| @@ -461,7 +461,7 @@ static int tps65912_probe(struct platform_device *pdev) | |||
| 461 | struct regulator_dev *rdev; | 461 | struct regulator_dev *rdev; |
| 462 | struct tps65912_reg *pmic; | 462 | struct tps65912_reg *pmic; |
| 463 | struct tps65912_board *pmic_plat_data; | 463 | struct tps65912_board *pmic_plat_data; |
| 464 | int i, err; | 464 | int i; |
| 465 | 465 | ||
| 466 | pmic_plat_data = dev_get_platdata(tps65912->dev); | 466 | pmic_plat_data = dev_get_platdata(tps65912->dev); |
| 467 | if (!pmic_plat_data) | 467 | if (!pmic_plat_data) |
| @@ -504,34 +504,19 @@ static int tps65912_probe(struct platform_device *pdev) | |||
| 504 | config.init_data = reg_data; | 504 | config.init_data = reg_data; |
| 505 | config.driver_data = pmic; | 505 | config.driver_data = pmic; |
| 506 | 506 | ||
| 507 | rdev = regulator_register(&pmic->desc[i], &config); | 507 | rdev = devm_regulator_register(&pdev->dev, &pmic->desc[i], |
| 508 | &config); | ||
| 508 | if (IS_ERR(rdev)) { | 509 | if (IS_ERR(rdev)) { |
| 509 | dev_err(tps65912->dev, | 510 | dev_err(tps65912->dev, |
| 510 | "failed to register %s regulator\n", | 511 | "failed to register %s regulator\n", |
| 511 | pdev->name); | 512 | pdev->name); |
| 512 | err = PTR_ERR(rdev); | 513 | return PTR_ERR(rdev); |
| 513 | goto err; | ||
| 514 | } | 514 | } |
| 515 | 515 | ||
| 516 | /* Save regulator for cleanup */ | 516 | /* Save regulator for cleanup */ |
| 517 | pmic->rdev[i] = rdev; | 517 | pmic->rdev[i] = rdev; |
| 518 | } | 518 | } |
| 519 | return 0; | 519 | return 0; |
| 520 | |||
| 521 | err: | ||
| 522 | while (--i >= 0) | ||
| 523 | regulator_unregister(pmic->rdev[i]); | ||
| 524 | return err; | ||
| 525 | } | ||
| 526 | |||
| 527 | static int tps65912_remove(struct platform_device *pdev) | ||
| 528 | { | ||
| 529 | struct tps65912_reg *tps65912_reg = platform_get_drvdata(pdev); | ||
| 530 | int i; | ||
| 531 | |||
| 532 | for (i = 0; i < TPS65912_NUM_REGULATOR; i++) | ||
| 533 | regulator_unregister(tps65912_reg->rdev[i]); | ||
| 534 | return 0; | ||
| 535 | } | 520 | } |
| 536 | 521 | ||
| 537 | static struct platform_driver tps65912_driver = { | 522 | static struct platform_driver tps65912_driver = { |
| @@ -540,7 +525,6 @@ static struct platform_driver tps65912_driver = { | |||
| 540 | .owner = THIS_MODULE, | 525 | .owner = THIS_MODULE, |
| 541 | }, | 526 | }, |
| 542 | .probe = tps65912_probe, | 527 | .probe = tps65912_probe, |
| 543 | .remove = tps65912_remove, | ||
| 544 | }; | 528 | }; |
| 545 | 529 | ||
| 546 | static int __init tps65912_init(void) | 530 | static int __init tps65912_init(void) |
diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c index 6511d0bfd896..71f457a42623 100644 --- a/drivers/regulator/tps80031-regulator.c +++ b/drivers/regulator/tps80031-regulator.c | |||
| @@ -719,7 +719,7 @@ static int tps80031_regulator_probe(struct platform_device *pdev) | |||
| 719 | if (ret < 0) { | 719 | if (ret < 0) { |
| 720 | dev_err(&pdev->dev, | 720 | dev_err(&pdev->dev, |
| 721 | "regulator config failed, e %d\n", ret); | 721 | "regulator config failed, e %d\n", ret); |
| 722 | goto fail; | 722 | return ret; |
| 723 | } | 723 | } |
| 724 | 724 | ||
| 725 | ret = tps80031_power_req_config(pdev->dev.parent, | 725 | ret = tps80031_power_req_config(pdev->dev.parent, |
| @@ -727,41 +727,22 @@ static int tps80031_regulator_probe(struct platform_device *pdev) | |||
| 727 | if (ret < 0) { | 727 | if (ret < 0) { |
| 728 | dev_err(&pdev->dev, | 728 | dev_err(&pdev->dev, |
| 729 | "pwr_req config failed, err %d\n", ret); | 729 | "pwr_req config failed, err %d\n", ret); |
| 730 | goto fail; | 730 | return ret; |
| 731 | } | 731 | } |
| 732 | } | 732 | } |
| 733 | rdev = regulator_register(&ri->rinfo->desc, &config); | 733 | rdev = devm_regulator_register(&pdev->dev, &ri->rinfo->desc, |
| 734 | &config); | ||
| 734 | if (IS_ERR(rdev)) { | 735 | if (IS_ERR(rdev)) { |
| 735 | dev_err(&pdev->dev, | 736 | dev_err(&pdev->dev, |
| 736 | "register regulator failed %s\n", | 737 | "register regulator failed %s\n", |
| 737 | ri->rinfo->desc.name); | 738 | ri->rinfo->desc.name); |
| 738 | ret = PTR_ERR(rdev); | 739 | return PTR_ERR(rdev); |
| 739 | goto fail; | ||
| 740 | } | 740 | } |
| 741 | ri->rdev = rdev; | 741 | ri->rdev = rdev; |
| 742 | } | 742 | } |
| 743 | 743 | ||
| 744 | platform_set_drvdata(pdev, pmic); | 744 | platform_set_drvdata(pdev, pmic); |
| 745 | return 0; | 745 | return 0; |
| 746 | fail: | ||
| 747 | while (--num >= 0) { | ||
| 748 | ri = &pmic[num]; | ||
| 749 | regulator_unregister(ri->rdev); | ||
| 750 | } | ||
| 751 | return ret; | ||
| 752 | } | ||
| 753 | |||
| 754 | static int tps80031_regulator_remove(struct platform_device *pdev) | ||
| 755 | { | ||
| 756 | struct tps80031_regulator *pmic = platform_get_drvdata(pdev); | ||
| 757 | struct tps80031_regulator *ri = NULL; | ||
| 758 | int num; | ||
| 759 | |||
| 760 | for (num = 0; num < TPS80031_REGULATOR_MAX; ++num) { | ||
| 761 | ri = &pmic[num]; | ||
| 762 | regulator_unregister(ri->rdev); | ||
| 763 | } | ||
| 764 | return 0; | ||
| 765 | } | 746 | } |
| 766 | 747 | ||
| 767 | static struct platform_driver tps80031_regulator_driver = { | 748 | static struct platform_driver tps80031_regulator_driver = { |
| @@ -770,7 +751,6 @@ static struct platform_driver tps80031_regulator_driver = { | |||
| 770 | .owner = THIS_MODULE, | 751 | .owner = THIS_MODULE, |
| 771 | }, | 752 | }, |
| 772 | .probe = tps80031_regulator_probe, | 753 | .probe = tps80031_regulator_probe, |
| 773 | .remove = tps80031_regulator_remove, | ||
| 774 | }; | 754 | }; |
| 775 | 755 | ||
| 776 | static int __init tps80031_regulator_init(void) | 756 | static int __init tps80031_regulator_init(void) |
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index 11861cb861df..6823e6f2b88a 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c | |||
| @@ -387,8 +387,9 @@ static struct regulator_ops wm831x_buckv_ops = { | |||
| 387 | * Set up DVS control. We just log errors since we can still run | 387 | * Set up DVS control. We just log errors since we can still run |
| 388 | * (with reduced performance) if we fail. | 388 | * (with reduced performance) if we fail. |
| 389 | */ | 389 | */ |
| 390 | static void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc, | 390 | static void wm831x_buckv_dvs_init(struct platform_device *pdev, |
| 391 | struct wm831x_buckv_pdata *pdata) | 391 | struct wm831x_dcdc *dcdc, |
| 392 | struct wm831x_buckv_pdata *pdata) | ||
| 392 | { | 393 | { |
| 393 | struct wm831x *wm831x = dcdc->wm831x; | 394 | struct wm831x *wm831x = dcdc->wm831x; |
| 394 | int ret; | 395 | int ret; |
| @@ -402,9 +403,9 @@ static void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc, | |||
| 402 | */ | 403 | */ |
| 403 | dcdc->dvs_gpio_state = pdata->dvs_init_state; | 404 | dcdc->dvs_gpio_state = pdata->dvs_init_state; |
| 404 | 405 | ||
| 405 | ret = gpio_request_one(pdata->dvs_gpio, | 406 | ret = devm_gpio_request_one(&pdev->dev, pdata->dvs_gpio, |
| 406 | dcdc->dvs_gpio_state ? GPIOF_INIT_HIGH : 0, | 407 | dcdc->dvs_gpio_state ? GPIOF_INIT_HIGH : 0, |
| 407 | "DCDC DVS"); | 408 | "DCDC DVS"); |
| 408 | if (ret < 0) { | 409 | if (ret < 0) { |
| 409 | dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n", | 410 | dev_err(wm831x->dev, "Failed to get %s DVS GPIO: %d\n", |
| 410 | dcdc->name, ret); | 411 | dcdc->name, ret); |
| @@ -513,7 +514,8 @@ static int wm831x_buckv_probe(struct platform_device *pdev) | |||
| 513 | dcdc->dvs_vsel = ret & WM831X_DC1_DVS_VSEL_MASK; | 514 | dcdc->dvs_vsel = ret & WM831X_DC1_DVS_VSEL_MASK; |
| 514 | 515 | ||
| 515 | if (pdata && pdata->dcdc[id]) | 516 | if (pdata && pdata->dcdc[id]) |
| 516 | wm831x_buckv_dvs_init(dcdc, pdata->dcdc[id]->driver_data); | 517 | wm831x_buckv_dvs_init(pdev, dcdc, |
| 518 | pdata->dcdc[id]->driver_data); | ||
| 517 | 519 | ||
| 518 | config.dev = pdev->dev.parent; | 520 | config.dev = pdev->dev.parent; |
| 519 | if (pdata) | 521 | if (pdata) |
| @@ -521,7 +523,8 @@ static int wm831x_buckv_probe(struct platform_device *pdev) | |||
| 521 | config.driver_data = dcdc; | 523 | config.driver_data = dcdc; |
| 522 | config.regmap = wm831x->regmap; | 524 | config.regmap = wm831x->regmap; |
| 523 | 525 | ||
| 524 | dcdc->regulator = regulator_register(&dcdc->desc, &config); | 526 | dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, |
| 527 | &config); | ||
| 525 | if (IS_ERR(dcdc->regulator)) { | 528 | if (IS_ERR(dcdc->regulator)) { |
| 526 | ret = PTR_ERR(dcdc->regulator); | 529 | ret = PTR_ERR(dcdc->regulator); |
| 527 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", | 530 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", |
| @@ -530,57 +533,35 @@ static int wm831x_buckv_probe(struct platform_device *pdev) | |||
| 530 | } | 533 | } |
| 531 | 534 | ||
| 532 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); | 535 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); |
| 533 | ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, | 536 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
| 534 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); | 537 | wm831x_dcdc_uv_irq, |
| 538 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); | ||
| 535 | if (ret != 0) { | 539 | if (ret != 0) { |
| 536 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 540 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
| 537 | irq, ret); | 541 | irq, ret); |
| 538 | goto err_regulator; | 542 | goto err; |
| 539 | } | 543 | } |
| 540 | 544 | ||
| 541 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")); | 545 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")); |
| 542 | ret = request_threaded_irq(irq, NULL, wm831x_dcdc_oc_irq, | 546 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
| 543 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); | 547 | wm831x_dcdc_oc_irq, |
| 548 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); | ||
| 544 | if (ret != 0) { | 549 | if (ret != 0) { |
| 545 | dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n", | 550 | dev_err(&pdev->dev, "Failed to request HC IRQ %d: %d\n", |
| 546 | irq, ret); | 551 | irq, ret); |
| 547 | goto err_uv; | 552 | goto err; |
| 548 | } | 553 | } |
| 549 | 554 | ||
| 550 | platform_set_drvdata(pdev, dcdc); | 555 | platform_set_drvdata(pdev, dcdc); |
| 551 | 556 | ||
| 552 | return 0; | 557 | return 0; |
| 553 | 558 | ||
| 554 | err_uv: | ||
| 555 | free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")), | ||
| 556 | dcdc); | ||
| 557 | err_regulator: | ||
| 558 | regulator_unregister(dcdc->regulator); | ||
| 559 | err: | 559 | err: |
| 560 | if (dcdc->dvs_gpio) | ||
| 561 | gpio_free(dcdc->dvs_gpio); | ||
| 562 | return ret; | 560 | return ret; |
| 563 | } | 561 | } |
| 564 | 562 | ||
| 565 | static int wm831x_buckv_remove(struct platform_device *pdev) | ||
| 566 | { | ||
| 567 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | ||
| 568 | struct wm831x *wm831x = dcdc->wm831x; | ||
| 569 | |||
| 570 | free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "HC")), | ||
| 571 | dcdc); | ||
| 572 | free_irq(wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")), | ||
| 573 | dcdc); | ||
| 574 | regulator_unregister(dcdc->regulator); | ||
| 575 | if (dcdc->dvs_gpio) | ||
| 576 | gpio_free(dcdc->dvs_gpio); | ||
| 577 | |||
| 578 | return 0; | ||
| 579 | } | ||
| 580 | |||
| 581 | static struct platform_driver wm831x_buckv_driver = { | 563 | static struct platform_driver wm831x_buckv_driver = { |
| 582 | .probe = wm831x_buckv_probe, | 564 | .probe = wm831x_buckv_probe, |
| 583 | .remove = wm831x_buckv_remove, | ||
| 584 | .driver = { | 565 | .driver = { |
| 585 | .name = "wm831x-buckv", | 566 | .name = "wm831x-buckv", |
| 586 | .owner = THIS_MODULE, | 567 | .owner = THIS_MODULE, |
| @@ -681,7 +662,8 @@ static int wm831x_buckp_probe(struct platform_device *pdev) | |||
| 681 | config.driver_data = dcdc; | 662 | config.driver_data = dcdc; |
| 682 | config.regmap = wm831x->regmap; | 663 | config.regmap = wm831x->regmap; |
| 683 | 664 | ||
| 684 | dcdc->regulator = regulator_register(&dcdc->desc, &config); | 665 | dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, |
| 666 | &config); | ||
| 685 | if (IS_ERR(dcdc->regulator)) { | 667 | if (IS_ERR(dcdc->regulator)) { |
| 686 | ret = PTR_ERR(dcdc->regulator); | 668 | ret = PTR_ERR(dcdc->regulator); |
| 687 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", | 669 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", |
| @@ -690,38 +672,25 @@ static int wm831x_buckp_probe(struct platform_device *pdev) | |||
| 690 | } | 672 | } |
| 691 | 673 | ||
| 692 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); | 674 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); |
| 693 | ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, | 675 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
| 694 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); | 676 | wm831x_dcdc_uv_irq, |
| 677 | IRQF_TRIGGER_RISING, dcdc->name, dcdc); | ||
| 695 | if (ret != 0) { | 678 | if (ret != 0) { |
| 696 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 679 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
| 697 | irq, ret); | 680 | irq, ret); |
| 698 | goto err_regulator; | 681 | goto err; |
| 699 | } | 682 | } |
| 700 | 683 | ||
| 701 | platform_set_drvdata(pdev, dcdc); | 684 | platform_set_drvdata(pdev, dcdc); |
| 702 | 685 | ||
| 703 | return 0; | 686 | return 0; |
| 704 | 687 | ||
| 705 | err_regulator: | ||
| 706 | regulator_unregister(dcdc->regulator); | ||
| 707 | err: | 688 | err: |
| 708 | return ret; | 689 | return ret; |
| 709 | } | 690 | } |
| 710 | 691 | ||
| 711 | static int wm831x_buckp_remove(struct platform_device *pdev) | ||
| 712 | { | ||
| 713 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | ||
| 714 | |||
| 715 | free_irq(wm831x_irq(dcdc->wm831x, platform_get_irq_byname(pdev, "UV")), | ||
| 716 | dcdc); | ||
| 717 | regulator_unregister(dcdc->regulator); | ||
| 718 | |||
| 719 | return 0; | ||
| 720 | } | ||
| 721 | |||
| 722 | static struct platform_driver wm831x_buckp_driver = { | 692 | static struct platform_driver wm831x_buckp_driver = { |
| 723 | .probe = wm831x_buckp_probe, | 693 | .probe = wm831x_buckp_probe, |
| 724 | .remove = wm831x_buckp_remove, | ||
| 725 | .driver = { | 694 | .driver = { |
| 726 | .name = "wm831x-buckp", | 695 | .name = "wm831x-buckp", |
| 727 | .owner = THIS_MODULE, | 696 | .owner = THIS_MODULE, |
| @@ -813,7 +782,8 @@ static int wm831x_boostp_probe(struct platform_device *pdev) | |||
| 813 | config.driver_data = dcdc; | 782 | config.driver_data = dcdc; |
| 814 | config.regmap = wm831x->regmap; | 783 | config.regmap = wm831x->regmap; |
| 815 | 784 | ||
| 816 | dcdc->regulator = regulator_register(&dcdc->desc, &config); | 785 | dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, |
| 786 | &config); | ||
| 817 | if (IS_ERR(dcdc->regulator)) { | 787 | if (IS_ERR(dcdc->regulator)) { |
| 818 | ret = PTR_ERR(dcdc->regulator); | 788 | ret = PTR_ERR(dcdc->regulator); |
| 819 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", | 789 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", |
| @@ -822,39 +792,26 @@ static int wm831x_boostp_probe(struct platform_device *pdev) | |||
| 822 | } | 792 | } |
| 823 | 793 | ||
| 824 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); | 794 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); |
| 825 | ret = request_threaded_irq(irq, NULL, wm831x_dcdc_uv_irq, | 795 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
| 826 | IRQF_TRIGGER_RISING, dcdc->name, | 796 | wm831x_dcdc_uv_irq, |
| 827 | dcdc); | 797 | IRQF_TRIGGER_RISING, dcdc->name, |
| 798 | dcdc); | ||
| 828 | if (ret != 0) { | 799 | if (ret != 0) { |
| 829 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 800 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
| 830 | irq, ret); | 801 | irq, ret); |
| 831 | goto err_regulator; | 802 | goto err; |
| 832 | } | 803 | } |
| 833 | 804 | ||
| 834 | platform_set_drvdata(pdev, dcdc); | 805 | platform_set_drvdata(pdev, dcdc); |
| 835 | 806 | ||
| 836 | return 0; | 807 | return 0; |
| 837 | 808 | ||
| 838 | err_regulator: | ||
| 839 | regulator_unregister(dcdc->regulator); | ||
| 840 | err: | 809 | err: |
| 841 | return ret; | 810 | return ret; |
| 842 | } | 811 | } |
| 843 | 812 | ||
| 844 | static int wm831x_boostp_remove(struct platform_device *pdev) | ||
| 845 | { | ||
| 846 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | ||
| 847 | |||
| 848 | free_irq(wm831x_irq(dcdc->wm831x, platform_get_irq_byname(pdev, "UV")), | ||
| 849 | dcdc); | ||
| 850 | regulator_unregister(dcdc->regulator); | ||
| 851 | |||
| 852 | return 0; | ||
| 853 | } | ||
| 854 | |||
| 855 | static struct platform_driver wm831x_boostp_driver = { | 813 | static struct platform_driver wm831x_boostp_driver = { |
| 856 | .probe = wm831x_boostp_probe, | 814 | .probe = wm831x_boostp_probe, |
| 857 | .remove = wm831x_boostp_remove, | ||
| 858 | .driver = { | 815 | .driver = { |
| 859 | .name = "wm831x-boostp", | 816 | .name = "wm831x-boostp", |
| 860 | .owner = THIS_MODULE, | 817 | .owner = THIS_MODULE, |
| @@ -914,7 +871,8 @@ static int wm831x_epe_probe(struct platform_device *pdev) | |||
| 914 | config.driver_data = dcdc; | 871 | config.driver_data = dcdc; |
| 915 | config.regmap = wm831x->regmap; | 872 | config.regmap = wm831x->regmap; |
| 916 | 873 | ||
| 917 | dcdc->regulator = regulator_register(&dcdc->desc, &config); | 874 | dcdc->regulator = devm_regulator_register(&pdev->dev, &dcdc->desc, |
| 875 | &config); | ||
| 918 | if (IS_ERR(dcdc->regulator)) { | 876 | if (IS_ERR(dcdc->regulator)) { |
| 919 | ret = PTR_ERR(dcdc->regulator); | 877 | ret = PTR_ERR(dcdc->regulator); |
| 920 | dev_err(wm831x->dev, "Failed to register EPE%d: %d\n", | 878 | dev_err(wm831x->dev, "Failed to register EPE%d: %d\n", |
| @@ -930,18 +888,8 @@ err: | |||
| 930 | return ret; | 888 | return ret; |
| 931 | } | 889 | } |
| 932 | 890 | ||
| 933 | static int wm831x_epe_remove(struct platform_device *pdev) | ||
| 934 | { | ||
| 935 | struct wm831x_dcdc *dcdc = platform_get_drvdata(pdev); | ||
| 936 | |||
| 937 | regulator_unregister(dcdc->regulator); | ||
| 938 | |||
| 939 | return 0; | ||
| 940 | } | ||
| 941 | |||
| 942 | static struct platform_driver wm831x_epe_driver = { | 891 | static struct platform_driver wm831x_epe_driver = { |
| 943 | .probe = wm831x_epe_probe, | 892 | .probe = wm831x_epe_probe, |
| 944 | .remove = wm831x_epe_remove, | ||
| 945 | .driver = { | 893 | .driver = { |
| 946 | .name = "wm831x-epe", | 894 | .name = "wm831x-epe", |
| 947 | .owner = THIS_MODULE, | 895 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c index 4eb373de1fac..0339b886df5d 100644 --- a/drivers/regulator/wm831x-isink.c +++ b/drivers/regulator/wm831x-isink.c | |||
| @@ -194,7 +194,8 @@ static int wm831x_isink_probe(struct platform_device *pdev) | |||
| 194 | config.init_data = pdata->isink[id]; | 194 | config.init_data = pdata->isink[id]; |
| 195 | config.driver_data = isink; | 195 | config.driver_data = isink; |
| 196 | 196 | ||
| 197 | isink->regulator = regulator_register(&isink->desc, &config); | 197 | isink->regulator = devm_regulator_register(&pdev->dev, &isink->desc, |
| 198 | &config); | ||
| 198 | if (IS_ERR(isink->regulator)) { | 199 | if (IS_ERR(isink->regulator)) { |
| 199 | ret = PTR_ERR(isink->regulator); | 200 | ret = PTR_ERR(isink->regulator); |
| 200 | dev_err(wm831x->dev, "Failed to register ISINK%d: %d\n", | 201 | dev_err(wm831x->dev, "Failed to register ISINK%d: %d\n", |
| @@ -203,38 +204,26 @@ static int wm831x_isink_probe(struct platform_device *pdev) | |||
| 203 | } | 204 | } |
| 204 | 205 | ||
| 205 | irq = wm831x_irq(wm831x, platform_get_irq(pdev, 0)); | 206 | irq = wm831x_irq(wm831x, platform_get_irq(pdev, 0)); |
| 206 | ret = request_threaded_irq(irq, NULL, wm831x_isink_irq, | 207 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
| 207 | IRQF_TRIGGER_RISING, isink->name, isink); | 208 | wm831x_isink_irq, |
| 209 | IRQF_TRIGGER_RISING, isink->name, | ||
| 210 | isink); | ||
| 208 | if (ret != 0) { | 211 | if (ret != 0) { |
| 209 | dev_err(&pdev->dev, "Failed to request ISINK IRQ %d: %d\n", | 212 | dev_err(&pdev->dev, "Failed to request ISINK IRQ %d: %d\n", |
| 210 | irq, ret); | 213 | irq, ret); |
| 211 | goto err_regulator; | 214 | goto err; |
| 212 | } | 215 | } |
| 213 | 216 | ||
| 214 | platform_set_drvdata(pdev, isink); | 217 | platform_set_drvdata(pdev, isink); |
| 215 | 218 | ||
| 216 | return 0; | 219 | return 0; |
| 217 | 220 | ||
| 218 | err_regulator: | ||
| 219 | regulator_unregister(isink->regulator); | ||
| 220 | err: | 221 | err: |
| 221 | return ret; | 222 | return ret; |
| 222 | } | 223 | } |
| 223 | 224 | ||
| 224 | static int wm831x_isink_remove(struct platform_device *pdev) | ||
| 225 | { | ||
| 226 | struct wm831x_isink *isink = platform_get_drvdata(pdev); | ||
| 227 | |||
| 228 | free_irq(wm831x_irq(isink->wm831x, platform_get_irq(pdev, 0)), isink); | ||
| 229 | |||
| 230 | regulator_unregister(isink->regulator); | ||
| 231 | |||
| 232 | return 0; | ||
| 233 | } | ||
| 234 | |||
| 235 | static struct platform_driver wm831x_isink_driver = { | 225 | static struct platform_driver wm831x_isink_driver = { |
| 236 | .probe = wm831x_isink_probe, | 226 | .probe = wm831x_isink_probe, |
| 237 | .remove = wm831x_isink_remove, | ||
| 238 | .driver = { | 227 | .driver = { |
| 239 | .name = "wm831x-isink", | 228 | .name = "wm831x-isink", |
| 240 | .owner = THIS_MODULE, | 229 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/wm831x-ldo.c b/drivers/regulator/wm831x-ldo.c index 1432b26ef2e9..2be72fe36535 100644 --- a/drivers/regulator/wm831x-ldo.c +++ b/drivers/regulator/wm831x-ldo.c | |||
| @@ -279,7 +279,8 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev) | |||
| 279 | config.driver_data = ldo; | 279 | config.driver_data = ldo; |
| 280 | config.regmap = wm831x->regmap; | 280 | config.regmap = wm831x->regmap; |
| 281 | 281 | ||
| 282 | ldo->regulator = regulator_register(&ldo->desc, &config); | 282 | ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, |
| 283 | &config); | ||
| 283 | if (IS_ERR(ldo->regulator)) { | 284 | if (IS_ERR(ldo->regulator)) { |
| 284 | ret = PTR_ERR(ldo->regulator); | 285 | ret = PTR_ERR(ldo->regulator); |
| 285 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", | 286 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", |
| @@ -288,39 +289,26 @@ static int wm831x_gp_ldo_probe(struct platform_device *pdev) | |||
| 288 | } | 289 | } |
| 289 | 290 | ||
| 290 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); | 291 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); |
| 291 | ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, | 292 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
| 292 | IRQF_TRIGGER_RISING, ldo->name, | 293 | wm831x_ldo_uv_irq, |
| 293 | ldo); | 294 | IRQF_TRIGGER_RISING, ldo->name, |
| 295 | ldo); | ||
| 294 | if (ret != 0) { | 296 | if (ret != 0) { |
| 295 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 297 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
| 296 | irq, ret); | 298 | irq, ret); |
| 297 | goto err_regulator; | 299 | goto err; |
| 298 | } | 300 | } |
| 299 | 301 | ||
| 300 | platform_set_drvdata(pdev, ldo); | 302 | platform_set_drvdata(pdev, ldo); |
| 301 | 303 | ||
| 302 | return 0; | 304 | return 0; |
| 303 | 305 | ||
| 304 | err_regulator: | ||
| 305 | regulator_unregister(ldo->regulator); | ||
| 306 | err: | 306 | err: |
| 307 | return ret; | 307 | return ret; |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | static int wm831x_gp_ldo_remove(struct platform_device *pdev) | ||
| 311 | { | ||
| 312 | struct wm831x_ldo *ldo = platform_get_drvdata(pdev); | ||
| 313 | |||
| 314 | free_irq(wm831x_irq(ldo->wm831x, | ||
| 315 | platform_get_irq_byname(pdev, "UV")), ldo); | ||
| 316 | regulator_unregister(ldo->regulator); | ||
| 317 | |||
| 318 | return 0; | ||
| 319 | } | ||
| 320 | |||
| 321 | static struct platform_driver wm831x_gp_ldo_driver = { | 310 | static struct platform_driver wm831x_gp_ldo_driver = { |
| 322 | .probe = wm831x_gp_ldo_probe, | 311 | .probe = wm831x_gp_ldo_probe, |
| 323 | .remove = wm831x_gp_ldo_remove, | ||
| 324 | .driver = { | 312 | .driver = { |
| 325 | .name = "wm831x-ldo", | 313 | .name = "wm831x-ldo", |
| 326 | .owner = THIS_MODULE, | 314 | .owner = THIS_MODULE, |
| @@ -505,7 +493,8 @@ static int wm831x_aldo_probe(struct platform_device *pdev) | |||
| 505 | config.driver_data = ldo; | 493 | config.driver_data = ldo; |
| 506 | config.regmap = wm831x->regmap; | 494 | config.regmap = wm831x->regmap; |
| 507 | 495 | ||
| 508 | ldo->regulator = regulator_register(&ldo->desc, &config); | 496 | ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, |
| 497 | &config); | ||
| 509 | if (IS_ERR(ldo->regulator)) { | 498 | if (IS_ERR(ldo->regulator)) { |
| 510 | ret = PTR_ERR(ldo->regulator); | 499 | ret = PTR_ERR(ldo->regulator); |
| 511 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", | 500 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", |
| @@ -514,38 +503,25 @@ static int wm831x_aldo_probe(struct platform_device *pdev) | |||
| 514 | } | 503 | } |
| 515 | 504 | ||
| 516 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); | 505 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); |
| 517 | ret = request_threaded_irq(irq, NULL, wm831x_ldo_uv_irq, | 506 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
| 518 | IRQF_TRIGGER_RISING, ldo->name, ldo); | 507 | wm831x_ldo_uv_irq, |
| 508 | IRQF_TRIGGER_RISING, ldo->name, ldo); | ||
| 519 | if (ret != 0) { | 509 | if (ret != 0) { |
| 520 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 510 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
| 521 | irq, ret); | 511 | irq, ret); |
| 522 | goto err_regulator; | 512 | goto err; |
| 523 | } | 513 | } |
| 524 | 514 | ||
| 525 | platform_set_drvdata(pdev, ldo); | 515 | platform_set_drvdata(pdev, ldo); |
| 526 | 516 | ||
| 527 | return 0; | 517 | return 0; |
| 528 | 518 | ||
| 529 | err_regulator: | ||
| 530 | regulator_unregister(ldo->regulator); | ||
| 531 | err: | 519 | err: |
| 532 | return ret; | 520 | return ret; |
| 533 | } | 521 | } |
| 534 | 522 | ||
| 535 | static int wm831x_aldo_remove(struct platform_device *pdev) | ||
| 536 | { | ||
| 537 | struct wm831x_ldo *ldo = platform_get_drvdata(pdev); | ||
| 538 | |||
| 539 | free_irq(wm831x_irq(ldo->wm831x, platform_get_irq_byname(pdev, "UV")), | ||
| 540 | ldo); | ||
| 541 | regulator_unregister(ldo->regulator); | ||
| 542 | |||
| 543 | return 0; | ||
| 544 | } | ||
| 545 | |||
| 546 | static struct platform_driver wm831x_aldo_driver = { | 523 | static struct platform_driver wm831x_aldo_driver = { |
| 547 | .probe = wm831x_aldo_probe, | 524 | .probe = wm831x_aldo_probe, |
| 548 | .remove = wm831x_aldo_remove, | ||
| 549 | .driver = { | 525 | .driver = { |
| 550 | .name = "wm831x-aldo", | 526 | .name = "wm831x-aldo", |
| 551 | .owner = THIS_MODULE, | 527 | .owner = THIS_MODULE, |
| @@ -663,7 +639,8 @@ static int wm831x_alive_ldo_probe(struct platform_device *pdev) | |||
| 663 | config.driver_data = ldo; | 639 | config.driver_data = ldo; |
| 664 | config.regmap = wm831x->regmap; | 640 | config.regmap = wm831x->regmap; |
| 665 | 641 | ||
| 666 | ldo->regulator = regulator_register(&ldo->desc, &config); | 642 | ldo->regulator = devm_regulator_register(&pdev->dev, &ldo->desc, |
| 643 | &config); | ||
| 667 | if (IS_ERR(ldo->regulator)) { | 644 | if (IS_ERR(ldo->regulator)) { |
| 668 | ret = PTR_ERR(ldo->regulator); | 645 | ret = PTR_ERR(ldo->regulator); |
| 669 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", | 646 | dev_err(wm831x->dev, "Failed to register LDO%d: %d\n", |
| @@ -679,18 +656,8 @@ err: | |||
| 679 | return ret; | 656 | return ret; |
| 680 | } | 657 | } |
| 681 | 658 | ||
| 682 | static int wm831x_alive_ldo_remove(struct platform_device *pdev) | ||
| 683 | { | ||
| 684 | struct wm831x_ldo *ldo = platform_get_drvdata(pdev); | ||
| 685 | |||
| 686 | regulator_unregister(ldo->regulator); | ||
| 687 | |||
| 688 | return 0; | ||
| 689 | } | ||
| 690 | |||
| 691 | static struct platform_driver wm831x_alive_ldo_driver = { | 659 | static struct platform_driver wm831x_alive_ldo_driver = { |
| 692 | .probe = wm831x_alive_ldo_probe, | 660 | .probe = wm831x_alive_ldo_probe, |
| 693 | .remove = wm831x_alive_ldo_remove, | ||
| 694 | .driver = { | 661 | .driver = { |
| 695 | .name = "wm831x-alive-ldo", | 662 | .name = "wm831x-alive-ldo", |
| 696 | .owner = THIS_MODULE, | 663 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/wm8350-regulator.c b/drivers/regulator/wm8350-regulator.c index 835b5f0f344e..a438e937cfa0 100644 --- a/drivers/regulator/wm8350-regulator.c +++ b/drivers/regulator/wm8350-regulator.c | |||
| @@ -1206,7 +1206,8 @@ static int wm8350_regulator_probe(struct platform_device *pdev) | |||
| 1206 | config.regmap = wm8350->regmap; | 1206 | config.regmap = wm8350->regmap; |
| 1207 | 1207 | ||
| 1208 | /* register regulator */ | 1208 | /* register regulator */ |
| 1209 | rdev = regulator_register(&wm8350_reg[pdev->id], &config); | 1209 | rdev = devm_regulator_register(&pdev->dev, &wm8350_reg[pdev->id], |
| 1210 | &config); | ||
| 1210 | if (IS_ERR(rdev)) { | 1211 | if (IS_ERR(rdev)) { |
| 1211 | dev_err(&pdev->dev, "failed to register %s\n", | 1212 | dev_err(&pdev->dev, "failed to register %s\n", |
| 1212 | wm8350_reg[pdev->id].name); | 1213 | wm8350_reg[pdev->id].name); |
| @@ -1217,7 +1218,6 @@ static int wm8350_regulator_probe(struct platform_device *pdev) | |||
| 1217 | ret = wm8350_register_irq(wm8350, wm8350_reg[pdev->id].irq, | 1218 | ret = wm8350_register_irq(wm8350, wm8350_reg[pdev->id].irq, |
| 1218 | pmic_uv_handler, 0, "UV", rdev); | 1219 | pmic_uv_handler, 0, "UV", rdev); |
| 1219 | if (ret < 0) { | 1220 | if (ret < 0) { |
| 1220 | regulator_unregister(rdev); | ||
| 1221 | dev_err(&pdev->dev, "failed to register regulator %s IRQ\n", | 1221 | dev_err(&pdev->dev, "failed to register regulator %s IRQ\n", |
| 1222 | wm8350_reg[pdev->id].name); | 1222 | wm8350_reg[pdev->id].name); |
| 1223 | return ret; | 1223 | return ret; |
| @@ -1233,8 +1233,6 @@ static int wm8350_regulator_remove(struct platform_device *pdev) | |||
| 1233 | 1233 | ||
| 1234 | wm8350_free_irq(wm8350, wm8350_reg[pdev->id].irq, rdev); | 1234 | wm8350_free_irq(wm8350, wm8350_reg[pdev->id].irq, rdev); |
| 1235 | 1235 | ||
| 1236 | regulator_unregister(rdev); | ||
| 1237 | |||
| 1238 | return 0; | 1236 | return 0; |
| 1239 | } | 1237 | } |
| 1240 | 1238 | ||
diff --git a/drivers/regulator/wm8400-regulator.c b/drivers/regulator/wm8400-regulator.c index 58f51bec13f2..870b52f709bc 100644 --- a/drivers/regulator/wm8400-regulator.c +++ b/drivers/regulator/wm8400-regulator.c | |||
| @@ -219,7 +219,8 @@ static int wm8400_regulator_probe(struct platform_device *pdev) | |||
| 219 | config.driver_data = wm8400; | 219 | config.driver_data = wm8400; |
| 220 | config.regmap = wm8400->regmap; | 220 | config.regmap = wm8400->regmap; |
| 221 | 221 | ||
| 222 | rdev = regulator_register(®ulators[pdev->id], &config); | 222 | rdev = devm_regulator_register(&pdev->dev, ®ulators[pdev->id], |
| 223 | &config); | ||
| 223 | if (IS_ERR(rdev)) | 224 | if (IS_ERR(rdev)) |
| 224 | return PTR_ERR(rdev); | 225 | return PTR_ERR(rdev); |
| 225 | 226 | ||
| @@ -228,21 +229,11 @@ static int wm8400_regulator_probe(struct platform_device *pdev) | |||
| 228 | return 0; | 229 | return 0; |
| 229 | } | 230 | } |
| 230 | 231 | ||
| 231 | static int wm8400_regulator_remove(struct platform_device *pdev) | ||
| 232 | { | ||
| 233 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
| 234 | |||
| 235 | regulator_unregister(rdev); | ||
| 236 | |||
| 237 | return 0; | ||
| 238 | } | ||
| 239 | |||
| 240 | static struct platform_driver wm8400_regulator_driver = { | 232 | static struct platform_driver wm8400_regulator_driver = { |
| 241 | .driver = { | 233 | .driver = { |
| 242 | .name = "wm8400-regulator", | 234 | .name = "wm8400-regulator", |
| 243 | }, | 235 | }, |
| 244 | .probe = wm8400_regulator_probe, | 236 | .probe = wm8400_regulator_probe, |
| 245 | .remove = wm8400_regulator_remove, | ||
| 246 | }; | 237 | }; |
| 247 | 238 | ||
| 248 | /** | 239 | /** |
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c index 5ee2a208457c..71c5911f2e71 100644 --- a/drivers/regulator/wm8994-regulator.c +++ b/drivers/regulator/wm8994-regulator.c | |||
| @@ -165,7 +165,9 @@ static int wm8994_ldo_probe(struct platform_device *pdev) | |||
| 165 | ldo->init_data = *pdata->ldo[id].init_data; | 165 | ldo->init_data = *pdata->ldo[id].init_data; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config); | 168 | ldo->regulator = devm_regulator_register(&pdev->dev, |
| 169 | &wm8994_ldo_desc[id], | ||
| 170 | &config); | ||
| 169 | if (IS_ERR(ldo->regulator)) { | 171 | if (IS_ERR(ldo->regulator)) { |
| 170 | ret = PTR_ERR(ldo->regulator); | 172 | ret = PTR_ERR(ldo->regulator); |
| 171 | dev_err(wm8994->dev, "Failed to register LDO%d: %d\n", | 173 | dev_err(wm8994->dev, "Failed to register LDO%d: %d\n", |
| @@ -181,18 +183,8 @@ err: | |||
| 181 | return ret; | 183 | return ret; |
| 182 | } | 184 | } |
| 183 | 185 | ||
| 184 | static int wm8994_ldo_remove(struct platform_device *pdev) | ||
| 185 | { | ||
| 186 | struct wm8994_ldo *ldo = platform_get_drvdata(pdev); | ||
| 187 | |||
| 188 | regulator_unregister(ldo->regulator); | ||
| 189 | |||
| 190 | return 0; | ||
| 191 | } | ||
| 192 | |||
| 193 | static struct platform_driver wm8994_ldo_driver = { | 186 | static struct platform_driver wm8994_ldo_driver = { |
| 194 | .probe = wm8994_ldo_probe, | 187 | .probe = wm8994_ldo_probe, |
| 195 | .remove = wm8994_ldo_remove, | ||
| 196 | .driver = { | 188 | .driver = { |
| 197 | .name = "wm8994-ldo", | 189 | .name = "wm8994-ldo", |
| 198 | .owner = THIS_MODULE, | 190 | .owner = THIS_MODULE, |
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 67e13aa5a478..8474c7f88745 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h | |||
| @@ -334,7 +334,12 @@ struct regulator_dev { | |||
| 334 | struct regulator_dev * | 334 | struct regulator_dev * |
| 335 | regulator_register(const struct regulator_desc *regulator_desc, | 335 | regulator_register(const struct regulator_desc *regulator_desc, |
| 336 | const struct regulator_config *config); | 336 | const struct regulator_config *config); |
| 337 | struct regulator_dev * | ||
| 338 | devm_regulator_register(struct device *dev, | ||
| 339 | const struct regulator_desc *regulator_desc, | ||
| 340 | const struct regulator_config *config); | ||
| 337 | void regulator_unregister(struct regulator_dev *rdev); | 341 | void regulator_unregister(struct regulator_dev *rdev); |
| 342 | void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev); | ||
| 338 | 343 | ||
| 339 | int regulator_notifier_call_chain(struct regulator_dev *rdev, | 344 | int regulator_notifier_call_chain(struct regulator_dev *rdev, |
| 340 | unsigned long event, void *data); | 345 | unsigned long event, void *data); |
