mmc: slot-gpio: call gpiod_to_irq() only when MMC_CAP_NEEDS_POLL is unset

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 <yamada.masahiro@socionext.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
Masahiro Yamada 2017-11-08 15:34:54 +09:00 committed by Ulf Hansson
parent 50c4c4e268
commit 5f3a86014e
1 changed files with 6 additions and 8 deletions

View File

@ -121,20 +121,18 @@ EXPORT_SYMBOL(mmc_gpio_request_ro);
void mmc_gpiod_request_cd_irq(struct mmc_host *host) void mmc_gpiod_request_cd_irq(struct mmc_host *host)
{ {
struct mmc_gpio *ctx = host->slot.handler_priv; 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) if (host->slot.cd_irq >= 0 || !ctx || !ctx->cd_gpio)
return; return;
irq = gpiod_to_irq(ctx->cd_gpio);
/* /*
* Even if gpiod_to_irq() returns a valid IRQ number, the platform might * Do not use IRQ if the platform prefers to poll, e.g., because that
* still prefer to poll, e.g., because that IRQ number is already used * IRQ number is already used by another unit and cannot be shared.
* by another unit and cannot be shared.
*/ */
if (irq >= 0 && host->caps & MMC_CAP_NEEDS_POLL) if (!(host->caps & MMC_CAP_NEEDS_POLL))
irq = -EINVAL; irq = gpiod_to_irq(ctx->cd_gpio);
if (irq >= 0) { if (irq >= 0) {
if (!ctx->cd_gpio_isr) if (!ctx->cd_gpio_isr)