2012-10-04 09:30:21

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH v2] media: davinci: vpif: Add return code check at vb2_queue_init()

From: Lad, Prabhakar <[email protected]>

from commit with id 896f38f582730a19eb49677105b4fe4c0270b82e
it's mandatory to check the return code of vb2_queue_init().

Signed-off-by: Lad, Prabhakar <[email protected]>
Signed-off-by: Manjunath Hadli <[email protected]>
Cc: Hans Verkuil <[email protected]>
---
Changes for v2:
1: Added vb2_dma_contig_cleanup_ctx() on failure of
vb2_queue_init() to avoid memory leak, pointed by Hans.

drivers/media/platform/davinci/vpif_capture.c | 9 +++++++--
drivers/media/platform/davinci/vpif_display.c | 9 +++++++--
2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index 83b80ba..cabd5a2 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -976,6 +976,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
struct common_obj *common;
u8 index = 0;
struct vb2_queue *q;
+ int ret;

vpif_dbg(2, debug, "vpif_reqbufs\n");

@@ -1015,8 +1016,12 @@ static int vpif_reqbufs(struct file *file, void *priv,
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct vpif_cap_buffer);

- vb2_queue_init(q);
-
+ ret = vb2_queue_init(q);
+ if (ret) {
+ vpif_err("vpif_capture: vb2_queue_init() failed\n");
+ vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
+ return ret;
+ }
/* Set io allowed member of file handle to TRUE */
fh->io_allowed[index] = 1;
/* Increment io usrs member of channel object to 1 */
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index ae8329d..7f20ca5 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -936,6 +936,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
enum v4l2_field field;
struct vb2_queue *q;
u8 index = 0;
+ int ret;

