linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: <linux-media@vger.kernel.org>, Benoit Parrot <bparrot@ti.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Hans Verkuil <hverkuil@xs4all.nl>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Tomi Valkeinen <tomi.valkeinen@ti.com>
Subject: [PATCH v3 08/19] media: ti-vpe: cal: simplify irq handling
Date: Wed, 25 Mar 2020 14:14:59 +0200	[thread overview]
Message-ID: <20200325121510.25923-9-tomi.valkeinen@ti.com> (raw)
In-Reply-To: <20200325121510.25923-1-tomi.valkeinen@ti.com>

Instead of having identical code block to handle irqs for the two CAL
ports, we can have a for loop and a single code block.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Benoit Parrot <bparrot@ti.com>
---
 drivers/media/platform/ti-vpe/cal.c | 68 +++++++++++------------------
 1 file changed, 25 insertions(+), 43 deletions(-)

diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 9bfe83fdd76e..df06ecfdfc6a 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -1221,64 +1221,46 @@ static irqreturn_t cal_irq(int irq_cal, void *data)
 	/* Check which DMA just finished */
 	irqst2 = reg_read(dev, CAL_HL_IRQSTATUS(2));
 	if (irqst2) {
+		int i;
+
 		/* Clear Interrupt status */
 		reg_write(dev, CAL_HL_IRQSTATUS(2), irqst2);
 
-		/* Need to check both port */
-		if (isportirqset(irqst2, 1)) {
-			ctx = dev->ctx[0];
-
-			spin_lock(&ctx->slock);
-			ctx->dma_act = false;
-
-			if (ctx->cur_frm != ctx->next_frm)
-				cal_process_buffer_complete(ctx);
-
-			spin_unlock(&ctx->slock);
-		}
-
-		if (isportirqset(irqst2, 2)) {
-			ctx = dev->ctx[1];
+		for (i = 1; i <= 2; ++i) {
+			if (isportirqset(irqst2, i)) {
+				ctx = dev->ctx[i - 1];
 
-			spin_lock(&ctx->slock);
-			ctx->dma_act = false;
+				spin_lock(&ctx->slock);
+				ctx->dma_act = false;
 
-			if (ctx->cur_frm != ctx->next_frm)
-				cal_process_buffer_complete(ctx);
+				if (ctx->cur_frm != ctx->next_frm)
+					cal_process_buffer_complete(ctx);
 
-			spin_unlock(&ctx->slock);
+				spin_unlock(&ctx->slock);
+			}
 		}
 	}
 
 	/* Check which DMA just started */
 	irqst3 = reg_read(dev, CAL_HL_IRQSTATUS(3));
 	if (irqst3) {
+		int i;
+
 		/* Clear Interrupt status */
 		reg_write(dev, CAL_HL_IRQSTATUS(3), irqst3);
 
-		/* Need to check both port */
-		if (isportirqset(irqst3, 1)) {
-			ctx = dev->ctx[0];
-			dma_q = &ctx->vidq;
-
-			spin_lock(&ctx->slock);
-			ctx->dma_act = true;
-			if (!list_empty(&dma_q->active) &&
-			    ctx->cur_frm == ctx->next_frm)
-				cal_schedule_next_buffer(ctx);
-			spin_unlock(&ctx->slock);
-		}
-
-		if (isportirqset(irqst3, 2)) {
-			ctx = dev->ctx[1];
-			dma_q = &ctx->vidq;
-
-			spin_lock(&ctx->slock);
-			ctx->dma_act = true;
-			if (!list_empty(&dma_q->active) &&
-			    ctx->cur_frm == ctx->next_frm)
-				cal_schedule_next_buffer(ctx);
-			spin_unlock(&ctx->slock);
+		for (i = 1; i <= 2; ++i) {
+			if (isportirqset(irqst3, i)) {
+				ctx = dev->ctx[i - 1];
+				dma_q = &ctx->vidq;
+
+				spin_lock(&ctx->slock);
+				ctx->dma_act = true;
+				if (!list_empty(&dma_q->active) &&
+				    ctx->cur_frm == ctx->next_frm)
+					cal_schedule_next_buffer(ctx);
+				spin_unlock(&ctx->slock);
+			}
 		}
 	}
 
-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki


  parent reply	other threads:[~2020-03-25 12:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 12:14 [PATCH v3 00/19] CAL fixes and improvements Tomi Valkeinen
2020-03-25 12:14 ` [PATCH v3 01/19] media: ti-vpe: cal: fix DMA memory corruption Tomi Valkeinen
2020-03-25 12:14 ` [PATCH v3 02/19] media: ti-vpe: cal: improve enable_irqs Tomi Valkeinen
2020-03-25 12:14 ` [PATCH v3 03/19] media: ti-vpe: cal: fix use of wrong macro Tomi Valkeinen
2020-03-25 12:14 ` [PATCH v3 04/19] media: ti-vpe: cal: use runtime_resume for errata handling Tomi Valkeinen
2020-03-25 12:14 ` [PATCH v3 05/19] media: ti-vpe: cal: drop cal_runtime_get/put Tomi Valkeinen
2020-03-25 12:14 ` [PATCH v3 06/19] media: ti-vpe: cal: catch error irqs and print errors Tomi Valkeinen
2020-03-25 12:14 ` [PATCH v3 07/19] media: ti-vpe: cal: print errors on timeouts Tomi Valkeinen
2020-03-25 12:14 ` Tomi Valkeinen [this message]
2020-03-25 12:15 ` [PATCH v3 09/19] media: ti-vpe: cal: remove useless CAL_GEN_* macros Tomi Valkeinen
2020-03-25 12:15 ` [PATCH v3 10/19] media: ti-vpe: cal: remove useless IRQ defines Tomi Valkeinen
2020-03-25 12:15 ` [PATCH v3 11/19] media: ti-vpe: cal: use reg_write_field Tomi Valkeinen
2020-03-25 12:15 ` [PATCH v3 12/19] media: ti-vpe: cal: cleanup CIO power enable/disable Tomi Valkeinen
2020-03-25 12:15 ` [PATCH v3 13/19] media: ti-vpe: cal: fix dummy read to phy Tomi Valkeinen
2020-03-25 12:15 ` [PATCH v3 14/19] media: ti-vpe: cal: program number of lines properly Tomi Valkeinen
2020-03-25 12:15 ` [PATCH v3 15/19] media: ti-vpe: cal: set DMA max seg size Tomi Valkeinen
2020-03-25 12:15 ` [PATCH v3 16/19] media: ti-vpe: cal: move code to separate functions Tomi Valkeinen
2020-03-25 12:15 ` [PATCH v3 17/19] media: ti-vpe: cal: improve wait for CIO resetdone Tomi Valkeinen
2020-03-25 12:15 ` [PATCH v3 18/19] media: ti-vpe: cal: improve wait for stop-state Tomi Valkeinen
2020-03-25 12:15 ` [PATCH v3 19/19] media: ti-vpe: cal: fix stop state timeout Tomi Valkeinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200325121510.25923-9-tomi.valkeinen@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=bparrot@ti.com \
    --cc=hverkuil@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).