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

[Fixups from rebase onto v3.12 code -- broonie]
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/regulator/max8660.c

index 144bcacd734dbe39e44801e411990e15a45d18eb..8d94d3d7f97f22336fb973d5659ed50b4a3e6a97 100644 (file)
@@ -439,7 +439,7 @@ static int max8660_probe(struct i2c_client *client,
        for (i = 0; i < pdata->num_subdevs; i++) {
 
                if (!pdata->subdevs[i].platform_data)
-                       goto err_out;
+                       return ret;
 
                boot_on = pdata->subdevs[i].platform_data->constraints.boot_on;
 
@@ -465,7 +465,7 @@ static int max8660_probe(struct i2c_client *client,
                case MAX8660_V7:
                        if (type == MAX8661) {
                                dev_err(dev, "Regulator not on this chip!\n");
-                               goto err_out;
+                               return -EINVAL;
                        }
 
                        if (boot_on)
@@ -475,7 +475,7 @@ static int max8660_probe(struct i2c_client *client,
                default:
                        dev_err(dev, "invalid regulator %s\n",
                                 pdata->subdevs[i].name);
-                       goto err_out;
+                       return ret;
                }
        }
 
@@ -489,33 +489,18 @@ static int max8660_probe(struct i2c_client *client,
                config.of_node = of_node[i];
                config.driver_data = max8660;
 
-               rdev[i] = regulator_register(&max8660_reg[id], &config);
+               rdev[i] = devm_regulator_register(&client->dev,
+                                                 &max8660_reg[id], &config);
                if (IS_ERR(rdev[i])) {
                        ret = PTR_ERR(rdev[i]);
-                       dev_err(dev, "failed to register %s\n",
+                       dev_err(&client->dev, "failed to register %s\n",
                                max8660_reg[id].name);
-                       goto err_unregister;
+                       return PTR_ERR(rdev[i]);
                }
        }
 
        i2c_set_clientdata(client, max8660);
        return 0;
-
-err_unregister:
-       while (--i >= 0)
-               regulator_unregister(rdev[i]);
-err_out:
-       return ret;
-}
-
-static int max8660_remove(struct i2c_client *client)
-{
-       struct max8660 *max8660 = i2c_get_clientdata(client);
-       int i;
-
-       for (i = 0; i < MAX8660_V_END; i++)
-               regulator_unregister(max8660->rdev[i]);
-       return 0;
 }
 
 static const struct i2c_device_id max8660_id[] = {
@@ -527,7 +512,6 @@ MODULE_DEVICE_TABLE(i2c, max8660_id);
 
 static struct i2c_driver max8660_driver = {
        .probe = max8660_probe,
-       .remove = max8660_remove,
        .driver         = {
                .name   = "max8660",
                .owner  = THIS_MODULE,