mfd: tps80031: use devm managed resources
Laxman Dewangan [Thu, 19 Jul 2012 08:35:52 +0000 (13:35 +0530)]
Allocate memory for device state using devm_kzalloc()
to simplify accounting and letting the kernel do the
garbage-collection.

Change-Id: I8dcde205556c43f4fdfe5e335507df206f204177
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/117331
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
GVS: Gerrit_Virtual_Submit

drivers/mfd/tps80031.c

index 047c380..5b287eb 100644 (file)
@@ -1209,7 +1209,6 @@ static int __devexit tps80031_i2c_remove(struct i2c_client *client)
                mutex_destroy(&tps->lock);
        }
 
-       kfree(tps80031);
        return 0;
 }
 
@@ -1246,9 +1245,11 @@ static int __devinit tps80031_i2c_probe(struct i2c_client *client,
        dev_info(&client->dev, "Jtag version 0x%02x and Eeprom version 0x%02x\n",
                                                jtag_ver, ep_ver);
 
-       tps80031 = kzalloc(sizeof(struct tps80031), GFP_KERNEL);
-       if (tps80031 == NULL)
+       tps80031 = devm_kzalloc(&client->dev, sizeof(*tps80031), GFP_KERNEL);
+       if (!tps80031) {
+               dev_err(&client->dev, "Memory alloc for tps80031 failed\n");
                return -ENOMEM;
+       }
 
        tps80031->es_version = jtag_ver;
        tps80031->dev = &client->dev;