linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] [media] s5k6aa: Use devm_kzalloc function
@ 2012-07-26  6:23 Sachin Kamat
  2012-07-26  6:23 ` [PATCH 2/2] [media] s5k6aa: Add missing static storage class specifier Sachin Kamat
  2012-07-31  8:13 ` [PATCH 1/2] [media] s5k6aa: Use devm_kzalloc function Sylwester Nawrocki
  0 siblings, 2 replies; 3+ messages in thread
From: Sachin Kamat @ 2012-07-26  6:23 UTC (permalink / raw)
  To: linux-media; +Cc: mchehab, s.nawrocki, sachin.kamat, patches

devm_kzalloc() eliminates the need to free explicitly thereby
making the code a bit simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/media/video/s5k6aa.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/media/video/s5k6aa.c b/drivers/media/video/s5k6aa.c
index 6625e46..0c3bc58 100644
--- a/drivers/media/video/s5k6aa.c
+++ b/drivers/media/video/s5k6aa.c
@@ -1568,7 +1568,7 @@ static int s5k6aa_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
-	s5k6aa = kzalloc(sizeof(*s5k6aa), GFP_KERNEL);
+	s5k6aa = devm_kzalloc(&client->dev, sizeof(*s5k6aa), GFP_KERNEL);
 	if (!s5k6aa)
 		return -ENOMEM;
 
@@ -1592,7 +1592,7 @@ static int s5k6aa_probe(struct i2c_client *client,
 	sd->entity.type = MEDIA_ENT_T_V4L2_SUBDEV_SENSOR;
 	ret = media_entity_init(&sd->entity, 1, &s5k6aa->pad, 0);
 	if (ret)
-		goto out_err1;
+		return ret;
 
 	ret = s5k6aa_configure_gpios(s5k6aa, pdata);
 	if (ret)
@@ -1627,8 +1627,6 @@ out_err3:
 	s5k6aa_free_gpios(s5k6aa);
 out_err2:
 	media_entity_cleanup(&s5k6aa->sd.entity);
-out_err1:
-	kfree(s5k6aa);
 	return ret;
 }
 
@@ -1642,7 +1640,6 @@ static int s5k6aa_remove(struct i2c_client *client)
 	media_entity_cleanup(&sd->entity);
 	regulator_bulk_free(S5K6AA_NUM_SUPPLIES, s5k6aa->supplies);
 	s5k6aa_free_gpios(s5k6aa);
-	kfree(s5k6aa);
 
 	return 0;
 }
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-31  8:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-26  6:23 [PATCH 1/2] [media] s5k6aa: Use devm_kzalloc function Sachin Kamat
2012-07-26  6:23 ` [PATCH 2/2] [media] s5k6aa: Add missing static storage class specifier Sachin Kamat
2012-07-31  8:13 ` [PATCH 1/2] [media] s5k6aa: Use devm_kzalloc function Sylwester Nawrocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).