From patchwork Tue Jul 26 12:02:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 9248051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 910EB6077C for ; Tue, 26 Jul 2016 12:02:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82B41271FD for ; Tue, 26 Jul 2016 12:02:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76E41272AA; Tue, 26 Jul 2016 12:02:40 +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=-6.9 required=2.0 tests=BAYES_00,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 C7A71271FD for ; Tue, 26 Jul 2016 12:02:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754635AbcGZMCi (ORCPT ); Tue, 26 Jul 2016 08:02:38 -0400 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:45105 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754597AbcGZMCh (ORCPT ); Tue, 26 Jul 2016 08:02:37 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1bS14C-0004zn-JY; Tue, 26 Jul 2016 14:02:32 +0200 Received: from ukl by dude.hi.pengutronix.de with local (Exim 4.87) (envelope-from ) id 1bS14C-0003mG-4t; Tue, 26 Jul 2016 14:02:32 +0200 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Mugunthan V N , Grygorii Strashko Cc: linux-omap@vger.kernel.org, netdev@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 1/2] net: davinci_cpdma: reduce time holding ctlr->lock in cpdma_control_set Date: Tue, 26 Jul 2016 14:02:24 +0200 Message-Id: <1469534545-14478-2-git-send-email-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1469534545-14478-1-git-send-email-u.kleine-koenig@pengutronix.de> References: <1469534545-14478-1-git-send-email-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-omap@vger.kernel.org Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The only user of cpdma_control_set (i.e. cpsw_ndo_open) doesn't check the return code, so it doesn't matter, which error triggers. So the checks that are independant of the fields protected by ctlr->lock can be moved out of the critical section. Signed-off-by: Uwe Kleine-König Reviewed-by: Grygorii Strashko Reviewed-by: Mugunthan V N --- drivers/net/ethernet/ti/davinci_cpdma.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 73638f7a55d4..5ffa04a306c6 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -877,23 +877,21 @@ int cpdma_control_set(struct cpdma_ctlr *ctlr, int control, int value) int ret; u32 val; - spin_lock_irqsave(&ctlr->lock, flags); - - ret = -ENOTSUPP; if (!ctlr->params.has_ext_regs) - goto unlock_ret; + return -ENOTSUPP; - ret = -EINVAL; - if (ctlr->state != CPDMA_STATE_ACTIVE) - goto unlock_ret; - - ret = -ENOENT; if (control < 0 || control >= ARRAY_SIZE(controls)) - goto unlock_ret; + return -ENOENT; - ret = -EPERM; if ((info->access & ACCESS_WO) != ACCESS_WO) + return -EPERM; + + spin_lock_irqsave(&ctlr->lock, flags); + + if (ctlr->state != CPDMA_STATE_ACTIVE) { + ret = -EINVAL; goto unlock_ret; + } val = dma_reg_read(ctlr, info->reg); val &= ~(info->mask << info->shift);