From patchwork Wed Nov 8 06:34:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10047835 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 DB537603FA for ; Wed, 8 Nov 2017 06:36:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE0922A4E1 for ; Wed, 8 Nov 2017 06:36:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2A4F2A4E4; Wed, 8 Nov 2017 06:36:12 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 B130D2A4E1 for ; Wed, 8 Nov 2017 06:36:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752816AbdKHGgK (ORCPT ); Wed, 8 Nov 2017 01:36:10 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:64401 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751910AbdKHGgJ (ORCPT ); Wed, 8 Nov 2017 01:36:09 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id vA86Z5mk026956; Wed, 8 Nov 2017 15:35:06 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com vA86Z5mk026956 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1510122906; bh=UWHd9U4sBZKzrnzTCCr6EQU3vS95avn76RlRoY8hIkw=; h=From:To:Cc:Subject:Date:From; b=iLuNXJ0rSJgBHsCkUNEOv8C8ZfYV7gEUVuIMI/NgXQ5ScKX1nWU9DSqgSq51E0zlt xymjYmcY8IkOGIq8O98D6u/RV1q5CGYG3XP6rxTVo3l7ns6RlhExTnNO10lpb9+6w6 WyFLnuDaUnEsEO8tXFE7CwN0z0yikRvJH6ieWURrbaOGZBzvSOiJPP/S28KT7u3fu1 /zVwmyhxAa/x3lSkJgaTo9THr+Bu4ggAiisY5I33hYSBds6k/sPdGZ9hfHZwX96z4d YBlwA08q1jIO3fFQUik9CQjC7FCm5negkottJHfJs7sPDtk1oim9d7kwuaTr7P8iHW wZ1Cw3UaoyGZQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mmc@vger.kernel.org Cc: Masahiro Yamada , Adrian Hunter , linux-kernel@vger.kernel.org, Andy Shevchenko , Shawn Lin , Ulf Hansson Subject: [PATCH] mmc: slot-gpio: call gpiod_to_irq() only when MMC_CAP_NEEDS_POLL is unset Date: Wed, 8 Nov 2017 15:34:54 +0900 Message-Id: <1510122894-9296-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is not efficient to call gpiod_to_irq() regardless the flag, then ignore the returned irq if MMC_CAP_NEEDS_POLL. Move gpiod_to_irq() after the MMC_CAP_NEEDS_POLL check. Signed-off-by: Masahiro Yamada --- drivers/mmc/core/slot-gpio.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c index 863f1db..f7c6e05 100644 --- a/drivers/mmc/core/slot-gpio.c +++ b/drivers/mmc/core/slot-gpio.c @@ -121,20 +121,18 @@ EXPORT_SYMBOL(mmc_gpio_request_ro); void mmc_gpiod_request_cd_irq(struct mmc_host *host) { struct mmc_gpio *ctx = host->slot.handler_priv; - int ret, irq; + int irq = -EINVAL; + int ret; if (host->slot.cd_irq >= 0 || !ctx || !ctx->cd_gpio) return; - irq = gpiod_to_irq(ctx->cd_gpio); - /* - * Even if gpiod_to_irq() returns a valid IRQ number, the platform might - * still prefer to poll, e.g., because that IRQ number is already used - * by another unit and cannot be shared. + * Do not use IRQ if the platform prefers to poll, e.g., because that + * IRQ number is already used by another unit and cannot be shared. */ - if (irq >= 0 && host->caps & MMC_CAP_NEEDS_POLL) - irq = -EINVAL; + if (!(host->caps & MMC_CAP_NEEDS_POLL)) + irq = gpiod_to_irq(ctx->cd_gpio); if (irq >= 0) { if (!ctx->cd_gpio_isr)