From: Lee Jones Date: Thu, 23 May 2013 15:25:02 +0000 (+0100) Subject: mfd: tps65912: Convert to managed resources for allocating memory X-Git-Tag: firefly_0821_release~176^2~5740^2~55 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b3fff1770a33abb1905eae2baa8dffd48e5913ae;p=firefly-linux-kernel-4.4.55.git mfd: tps65912: Convert to managed resources for allocating memory Saves on code and simplifies the driver, as these resources are now tracked and freed automatically when the driver is realised. Signed-off-by: Lee Jones Signed-off-by: Samuel Ortiz --- diff --git a/drivers/mfd/tps65912-core.c b/drivers/mfd/tps65912-core.c index aeb8e40ab424..479886a4cf80 100644 --- a/drivers/mfd/tps65912-core.c +++ b/drivers/mfd/tps65912-core.c @@ -162,7 +162,6 @@ int tps65912_device_init(struct tps65912 *tps65912) err: kfree(init_data); mfd_remove_devices(tps65912->dev); - kfree(tps65912); return ret; } @@ -170,7 +169,6 @@ void tps65912_device_exit(struct tps65912 *tps65912) { mfd_remove_devices(tps65912->dev); tps65912_irq_exit(tps65912); - kfree(tps65912); } MODULE_AUTHOR("Margarita Olaya "); diff --git a/drivers/mfd/tps65912-i2c.c b/drivers/mfd/tps65912-i2c.c index c041f2c3d2bd..6a6343ee95fe 100644 --- a/drivers/mfd/tps65912-i2c.c +++ b/drivers/mfd/tps65912-i2c.c @@ -77,7 +77,8 @@ static int tps65912_i2c_probe(struct i2c_client *i2c, { struct tps65912 *tps65912; - tps65912 = kzalloc(sizeof(struct tps65912), GFP_KERNEL); + tps65912 = devm_kzalloc(&i2c->dev, + sizeof(struct tps65912), GFP_KERNEL); if (tps65912 == NULL) return -ENOMEM; diff --git a/drivers/mfd/tps65912-spi.c b/drivers/mfd/tps65912-spi.c index b45f460d299f..69a5178bf152 100644 --- a/drivers/mfd/tps65912-spi.c +++ b/drivers/mfd/tps65912-spi.c @@ -85,7 +85,8 @@ static int tps65912_spi_probe(struct spi_device *spi) { struct tps65912 *tps65912; - tps65912 = kzalloc(sizeof(struct tps65912), GFP_KERNEL); + tps65912 = devm_kzalloc(&spi->dev, + sizeof(struct tps65912), GFP_KERNEL); if (tps65912 == NULL) return -ENOMEM;