Linux Kernels

mfd: tc3589x: Use devm_*() functions

This change “mfd: tc3589x: Use devm_*() functions” (commit 1383e00) in Linux kernel is authored by Jingoo Han <jg1.han [at] samsung.com> on Wed Feb 20 18:31:52 2013 +0900.

Description of "mfd: tc3589x: Use devm_*() functions"

The change “mfd: tc3589x: Use devm_*() functions” introduces changes as follows.

mfd: tc3589x: Use devm_*() functions

Use devm_*() functions to make cleanup paths more simple.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

Linux kernel releases containing commit 1383e00

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "mfd: tc3589x: Use devm_*() functions"

There are 21 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/mfd/tc3589x.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
 
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
index ecc092c7f745..4cb92bb2aea2 100644
--- a/drivers/mfd/tc3589x.c
+++ b/drivers/mfd/tc3589x.c
@@ -350,7 +350,8 @@ static int tc3589x_probe(struct i2c_client *i2c,
 				     | I2C_FUNC_SMBUS_I2C_BLOCK))
 		return -EIO;
 
-	tc3589x = kzalloc(sizeof(struct tc3589x), GFP_KERNEL);
+	tc3589x = devm_kzalloc(&i2c->dev, sizeof(struct tc3589x),
+				GFP_KERNEL);
 	if (!tc3589x)
 		return -ENOMEM;
 
@@ -366,33 +367,27 @@ static int tc3589x_probe(struct i2c_client *i2c,
 
 	ret = tc3589x_chip_init(tc3589x);
 	if (ret)
-		goto out_free;
+		return ret;
 
 	ret = tc3589x_irq_init(tc3589x, np);
 	if (ret)
-		goto out_free;
+		return ret;
 
 	ret = request_threaded_irq(tc3589x->i2c->irq, NULL, tc3589x_irq,
 				   IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
 				   "tc3589x", tc3589x);
 	if (ret) {
 		dev_err(tc3589x->dev, "failed to request IRQ: %d\n", ret);
-		goto out_free;
+		return ret;
 	}
 
 	ret = tc3589x_device_init(tc3589x);
 	if (ret) {
 		dev_err(tc3589x->dev, "failed to add child devices\n");
-		goto out_freeirq;
+		return ret;
 	}
 
 	return 0;
-
-out_freeirq:
-	free_irq(tc3589x->i2c->irq, tc3589x);
-out_free:
-	kfree(tc3589x);
-	return ret;
 }
 
 static int tc3589x_remove(struct i2c_client *client)
@@ -401,10 +396,6 @@ static int tc3589x_remove(struct i2c_client *client)
 
 	mfd_remove_devices(tc3589x->dev);
 
-	free_irq(tc3589x->i2c->irq, tc3589x);
-
-	kfree(tc3589x);
-
 	return 0;
 }
 

The commit for this change in Linux stable tree is 1383e00 (patch).

Last modified: 2020/01/11 09:34