/* This file handle has not initialized the channel,
It is not allowed to do settings */
@@ -981,8 +982,12 @@ static int vpif_reqbufs(struct file *file, void *priv,
q->mem_ops = &vb2_dma_contig_memops;
q->buf_struct_size = sizeof(struct vpif_disp_buffer);

- vb2_queue_init(q);
-
+ ret = vb2_queue_init(q);
+ if (ret) {
+ vpif_err("vpif_display: vb2_queue_init() failed\n");
+ vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
+ return ret;
+ }
/* Set io allowed member of file handle to TRUE */
fh->io_allowed[index] = 1;
/* Increment io usrs member of channel object to 1 */
--
1.7.4.1


2012-10-04 09:31:03

by Lad, Prabhakar

[permalink] [raw]
Subject: [PATCH v3] media: davinci: vpif: set device capabilities

From: Lad, Prabhakar <[email protected]>

set device_caps and also change the driver and
bus_info to proper values as per standard.

Signed-off-by: Lad, Prabhakar <[email protected]>
Signed-off-by: Manjunath Hadli <[email protected]>
Cc: Hans Verkuil <[email protected]>
---
Changes for v3:
1: Removed READWRITE flag for device_caps pointed by Hans.

Changes for v2:
1: Change the bus_info and driver to proper values,
pointed by Hans.

drivers/media/platform/davinci/vpif_capture.c | 8 +++++---
drivers/media/platform/davinci/vpif_display.c | 8 +++++---
2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
index cabd5a2..fcabc02 100644
--- a/drivers/media/platform/davinci/vpif_capture.c
+++ b/drivers/media/platform/davinci/vpif_capture.c
@@ -1635,9 +1635,11 @@ static int vpif_querycap(struct file *file, void *priv,
{
struct vpif_capture_config *config = vpif_dev->platform_data;

- cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
- strlcpy(cap->driver, "vpif capture", sizeof(cap->driver));
- strlcpy(cap->bus_info, "VPIF Platform", sizeof(cap->bus_info));
+ cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
+ cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
+ snprintf(cap->driver, sizeof(cap->driver), "%s", dev_name(vpif_dev));
+ snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
+ dev_name(vpif_dev));
strlcpy(cap->card, config->card_name, sizeof(cap->card));

return 0;
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
index 7f20ca5..b716fbd 100644
--- a/drivers/media/platform/davinci/vpif_display.c
+++ b/drivers/media/platform/davinci/vpif_display.c
@@ -827,9 +827,11 @@ static int vpif_querycap(struct file *file, void *priv,
{
struct vpif_display_config *config = vpif_dev->platform_data;

- cap->capabilities = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
- strlcpy(cap->driver, "vpif display", sizeof(cap->driver));
- strlcpy(cap->bus_info, "Platform", sizeof(cap->bus_info));
+ cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
+ cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
+ snprintf(cap->driver, sizeof(cap->driver), "%s", dev_name(vpif_dev));
+ snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
+ dev_name(vpif_dev));
strlcpy(cap->card, config->card_name, sizeof(cap->card));

return 0;
--
1.7.4.1

2012-10-04 09:37:37

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v2] media: davinci: vpif: Add return code check at vb2_queue_init()

On Thu 4 October 2012 11:29:57 Prabhakar wrote:
> From: Lad, Prabhakar <[email protected]>
>
> from commit with id 896f38f582730a19eb49677105b4fe4c0270b82e
> it's mandatory to check the return code of vb2_queue_init().
>
> Signed-off-by: Lad, Prabhakar <[email protected]>
> Signed-off-by: Manjunath Hadli <[email protected]>
> Cc: Hans Verkuil <[email protected]>

Acked-by: Hans Verkuil <[email protected]>

Regards,

Hans

> ---
> Changes for v2:
> 1: Added vb2_dma_contig_cleanup_ctx() on failure of
> vb2_queue_init() to avoid memory leak, pointed by Hans.
>
> drivers/media/platform/davinci/vpif_capture.c | 9 +++++++--
> drivers/media/platform/davinci/vpif_display.c | 9 +++++++--
> 2 files changed, 14 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
> index 83b80ba..cabd5a2 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -976,6 +976,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
> struct common_obj *common;
> u8 index = 0;
> struct vb2_queue *q;
> + int ret;
>
> vpif_dbg(2, debug, "vpif_reqbufs\n");
>
> @@ -1015,8 +1016,12 @@ static int vpif_reqbufs(struct file *file, void *priv,
> q->mem_ops = &vb2_dma_contig_memops;
> q->buf_struct_size = sizeof(struct vpif_cap_buffer);
>
> - vb2_queue_init(q);
> -
> + ret = vb2_queue_init(q);
> + if (ret) {
> + vpif_err("vpif_capture: vb2_queue_init() failed\n");
> + vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
> + return ret;
> + }
> /* Set io allowed member of file handle to TRUE */
> fh->io_allowed[index] = 1;
> /* Increment io usrs member of channel object to 1 */
> diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
> index ae8329d..7f20ca5 100644
> --- a/drivers/media/platform/davinci/vpif_display.c
> +++ b/drivers/media/platform/davinci/vpif_display.c
> @@ -936,6 +936,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
> enum v4l2_field field;
> struct vb2_queue *q;
> u8 index = 0;
> + int ret;
>
> /* This file handle has not initialized the channel,
> It is not allowed to do settings */
> @@ -981,8 +982,12 @@ static int vpif_reqbufs(struct file *file, void *priv,
> q->mem_ops = &vb2_dma_contig_memops;
> q->buf_struct_size = sizeof(struct vpif_disp_buffer);
>
> - vb2_queue_init(q);
> -
> + ret = vb2_queue_init(q);
> + if (ret) {
> + vpif_err("vpif_display: vb2_queue_init() failed\n");
> + vb2_dma_contig_cleanup_ctx(common->alloc_ctx);
> + return ret;
> + }
> /* Set io allowed member of file handle to TRUE */
> fh->io_allowed[index] = 1;
> /* Increment io usrs member of channel object to 1 */
>

2012-10-04 09:38:09

by Hans Verkuil

[permalink] [raw]
Subject: Re: [PATCH v3] media: davinci: vpif: set device capabilities

On Thu 4 October 2012 11:29:58 Prabhakar wrote:
> From: Lad, Prabhakar <[email protected]>
>
> set device_caps and also change the driver and
> bus_info to proper values as per standard.
>
> Signed-off-by: Lad, Prabhakar <[email protected]>
> Signed-off-by: Manjunath Hadli <[email protected]>
> Cc: Hans Verkuil <[email protected]>

Acked-by: Hans Verkuil <[email protected]>

Regards,

Hans

> ---
> Changes for v3:
> 1: Removed READWRITE flag for device_caps pointed by Hans.
>
> Changes for v2:
> 1: Change the bus_info and driver to proper values,
> pointed by Hans.
>
> drivers/media/platform/davinci/vpif_capture.c | 8 +++++---
> drivers/media/platform/davinci/vpif_display.c | 8 +++++---
> 2 files changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
> index cabd5a2..fcabc02 100644
> --- a/drivers/media/platform/davinci/vpif_capture.c
> +++ b/drivers/media/platform/davinci/vpif_capture.c
> @@ -1635,9 +1635,11 @@ static int vpif_querycap(struct file *file, void *priv,
> {
> struct vpif_capture_config *config = vpif_dev->platform_data;
>
> - cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
> - strlcpy(cap->driver, "vpif capture", sizeof(cap->driver));
> - strlcpy(cap->bus_info, "VPIF Platform", sizeof(cap->bus_info));
> + cap->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
> + cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
> + snprintf(cap->driver, sizeof(cap->driver), "%s", dev_name(vpif_dev));
> + snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> + dev_name(vpif_dev));
> strlcpy(cap->card, config->card_name, sizeof(cap->card));
>
> return 0;
> diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c
> index 7f20ca5..b716fbd 100644
> --- a/drivers/media/platform/davinci/vpif_display.c
> +++ b/drivers/media/platform/davinci/vpif_display.c
> @@ -827,9 +827,11 @@ static int vpif_querycap(struct file *file, void *priv,
> {
> struct vpif_display_config *config = vpif_dev->platform_data;
>
> - cap->capabilities = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
> - strlcpy(cap->driver, "vpif display", sizeof(cap->driver));
> - strlcpy(cap->bus_info, "Platform", sizeof(cap->bus_info));
> + cap->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
> + cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS;
> + snprintf(cap->driver, sizeof(cap->driver), "%s", dev_name(vpif_dev));
> + snprintf(cap->bus_info, sizeof(cap->bus_info), "platform:%s",
> + dev_name(vpif_dev));
> strlcpy(cap->card, config->card_name, sizeof(cap->card));
>
> return 0;
>