Thread (1 message) 1 message, 1 author, 2014-12-15

Re: [PATCH 4/4] usb: atmel_usba_udc: mask status with enabled irqs

From: Boris Brezillon <hidden>
Date: 2014-12-15 14:01:25

On Mon, 15 Dec 2014 13:34:56 +0000
David Laight [off-list ref] wrote:
From: Sergei Shtylyov
quoted
Hello.

On 12/15/2014 4:03 PM, Boris Brezillon wrote:
quoted
Avoid interpreting useless status flags when we're not waiting for such
events by masking the status variable with the interrupt enabled register
value.
quoted
Reported-by: Patrice VILCHEZ <redacted>
Signed-off-by: Boris Brezillon <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
  drivers/usb/gadget/udc/atmel_usba_udc.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
quoted
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 55c8dde..bc3a532 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1612,12 +1612,14 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)

  	spin_lock(&udc->lock);

-	status = usba_readl(udc, INT_STA);
+	status = usba_readl(udc, INT_STA) & usba_readl(udc, INT_ENB);
  	DBG(DBG_INT, "irq, status=%#08x\n", status);

  	if (status & USBA_DET_SUSPEND) {
  		toggle_bias(udc, 0);
  		usba_writel(udc, INT_CLR, USBA_DET_SUSPEND);
+		usba_writel(udc, INT_ENB,
+			    usba_readl(udc, INT_ENB) | USBA_WAKE_UP);
  		udc->bias_pulse_needed = true;
  		DBG(DBG_BUS, "Suspend detected\n");
  		if (udc->gadget.speed != USB_SPEED_UNKNOWN
@@ -1631,6 +1633,8 @@ static irqreturn_t usba_udc_irq(int irq, void *devid)
  	if (status & USBA_WAKE_UP) {
  		toggle_bias(udc, 1);
  		usba_writel(udc, INT_CLR, USBA_WAKE_UP);
+		usba_writel(udc, INT_ENB,
+			    usba_readl(udc, INT_ENB) & ~USBA_WAKE_UP);
  		DBG(DBG_BUS, "Wake Up CPU detected\n");
  	}
    Looks like t make sense to read the INT_ENB register into a separate
variable, to save on extra reads?

Better still remember the written value in one of the structures so
that it doesn't have to be read at all.
Sure, I'll modify the code accordingly.

Thanks,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help