V4L/DVB (13771): [Mantis] Reset Flags at the earliest possible

Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/dvb/mantis/mantis_common.h b/drivers/media/dvb/mantis/mantis_common.h
index ac3eefe..27ecfdb 100644
--- a/drivers/media/dvb/mantis/mantis_common.h
+++ b/drivers/media/dvb/mantis/mantis_common.h
@@ -139,6 +139,8 @@
 	 /*	A12 A13 A14		*/
 	u32			gpio_status;
 
+	u32			gpif_status;
+
 	struct mantis_ca	*mantis_ca;
 };
 
diff --git a/drivers/media/dvb/mantis/mantis_evm.c b/drivers/media/dvb/mantis/mantis_evm.c
index d603601..4c4c144 100644
--- a/drivers/media/dvb/mantis/mantis_evm.c
+++ b/drivers/media/dvb/mantis/mantis_evm.c
@@ -27,19 +27,11 @@
 	struct mantis_ca *ca = container_of(work, struct mantis_ca, hif_evm_work);
 	struct mantis_pci *mantis = ca->ca_priv;
 
-	u32 gpif_stat, gpif_mask, rst_mask, rst_stat;
-
-	rst_mask  = MANTIS_GPIF_WRACK  |
-		    MANTIS_GPIF_OTHERR |
-		    MANTIS_SBUF_WSTO   |
-		    MANTIS_GPIF_EXTIRQ;
+	u32 gpif_stat, gpif_mask;
 
 	gpif_stat = mmread(MANTIS_GPIF_STATUS);
 	gpif_mask = mmread(MANTIS_GPIF_IRQCFG);
 
-	rst_stat = gpif_stat & rst_mask;
-	mmwrite(rst_stat, MANTIS_GPIF_STATUS);
-
 	if (gpif_stat & MANTIS_GPIF_DETSTAT) {
 		if (gpif_stat & MANTIS_CARD_PLUGIN) {
 			dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): CAM Plugin", mantis->num);
@@ -60,13 +52,13 @@
 		}
 	}
 
-	if (gpif_stat & MANTIS_GPIF_EXTIRQ)
+	if (mantis->gpif_status & MANTIS_GPIF_EXTIRQ)
 		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Ext IRQ", mantis->num);
 
-	if (gpif_stat & MANTIS_SBUF_WSTO)
+	if (mantis->gpif_status & MANTIS_SBUF_WSTO)
 		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Timeout", mantis->num);
 
-	if (gpif_stat & MANTIS_GPIF_OTHERR)
+	if (mantis->gpif_status & MANTIS_GPIF_OTHERR)
 		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Alignment Error", mantis->num);
 
 	if (gpif_stat & MANTIS_SBUF_OVFLW)
@@ -75,7 +67,7 @@
 	if (gpif_stat & MANTIS_GPIF_BRRDY)
 		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Smart Buffer Read Ready", mantis->num);
 
-	if (gpif_stat & MANTIS_GPIF_WRACK)
+	if (mantis->gpif_status & MANTIS_GPIF_WRACK)
 		dprintk(verbose, MANTIS_DEBUG, 1, "Event Mgr: Adapter(%d) Slot(0): Slave Write ACK", mantis->num);
 
 	if (gpif_stat & MANTIS_GPIF_INTSTAT)
diff --git a/drivers/media/dvb/mantis/mantis_pci.c b/drivers/media/dvb/mantis/mantis_pci.c
index 4873fa9..f57e2a4 100644
--- a/drivers/media/dvb/mantis/mantis_pci.c
+++ b/drivers/media/dvb/mantis/mantis_pci.c
@@ -53,6 +53,8 @@
 static irqreturn_t mantis_pci_irq(int irq, void *dev_id)
 {
 	u32 stat = 0, mask = 0, lstat = 0, mstat = 0;
+	u32 rst_stat = 0, rst_mask = 0;
+
 	struct mantis_pci *mantis;
 	struct mantis_ca *ca;
 
@@ -69,6 +71,15 @@
 	if (!(stat & mask))
 		return IRQ_NONE;
 
+	rst_mask  = MANTIS_GPIF_WRACK  |
+		    MANTIS_GPIF_OTHERR |
+		    MANTIS_SBUF_WSTO   |
+		    MANTIS_GPIF_EXTIRQ;
+
+	rst_stat  = mmread(MANTIS_GPIF_STATUS);
+	rst_stat &= rst_mask;
+	mmwrite(rst_stat, MANTIS_GPIF_STATUS);
+
 	mantis->mantis_int_stat = stat;
 	mantis->mantis_int_mask = mask;
 	dprintk(verbose, MANTIS_DEBUG, 0, "=== Interrupts[%04x/%04x]= [", stat, mask);
@@ -77,6 +88,7 @@
 	}
 	if (stat & MANTIS_INT_IRQ0) {
 		dprintk(verbose, MANTIS_DEBUG, 0, "* INT IRQ-0 *");
+		mantis->gpif_status = rst_stat;
 		schedule_work(&ca->hif_evm_work);
 	}
 	if (stat & MANTIS_INT_IRQ1) {