From patchwork Wed Feb 20 12:19:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Bonn X-Patchwork-Id: 10822013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 877061805 for ; Wed, 20 Feb 2019 12:20:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FBED2D900 for ; Wed, 20 Feb 2019 12:20:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62CE82D963; Wed, 20 Feb 2019 12:20:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 211E02D734 for ; Wed, 20 Feb 2019 12:20:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727490AbfBTMUT (ORCPT ); Wed, 20 Feb 2019 07:20:19 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:33065 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726280AbfBTMUS (ORCPT ); Wed, 20 Feb 2019 07:20:18 -0500 Received: by mail-lj1-f193.google.com with SMTP id f24-v6so20623262ljk.0 for ; Wed, 20 Feb 2019 04:20:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=norrbonn-se.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2tfaveN+cB7E5HOlJgyDgTMgL0/lTVFeedC/fRB32HM=; b=rcZPB63i2KLSDRTv4dfIm0pYaDVSEWk2ftBAFZ5fQiWWpsvgnugh0UFD8H/MAFQxoP WKvEA2nGC/KALsMZs59ZhZ4icC5kAL3EWINnB0ZOWUM1ts4K2685ou91VqDOkObqnd4Z +4O95qIJbKM+2UyjjQLYFComGRQDuSARUqX7Or7dR6bi88PdyQzxm8cxHcv6NLPkSS2P YpRP4i+q1pHuEWCnaWSBooey7eQvRpWhZcdg9BVGZrBq51luxbdk2dx0X9NdYzxIFld8 2fPkQ50aPdFAH0zQ937IX/xiTgg+McFG5174MEfm4/4dsDa6Kbn80z0/IJUqP2nbfvCU HUCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2tfaveN+cB7E5HOlJgyDgTMgL0/lTVFeedC/fRB32HM=; b=iBqqs7L/RkG1e7WAEc4VlpG3BbdzNEqXb+9yrVYUE6JX35itK2TRiSP3iyn+tNFQM2 GVePHIMwChIZpoKskrSEFvdB3PtLI16nK3QqWXnxVd9Iy3ZbEb4jw6IyySAJeFj+DxlO a5NoewFA0/M4vB1PHUuTGEggu3k2/GLawsAHrb6HMhX+rwSH2CVrh6SmyNiDXdvNn0u1 qkgTlURXMLUPHZtvdSQkSQe1a1pjFSB7f8/AbkopPBbXLgDIuK5WYzOiQkDmpU6IXheB POGDA4vaiiAMcFMK1FwHXK+sT1JkqSP08DVT2tpoLfDRBHEK9YJsbzftss/U/vw/5le4 Q1tA== X-Gm-Message-State: AHQUAuapZ9UrNfmULp9F22ZJ59Jv8iNVf0YChNq875GFlM/OzUOiovtO lk+AcBf1X5dD08WRpYfQek1ZVQ== X-Google-Smtp-Source: AHgI3IYrQCiIUhsZpbt8/7/4ODJ5cjLPuMl//ZxG1g9HQl9PseFR2rWgHZDdYv+Lfcg6hfP7jUYVww== X-Received: by 2002:a2e:9b95:: with SMTP id z21mr3226407lji.155.1550665215496; Wed, 20 Feb 2019 04:20:15 -0800 (PST) Received: from mimer.lan (h-29-16.A159.priv.bahnhof.se. [79.136.29.16]) by smtp.gmail.com with ESMTPSA id r2-v6sm5270270lja.78.2019.02.20.04.20.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Feb 2019 04:20:15 -0800 (PST) From: Jonas Bonn To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Cc: Jonas Bonn , Cristian Birsan , Felipe Balbi , Greg Kroah-Hartman , Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] usb: gadget: atmel_usba_udc: simplify setting of interrupt-enabled mask Date: Wed, 20 Feb 2019 13:19:59 +0100 Message-Id: <20190220122001.5713-2-jonas@norrbonn.se> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190220122001.5713-1-jonas@norrbonn.se> References: <20190220122001.5713-1-jonas@norrbonn.se> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds set and clear functions for enabling/disabling interrupts. This simplifies the implementation a bit as the masking of previously set bits doesn't need to be so explicit. Signed-off-by: Jonas Bonn CC: Cristian Birsan CC: Felipe Balbi CC: Greg Kroah-Hartman CC: Nicolas Ferre CC: Alexandre Belloni CC: Ludovic Desroches CC: linux-arm-kernel@lists.infradead.org CC: linux-usb@vger.kernel.org --- drivers/usb/gadget/udc/atmel_usba_udc.c | 29 ++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 51a2b9232baa..9d18fdddd9b2 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -358,8 +358,20 @@ static inline u32 usba_int_enb_get(struct usba_udc *udc) return udc->int_enb_cache; } -static inline void usba_int_enb_set(struct usba_udc *udc, u32 val) +static inline void usba_int_enb_set(struct usba_udc *udc, u32 mask) { + u32 val; + + val = udc->int_enb_cache | mask; + usba_writel(udc, INT_ENB, val); + udc->int_enb_cache = val; +} + +static inline void usba_int_enb_clear(struct usba_udc *udc, u32 mask) +{ + u32 val; + + val = udc->int_enb_cache & ~mask; usba_writel(udc, INT_ENB, val); udc->int_enb_cache = val; } @@ -629,14 +641,12 @@ usba_ep_enable(struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) if (ep->can_dma) { u32 ctrl; - usba_int_enb_set(udc, usba_int_enb_get(udc) | - USBA_BF(EPT_INT, 1 << ep->index) | + usba_int_enb_set(udc, USBA_BF(EPT_INT, 1 << ep->index) | USBA_BF(DMA_INT, 1 << ep->index)); ctrl = USBA_AUTO_VALID | USBA_INTDIS_DMA; usba_ep_writel(ep, CTL_ENB, ctrl); } else { - usba_int_enb_set(udc, usba_int_enb_get(udc) | - USBA_BF(EPT_INT, 1 << ep->index)); + usba_int_enb_set(udc, USBA_BF(EPT_INT, 1 << ep->index)); } spin_unlock_irqrestore(&udc->lock, flags); @@ -680,8 +690,7 @@ static int usba_ep_disable(struct usb_ep *_ep) usba_dma_readl(ep, STATUS); } usba_ep_writel(ep, CTL_DIS, USBA_EPT_ENABLE); - usba_int_enb_set(udc, usba_int_enb_get(udc) & - ~USBA_BF(EPT_INT, 1 << ep->index)); + usba_int_enb_clear(udc, USBA_BF(EPT_INT, 1 << ep->index)); request_complete_list(ep, &req_list, -ESHUTDOWN); @@ -1713,7 +1722,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid) if (status & USBA_DET_SUSPEND) { toggle_bias(udc, 0); usba_writel(udc, INT_CLR, USBA_DET_SUSPEND); - usba_int_enb_set(udc, int_enb | USBA_WAKE_UP); + usba_int_enb_set(udc, USBA_WAKE_UP); udc->bias_pulse_needed = true; DBG(DBG_BUS, "Suspend detected\n"); if (udc->gadget.speed != USB_SPEED_UNKNOWN @@ -1727,7 +1736,7 @@ 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_int_enb_set(udc, int_enb & ~USBA_WAKE_UP); + usba_int_enb_clear(udc, USBA_WAKE_UP); DBG(DBG_BUS, "Wake Up CPU detected\n"); } @@ -1796,7 +1805,7 @@ static irqreturn_t usba_udc_irq(int irq, void *devid) | USBA_BF(BK_NUMBER, USBA_BK_NUMBER_ONE))); usba_ep_writel(ep0, CTL_ENB, USBA_EPT_ENABLE | USBA_RX_SETUP); - usba_int_enb_set(udc, int_enb | USBA_BF(EPT_INT, 1) | + usba_int_enb_set(udc, USBA_BF(EPT_INT, 1) | USBA_DET_SUSPEND | USBA_END_OF_RESUME); /*