]> git.karo-electronics.de Git - linux-beck.git/commitdiff
regulator: max8998: Use devm_regulator_register
authorSachin Kamat <sachin.kamat@linaro.org>
Wed, 4 Sep 2013 05:38:02 +0000 (11:08 +0530)
committerMark Brown <broonie@linaro.org>
Mon, 16 Sep 2013 23:28:41 +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/max8998.c

index a4c53b2d1aaf5210482976fd97504485e90fd247..ae3f0656feb00c406ca438642c051a6453ab9171 100644 (file)
@@ -790,16 +790,14 @@ static int max8998_pmic_probe(struct platform_device *pdev)
                        dev_err(&pdev->dev,
                                "MAX8998 SET1 GPIO defined as 0 !\n");
                        WARN_ON(!pdata->buck1_set1);
-                       ret = -EIO;
-                       goto err_out;
+                       return -EIO;
                }
                /* Check if SET2 is not equal to 0 */
                if (!pdata->buck1_set2) {
                        dev_err(&pdev->dev,
                                "MAX8998 SET2 GPIO defined as 0 !\n");
                        WARN_ON(!pdata->buck1_set2);
-                       ret = -EIO;
-                       goto err_out;
+                       return -EIO;
                }
 
                gpio_request(pdata->buck1_set1, "MAX8998 BUCK1_SET1");
@@ -823,7 +821,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
                        ret = max8998_write_reg(i2c,
                                        MAX8998_REG_BUCK1_VOLTAGE1 + v, i);
                        if (ret)
-                               goto err_out;
+                               return ret;
                }
        }
 
@@ -833,8 +831,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
                        dev_err(&pdev->dev,
                                "MAX8998 SET3 GPIO defined as 0 !\n");
                        WARN_ON(!pdata->buck2_set3);
-                       ret = -EIO;
-                       goto err_out;
+                       return -EIO;
                }
                gpio_request(pdata->buck2_set3, "MAX8998 BUCK2_SET3");
                gpio_direction_output(pdata->buck2_set3,
@@ -852,7 +849,7 @@ static int max8998_pmic_probe(struct platform_device *pdev)
                        ret = max8998_write_reg(i2c,
                                        MAX8998_REG_BUCK2_VOLTAGE1 + v, i);
                        if (ret)
-                               goto err_out;
+                               return ret;
                }
        }
 
@@ -875,33 +872,18 @@ static int max8998_pmic_probe(struct platform_device *pdev)
                config.init_data = pdata->regulators[i].initdata;
                config.driver_data = max8998;
 
-               rdev[i] = regulator_register(&regulators[index], &config);
+               rdev[i] = devm_regulator_register(&pdev->dev,
+                                                 &regulators[index], &config);
                if (IS_ERR(rdev[i])) {
                        ret = PTR_ERR(rdev[i]);
                        dev_err(max8998->dev, "regulator %s init failed (%d)\n",
                                                regulators[index].name, ret);
                        rdev[i] = NULL;
-                       goto err;
+                       return ret;
                }
        }
 
 
-       return 0;
-err:
-       while (--i >= 0)
-               regulator_unregister(rdev[i]);
-err_out:
-       return ret;
-}
-
-static int max8998_pmic_remove(struct platform_device *pdev)
-{
-       struct max8998_data *max8998 = platform_get_drvdata(pdev);
-       struct regulator_dev **rdev = max8998->rdev;
-       int i;
-
-       for (i = 0; i < max8998->num_regulators; i++)
-               regulator_unregister(rdev[i]);
        return 0;
 }
 
@@ -918,7 +900,6 @@ static struct platform_driver max8998_pmic_driver = {
                .owner = THIS_MODULE,
        },
        .probe = max8998_pmic_probe,
-       .remove = max8998_pmic_remove,
        .id_table = max8998_pmic_id,
 };