Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regulator: 88pm800: Update driver to use devm_regulator_register fn

This patch replaces standard regulator_register with
devm_regulator_register() fn, as using devm_regulator_register() fn
simplifies the driver return/exit path.

As part of this update, patch also cleanups up all unnecessary changes
which is result of this patch -

- Remove _remove() fn, as devm_ variant takes care of it.
- Remove pm800_regulators.regulators[] field, as it was only
needed during cleanup, so we no longer need this.
This also saved some amount of memory.

Signed-off-by: Vaibhav Hiremath <vaibhav.hiremath@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Vaibhav Hiremath and committed by
Mark Brown
a07d94a5 4d45c70b

+6 -21
+6 -21
drivers/regulator/88pm800.c
··· 78 78 }; 79 79 80 80 struct pm800_regulators { 81 - struct regulator_dev *regulators[PM800_ID_RG_MAX]; 82 81 struct pm80x_chip *chip; 83 82 struct regmap *map; 84 83 }; ··· 317 318 platform_set_drvdata(pdev, pm800_data); 318 319 319 320 for (i = 0; i < PM800_ID_RG_MAX; i++) { 321 + struct regulator_dev *regulator; 322 + 320 323 if (!pdata || pdata->num_regulators == 0) 321 324 init_data = pm800_regulator_matches[i].init_data; 322 325 else ··· 332 331 config.regmap = pm800_data->map; 333 332 config.of_node = pm800_regulator_matches[i].of_node; 334 333 335 - pm800_data->regulators[i] = 336 - regulator_register(&info->desc, &config); 337 - if (IS_ERR(pm800_data->regulators[i])) { 338 - ret = PTR_ERR(pm800_data->regulators[i]); 334 + regulator = devm_regulator_register(&pdev->dev, 335 + &info->desc, &config); 336 + if (IS_ERR(regulator)) { 337 + ret = PTR_ERR(regulator); 339 338 dev_err(&pdev->dev, "Failed to register %s\n", 340 339 info->desc.name); 341 - 342 - while (--i >= 0) 343 - regulator_unregister(pm800_data->regulators[i]); 344 - 345 340 return ret; 346 341 } 347 342 } 348 - 349 - return 0; 350 - } 351 - 352 - static int pm800_regulator_remove(struct platform_device *pdev) 353 - { 354 - struct pm800_regulators *pm800_data = platform_get_drvdata(pdev); 355 - int i; 356 - 357 - for (i = 0; i < PM800_ID_RG_MAX; i++) 358 - regulator_unregister(pm800_data->regulators[i]); 359 343 360 344 return 0; 361 345 } ··· 350 364 .name = "88pm80x-regulator", 351 365 }, 352 366 .probe = pm800_regulator_probe, 353 - .remove = pm800_regulator_remove, 354 367 }; 355 368 356 369 module_platform_driver(pm800_regulator_driver);