]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
regulator: max77686: Use devm_regulator_register
authorSachin Kamat <sachin.kamat@linaro.org>
Wed, 4 Sep 2013 05:37:54 +0000 (11:07 +0530)
committerMark Brown <broonie@linaro.org>
Mon, 16 Sep 2013 23:28:40 +0000 (00:28 +0100)
devm_* simplifies the code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/regulator/max77686.c

index f563057e56904c868a5344a43e80e41e97ced60d..de5b30ea823c93b0d71305396caf6be96c5f9eb4 100644 (file)
@@ -478,31 +478,16 @@ static int max77686_pmic_probe(struct platform_device *pdev)
                config.of_node = pdata->regulators[i].of_node;
 
                max77686->opmode[i] = regulators[i].enable_mask;
-               max77686->rdev[i] = regulator_register(&regulators[i], &config);
+               max77686->rdev[i] = devm_regulator_register(&pdev->dev,
+                                               &regulators[i], &config);
                if (IS_ERR(max77686->rdev[i])) {
-                       ret = PTR_ERR(max77686->rdev[i]);
                        dev_err(&pdev->dev,
                                "regulator init failed for %d\n", i);
                        max77686->rdev[i] = NULL;
-                       goto err;
+                       return PTR_ERR(max77686->rdev[i]);
                }
        }
 
-       return 0;
-err:
-       while (--i >= 0)
-               regulator_unregister(max77686->rdev[i]);
-       return ret;
-}
-
-static int max77686_pmic_remove(struct platform_device *pdev)
-{
-       struct max77686_data *max77686 = platform_get_drvdata(pdev);
-       int i;
-
-       for (i = 0; i < MAX77686_REGULATORS; i++)
-               regulator_unregister(max77686->rdev[i]);
-
        return 0;
 }
 
@@ -518,7 +503,6 @@ static struct platform_driver max77686_pmic_driver = {
                .owner = THIS_MODULE,
        },
        .probe = max77686_pmic_probe,
-       .remove = max77686_pmic_remove,
        .id_table = max77686_pmic_id,
 };