diff mbox series

[4/8] media: platform: renesas-ceu: drop buf NULL check

Message ID 20230524121150.435736-5-hverkuil-cisco@xs4all.nl (mailing list archive)
State New, archived
Headers show
Series Various smatch/sparse fixes | expand

Commit Message

Hans Verkuil May 24, 2023, 12:11 p.m. UTC
Since start_streaming is only called if there are at least two
buffers queued, the ceudev->capture list will never be empty, so
the check whether there are no buffers can be dropped.

Note that the '!buf' check was wrong in any case, if we wanted to
check for an empty list it should have used list_empty().

This fixes this smatch warning:

drivers/media/platform/renesas/renesas-ceu.c:705 ceu_start_streaming() warn: can 'buf' even be NULL?

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: Jacopo Mondi <jacopo@jmondi.org>
---
 drivers/media/platform/renesas/renesas-ceu.c | 9 ---------
 1 file changed, 9 deletions(-)

Comments

Jacopo Mondi May 25, 2023, 1:43 p.m. UTC | #1
Hi Hans,

On Wed, May 24, 2023 at 02:11:46PM +0200, Hans Verkuil wrote:
> Since start_streaming is only called if there are at least two
> buffers queued, the ceudev->capture list will never be empty, so
> the check whether there are no buffers can be dropped.
>
> Note that the '!buf' check was wrong in any case, if we wanted to
> check for an empty list it should have used list_empty().
>
> This fixes this smatch warning:
>
> drivers/media/platform/renesas/renesas-ceu.c:705 ceu_start_streaming() warn: can 'buf' even be NULL?
>
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Cc: Jacopo Mondi <jacopo@jmondi.org>

Thank you!
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>


> ---
>  drivers/media/platform/renesas/renesas-ceu.c | 9 ---------
>  1 file changed, 9 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/renesas-ceu.c b/drivers/media/platform/renesas/renesas-ceu.c
> index 56b9c59cfda8..5c9e27f8c94b 100644
> --- a/drivers/media/platform/renesas/renesas-ceu.c
> +++ b/drivers/media/platform/renesas/renesas-ceu.c
> @@ -702,12 +702,6 @@ static int ceu_start_streaming(struct vb2_queue *vq, unsigned int count)
>  	/* Grab the first available buffer and trigger the first capture. */
>  	buf = list_first_entry(&ceudev->capture, struct ceu_buffer,
>  			       queue);
> -	if (!buf) {
> -		spin_unlock_irqrestore(&ceudev->lock, irqflags);
> -		dev_dbg(ceudev->dev,
> -			"No buffer available for capture.\n");
> -		goto error_stop_sensor;
> -	}
>
>  	list_del(&buf->queue);
>  	ceudev->active = &buf->vb;
> @@ -722,9 +716,6 @@ static int ceu_start_streaming(struct vb2_queue *vq, unsigned int count)
>
>  	return 0;
>
> -error_stop_sensor:
> -	v4l2_subdev_call(v4l2_sd, video, s_stream, 0);
> -
>  error_return_bufs:
>  	spin_lock_irqsave(&ceudev->lock, irqflags);
>  	list_for_each_entry(buf, &ceudev->capture, queue)
> --
> 2.39.2
>
diff mbox series

Patch

diff --git a/drivers/media/platform/renesas/renesas-ceu.c b/drivers/media/platform/renesas/renesas-ceu.c
index 56b9c59cfda8..5c9e27f8c94b 100644
--- a/drivers/media/platform/renesas/renesas-ceu.c
+++ b/drivers/media/platform/renesas/renesas-ceu.c
@@ -702,12 +702,6 @@  static int ceu_start_streaming(struct vb2_queue *vq, unsigned int count)
 	/* Grab the first available buffer and trigger the first capture. */
 	buf = list_first_entry(&ceudev->capture, struct ceu_buffer,
 			       queue);
-	if (!buf) {
-		spin_unlock_irqrestore(&ceudev->lock, irqflags);
-		dev_dbg(ceudev->dev,
-			"No buffer available for capture.\n");
-		goto error_stop_sensor;
-	}
 
 	list_del(&buf->queue);
 	ceudev->active = &buf->vb;
@@ -722,9 +716,6 @@  static int ceu_start_streaming(struct vb2_queue *vq, unsigned int count)
 
 	return 0;
 
-error_stop_sensor:
-	v4l2_subdev_call(v4l2_sd, video, s_stream, 0);
-
 error_return_bufs:
 	spin_lock_irqsave(&ceudev->lock, irqflags);
 	list_for_each_entry(buf, &ceudev->capture, queue)