[PATCH 1/6] i2c: cpm: use devm_ functions

DORMANTno replies

From: Julia Lawall <hidden>
Date: 2012-08-25 17:41:48
Also in: kernel-janitors, linux-i2c, lkml
Subsystem: freescale i2c cpm driver, i2c subsystem, i2c subsystem host drivers, the rest · Maintainers: Jochen Friedrich, Andi Shyti, Linus Torvalds

From: Julia Lawall <redacted>

The various devm_ functions allocate memory that is released when a driver
detaches.  This patch uses these functions for data that is allocated in
the probe function of a platform device and is only freed in the remove
function.

Signed-off-by: Julia Lawall <redacted>

---
Not compiled.

 drivers/i2c/busses/i2c-cpm.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
index c1e1096..ec97415 100644
--- a/drivers/i2c/busses/i2c-cpm.c
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -640,7 +640,7 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev)
 	struct cpm_i2c *cpm;
 	const u32 *data;
 
-	cpm = kzalloc(sizeof(struct cpm_i2c), GFP_KERNEL);
+	cpm = devm_kzalloc(&ofdev->dev, sizeof(struct cpm_i2c), GFP_KERNEL);
 	if (!cpm)
 		return -ENOMEM;
 
@@ -683,7 +683,6 @@ out_shut:
 	cpm_i2c_shutdown(cpm);
 out_free:
 	dev_set_drvdata(&ofdev->dev, NULL);
-	kfree(cpm);
 
 	return result;
 }
@@ -697,7 +696,6 @@ static int __devexit cpm_i2c_remove(struct platform_device *ofdev)
 	cpm_i2c_shutdown(cpm);
 
 	dev_set_drvdata(&ofdev->dev, NULL);
-	kfree(cpm);
 
 	return 0;
 }
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help