devm_kzalloc is a device managed function and makes code a bit
smaller and cleaner.

Signed-off-by: Sachin Kamat <sachin.ka...@linaro.org>
---
This patch is based on Mauro's re-organized tree
(media_tree staging/for_v3.7) and is compile tested.
---
 drivers/media/i2c/smiapp/smiapp-core.c |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c 
b/drivers/media/i2c/smiapp/smiapp-core.c
index 1cf914d..7d4280e 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2801,12 +2801,11 @@ static int smiapp_probe(struct i2c_client *client,
                        const struct i2c_device_id *devid)
 {
        struct smiapp_sensor *sensor;
-       int rval;
 
        if (client->dev.platform_data == NULL)
                return -ENODEV;
 
-       sensor = kzalloc(sizeof(*sensor), GFP_KERNEL);
+       sensor = devm_kzalloc(&client->dev, sizeof(*sensor), GFP_KERNEL);
        if (sensor == NULL)
                return -ENOMEM;
 
@@ -2821,12 +2820,8 @@ static int smiapp_probe(struct i2c_client *client,
        sensor->src->sensor = sensor;
 
        sensor->src->pads[0].flags = MEDIA_PAD_FL_SOURCE;
-       rval = media_entity_init(&sensor->src->sd.entity, 2,
+       return media_entity_init(&sensor->src->sd.entity, 2,
                                 sensor->src->pads, 0);
-       if (rval < 0)
-               kfree(sensor);
-
-       return rval;
 }
 
 static int __exit smiapp_remove(struct i2c_client *client)
@@ -2862,8 +2857,6 @@ static int __exit smiapp_remove(struct i2c_client *client)
        if (sensor->vana)
                regulator_put(sensor->vana);
 
-       kfree(sensor);
-
        return 0;
 }
 
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to