regulator: tps65023: Use devm_* APIs
authorAxel Lin <axel.lin@gmail.com>
Sat, 7 Apr 2012 15:31:44 +0000 (23:31 +0800)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 10 Apr 2012 10:04:27 +0000 (11:04 +0100)
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/tps65023-regulator.c

index 7755afeecede138301aa83f4f879f8bf544771a3..2db71497b741dcac5ee30f663bc5a9f963a47fab 100644 (file)
@@ -394,16 +394,16 @@ static int __devinit tps_65023_probe(struct i2c_client *client,
        if (!init_data)
                return -EIO;
 
-       tps = kzalloc(sizeof(*tps), GFP_KERNEL);
+       tps = devm_kzalloc(&client->dev, sizeof(*tps), GFP_KERNEL);
        if (!tps)
                return -ENOMEM;
 
-       tps->regmap = regmap_init_i2c(client, &tps65023_regmap_config);
+       tps->regmap = devm_regmap_init_i2c(client, &tps65023_regmap_config);
        if (IS_ERR(tps->regmap)) {
                error = PTR_ERR(tps->regmap);
                dev_err(&client->dev, "Failed to allocate register map: %d\n",
                        error);
-               goto fail_alloc;
+               return error;
        }
 
        /* common for all regulators */
@@ -449,10 +449,6 @@ static int __devinit tps_65023_probe(struct i2c_client *client,
  fail:
        while (--i >= 0)
                regulator_unregister(tps->rdev[i]);
-
-       regmap_exit(tps->regmap);
- fail_alloc:
-       kfree(tps);
        return error;
 }
 
@@ -463,10 +459,6 @@ static int __devexit tps_65023_remove(struct i2c_client *client)
 
        for (i = 0; i < TPS65023_NUM_REGULATOR; i++)
                regulator_unregister(tps->rdev[i]);
-
-       regmap_exit(tps->regmap);
-       kfree(tps);
-
        return 0;
 }