All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [media] saa6752hs: Convert to devm_kzalloc()
@ 2014-08-10  9:41 Axel Lin
  2014-08-10 10:51 ` Prabhakar Lad
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2014-08-10  9:41 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Hans Verkuil, Laurent Pinchart, Lad, Prabhakar, linux-media

Using the managed function the kfree() calls can be removed from the
probe error path and the remove handler.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/media/i2c/saa6752hs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/saa6752hs.c b/drivers/media/i2c/saa6752hs.c
index 04e9e55..4024ea6 100644
--- a/drivers/media/i2c/saa6752hs.c
+++ b/drivers/media/i2c/saa6752hs.c
@@ -660,7 +660,7 @@ static const struct v4l2_subdev_ops saa6752hs_ops = {
 static int saa6752hs_probe(struct i2c_client *client,
 		const struct i2c_device_id *id)
 {
-	struct saa6752hs_state *h = kzalloc(sizeof(*h), GFP_KERNEL);
+	struct saa6752hs_state *h;
 	struct v4l2_subdev *sd;
 	struct v4l2_ctrl_handler *hdl;
 	u8 addr = 0x13;
@@ -668,6 +668,8 @@ static int saa6752hs_probe(struct i2c_client *client,
 
 	v4l_info(client, "chip found @ 0x%x (%s)\n",
 			client->addr << 1, client->adapter->name);
+
+	h = devm_kzalloc(&client->dev, sizeof(*h), GFP_KERNEL);
 	if (h == NULL)
 		return -ENOMEM;
 	sd = &h->sd;
@@ -752,7 +754,6 @@ static int saa6752hs_probe(struct i2c_client *client,
 		int err = hdl->error;
 
 		v4l2_ctrl_handler_free(hdl);
-		kfree(h);
 		return err;
 	}
 	v4l2_ctrl_cluster(3, &h->video_bitrate_mode);
@@ -767,7 +768,6 @@ static int saa6752hs_remove(struct i2c_client *client)
 
 	v4l2_device_unregister_subdev(sd);
 	v4l2_ctrl_handler_free(&to_state(sd)->hdl);
-	kfree(to_state(sd));
 	return 0;
 }
 
-- 
1.9.1




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

* Re: [PATCH] [media] saa6752hs: Convert to devm_kzalloc()
  2014-08-10  9:41 [PATCH] [media] saa6752hs: Convert to devm_kzalloc() Axel Lin
@ 2014-08-10 10:51 ` Prabhakar Lad
  0 siblings, 0 replies; 2+ messages in thread
From: Prabhakar Lad @ 2014-08-10 10:51 UTC (permalink / raw)
  To: Axel Lin
  Cc: Mauro Carvalho Chehab, Hans Verkuil, Laurent Pinchart, linux-media

On Sun, Aug 10, 2014 at 10:41 AM, Axel Lin <axel.lin@ingics.com> wrote:
> Using the managed function the kfree() calls can be removed from the
> probe error path and the remove handler.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Thanks,
--Prabhakar Lad

> ---
>  drivers/media/i2c/saa6752hs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/i2c/saa6752hs.c b/drivers/media/i2c/saa6752hs.c
> index 04e9e55..4024ea6 100644
> --- a/drivers/media/i2c/saa6752hs.c
> +++ b/drivers/media/i2c/saa6752hs.c
> @@ -660,7 +660,7 @@ static const struct v4l2_subdev_ops saa6752hs_ops = {
>  static int saa6752hs_probe(struct i2c_client *client,
>                 const struct i2c_device_id *id)
>  {
> -       struct saa6752hs_state *h = kzalloc(sizeof(*h), GFP_KERNEL);
> +       struct saa6752hs_state *h;
>         struct v4l2_subdev *sd;
>         struct v4l2_ctrl_handler *hdl;
>         u8 addr = 0x13;
> @@ -668,6 +668,8 @@ static int saa6752hs_probe(struct i2c_client *client,
>
>         v4l_info(client, "chip found @ 0x%x (%s)\n",
>                         client->addr << 1, client->adapter->name);
> +
> +       h = devm_kzalloc(&client->dev, sizeof(*h), GFP_KERNEL);
>         if (h == NULL)
>                 return -ENOMEM;
>         sd = &h->sd;
> @@ -752,7 +754,6 @@ static int saa6752hs_probe(struct i2c_client *client,
>                 int err = hdl->error;
>
>                 v4l2_ctrl_handler_free(hdl);
> -               kfree(h);
>                 return err;
>         }
>         v4l2_ctrl_cluster(3, &h->video_bitrate_mode);
> @@ -767,7 +768,6 @@ static int saa6752hs_remove(struct i2c_client *client)
>
>         v4l2_device_unregister_subdev(sd);
>         v4l2_ctrl_handler_free(&to_state(sd)->hdl);
> -       kfree(to_state(sd));
>         return 0;
>  }
>
> --
> 1.9.1
>
>
>

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

end of thread, other threads:[~2014-08-10 10:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-10  9:41 [PATCH] [media] saa6752hs: Convert to devm_kzalloc() Axel Lin
2014-08-10 10:51 ` Prabhakar Lad

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.