[v2,2/6] media: i.MX27 camera: Use list_first_entry() whenever possible.

Message ID 1329908374-19769-1-git-send-email-javier.martin@vista-silicon.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Javier Martin Feb. 22, 2012, 10:59 a.m. UTC
  Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
---
 Changes since v1:
 - Adapt to [PATCH v4 4/4] media i.MX27 camera: handle overflows properly.

---
 drivers/media/video/mx2_camera.c |   26 ++++++++++++--------------
 1 files changed, 12 insertions(+), 14 deletions(-)
  

Comments

Guennadi Liakhovetski Feb. 27, 2012, 8:49 a.m. UTC | #1
Hi Javier

On Wed, 22 Feb 2012, Javier Martin wrote:

> Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
> ---
>  Changes since v1:
>  - Adapt to [PATCH v4 4/4] media i.MX27 camera: handle overflows properly.
> 
> ---
>  drivers/media/video/mx2_camera.c |   26 ++++++++++++--------------
>  1 files changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
> index 0ade14e..7793264 100644
> --- a/drivers/media/video/mx2_camera.c
> +++ b/drivers/media/video/mx2_camera.c

[snip]

> @@ -1314,7 +1312,7 @@ static irqreturn_t mx27_camera_emma_irq(int irq_emma, void *data)
>  		       pcdev->base_emma + PRP_CNTL);
>  		writel(cntl, pcdev->base_emma + PRP_CNTL);
>  
> -		buf = list_entry(pcdev->active_bufs.next,
> +		buf = list_first_entry(pcdev->active_bufs.next,

This is the only hunk, that you've changed. I'll fix this to be

+		buf = list_first_entry(&pcdev->active_bufs,

>  			struct mx2_buffer, queue);
>  		mx27_camera_frame_done_emma(pcdev,
>  					buf->bufnum, true);

Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
  
Javier Martin Feb. 27, 2012, 10:59 a.m. UTC | #2
On 27 February 2012 09:49, Guennadi Liakhovetski <g.liakhovetski@gmx.de> wrote:
> Hi Javier
>
> On Wed, 22 Feb 2012, Javier Martin wrote:
>
>> Signed-off-by: Javier Martin <javier.martin@vista-silicon.com>
>> ---
>>  Changes since v1:
>>  - Adapt to [PATCH v4 4/4] media i.MX27 camera: handle overflows properly.
>>
>> ---
>>  drivers/media/video/mx2_camera.c |   26 ++++++++++++--------------
>>  1 files changed, 12 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
>> index 0ade14e..7793264 100644
>> --- a/drivers/media/video/mx2_camera.c
>> +++ b/drivers/media/video/mx2_camera.c
>
> [snip]
>
>> @@ -1314,7 +1312,7 @@ static irqreturn_t mx27_camera_emma_irq(int irq_emma, void *data)
>>                      pcdev->base_emma + PRP_CNTL);
>>               writel(cntl, pcdev->base_emma + PRP_CNTL);
>>
>> -             buf = list_entry(pcdev->active_bufs.next,
>> +             buf = list_first_entry(pcdev->active_bufs.next,
>
> This is the only hunk, that you've changed. I'll fix this to be
>
> +               buf = list_first_entry(&pcdev->active_bufs,
>
>>                       struct mx2_buffer, queue);
>>               mx27_camera_frame_done_emma(pcdev,
>>                                       buf->bufnum, true);
>

Looks OK.

Regards.
  

Patch

diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c
index 0ade14e..7793264 100644
--- a/drivers/media/video/mx2_camera.c
+++ b/drivers/media/video/mx2_camera.c
@@ -458,7 +458,7 @@  static void mx25_camera_frame_done(struct mx2_camera_dev *pcdev, int fb,
 		buf = NULL;
 		writel(0, pcdev->base_csi + fb_reg);
 	} else {
-		buf = list_entry(pcdev->capture.next, struct mx2_buffer,
+		buf = list_first_entry(&pcdev->capture, struct mx2_buffer,
 				queue);
 		vb = &buf->vb;
 		list_del(&buf->queue);
@@ -718,8 +718,8 @@  static int mx2_start_streaming(struct vb2_queue *q, unsigned int count)
 
 		spin_lock_irqsave(&pcdev->lock, flags);
 
-		buf = list_entry(pcdev->capture.next,
-				 struct mx2_buffer, queue);
+		buf = list_first_entry(&pcdev->capture, struct mx2_buffer,
+				       queue);
 		buf->bufnum = 0;
 		vb = &buf->vb;
 		buf->state = MX2_STATE_ACTIVE;
@@ -728,8 +728,8 @@  static int mx2_start_streaming(struct vb2_queue *q, unsigned int count)
 		mx27_update_emma_buf(pcdev, phys, buf->bufnum);
 		list_move_tail(pcdev->capture.next, &pcdev->active_bufs);
 
-		buf = list_entry(pcdev->capture.next,
-				 struct mx2_buffer, queue);
+		buf = list_first_entry(&pcdev->capture, struct mx2_buffer,
+				       queue);
 		buf->bufnum = 1;
 		vb = &buf->vb;
 		buf->state = MX2_STATE_ACTIVE;
@@ -1215,8 +1215,7 @@  static void mx27_camera_frame_done_emma(struct mx2_camera_dev *pcdev,
 	struct vb2_buffer *vb;
 	unsigned long phys;
 
-	buf = list_entry(pcdev->active_bufs.next,
-			 struct mx2_buffer, queue);
+	buf = list_first_entry(&pcdev->active_bufs, struct mx2_buffer, queue);
 
 	BUG_ON(buf->bufnum != bufnum);
 
@@ -1270,8 +1269,8 @@  static void mx27_camera_frame_done_emma(struct mx2_camera_dev *pcdev,
 			return;
 		}
 
-		buf = list_entry(pcdev->discard.next,
-			struct mx2_buffer, queue);
+		buf = list_first_entry(&pcdev->discard, struct mx2_buffer,
+				       queue);
 		buf->bufnum = bufnum;
 
 		list_move_tail(pcdev->discard.next, &pcdev->active_bufs);
@@ -1279,8 +1278,7 @@  static void mx27_camera_frame_done_emma(struct mx2_camera_dev *pcdev,
 		return;
 	}
 
-	buf = list_entry(pcdev->capture.next,
-			struct mx2_buffer, queue);
+	buf = list_first_entry(&pcdev->capture, struct mx2_buffer, queue);
 
 	buf->bufnum = bufnum;
 
@@ -1314,7 +1312,7 @@  static irqreturn_t mx27_camera_emma_irq(int irq_emma, void *data)
 		       pcdev->base_emma + PRP_CNTL);
 		writel(cntl, pcdev->base_emma + PRP_CNTL);
 
-		buf = list_entry(pcdev->active_bufs.next,
+		buf = list_first_entry(pcdev->active_bufs.next,
 			struct mx2_buffer, queue);
 		mx27_camera_frame_done_emma(pcdev,
 					buf->bufnum, true);
@@ -1326,8 +1324,8 @@  static irqreturn_t mx27_camera_emma_irq(int irq_emma, void *data)
 		 * Both buffers have triggered, process the one we're expecting
 		 * to first
 		 */
-		buf = list_entry(pcdev->active_bufs.next,
-			struct mx2_buffer, queue);
+		buf = list_first_entry(&pcdev->active_bufs, struct mx2_buffer,
+				       queue);
 		mx27_camera_frame_done_emma(pcdev, buf->bufnum, false);
 		status &= ~(1 << (6 - buf->bufnum)); /* mark processed */
 	} else if ((status & (1 << 6)) || (status & (1 << 4))) {