From patchwork Wed Feb 22 10:59:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martin X-Patchwork-Id: 10016 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1S09vH-0007NH-HX for patchwork@linuxtv.org; Wed, 22 Feb 2012 11:59:47 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-3) with esmtp for id 1S09vG-0003sy-Ea; Wed, 22 Feb 2012 11:59:47 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755427Ab2BVK7o (ORCPT ); Wed, 22 Feb 2012 05:59:44 -0500 Received: from mail-wi0-f174.google.com ([209.85.212.174]:51530 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754763Ab2BVK7n (ORCPT ); Wed, 22 Feb 2012 05:59:43 -0500 Received: by wics10 with SMTP id s10so4111066wic.19 for ; Wed, 22 Feb 2012 02:59:42 -0800 (PST) Received-SPF: pass (google.com: domain of javier.martin@vista-silicon.com designates 10.216.134.39 as permitted sender) client-ip=10.216.134.39; Authentication-Results: mr.google.com; spf=pass (google.com: domain of javier.martin@vista-silicon.com designates 10.216.134.39 as permitted sender) smtp.mail=javier.martin@vista-silicon.com Received: from mr.google.com ([10.216.134.39]) by 10.216.134.39 with SMTP id r39mr2201925wei.26.1329908382520 (num_hops = 1); Wed, 22 Feb 2012 02:59:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=gamma; h=mime-version:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=PC4OhPcKHZuvCbMCEJjOLdj4Tn9s1aK+wWNrTWr67JM=; b=FgPlcUnJV1eBpcj//2faib4lMVXuT5C90duhzmmK4wGujP8CQi/wIlGETGRYkDMs0h 8gksuiYpeb1pMSPkEM1NG2cm7yBMhWuYI1vf7dG47lJB8e6+x/XpJXWbsEObdQsLK+Ow 0jlU/qVBmoLUkfote21BdG4TGZGAtsYO3qsJs= MIME-Version: 1.0 Received: by 10.216.134.39 with SMTP id r39mr1784676wei.26.1329908382395; Wed, 22 Feb 2012 02:59:42 -0800 (PST) Received: from localhost.localdomain (182.50.18.95.dynamic.jazztel.es. [95.18.50.182]) by mx.google.com with ESMTPS id df3sm15528124wib.1.2012.02.22.02.59.40 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 22 Feb 2012 02:59:41 -0800 (PST) From: Javier Martin To: linux-media@vger.kernel.org Cc: g.liakhovetski@gmx.de, s.hauer@pengutronix.de, mchehab@infradead.org, Javier Martin Subject: [PATCH v2 2/6] media: i.MX27 camera: Use list_first_entry() whenever possible. Date: Wed, 22 Feb 2012 11:59:33 +0100 Message-Id: <1329908374-19769-1-git-send-email-javier.martin@vista-silicon.com> X-Mailer: git-send-email 1.7.0.4 X-Gm-Message-State: ALoCoQnOJvD0vvBHgI3Gwh2aP9NDywuWxRD6Jk7X3QjU0gNjlkcPzipelIqDXaLOrWwjM0VIrBhR Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.2.22.105126 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' Signed-off-by: Javier Martin --- 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 @@ -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))) {