From patchwork Sun Sep 8 10:12:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 173339 Delivered-To: patches@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp3003025ilq; Sun, 8 Sep 2019 03:12:47 -0700 (PDT) X-Received: by 2002:a19:7d55:: with SMTP id y82mr12583280lfc.106.1567937567430; Sun, 08 Sep 2019 03:12:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567937567; cv=none; d=google.com; s=arc-20160816; b=oJ8Cy7x/4TkaceQlYVPwcAL8svL/vDikM7+Vk+pBCr3m3cevNuknqtJcqYY5WqiYeC VxASnQAsMD5wxWiodHqIvc/5MqGsrsmhcUpyLfWrGIbDnz1XbBY9I65N0zhz8VLjMSHz XRdr10HjSzvabpkzWp6kjLisqsAzPT1v2hfNjN94nxJA4k8GKF9iuPfk4/hIoBLMbiUy kPOd57nHPNMHuouo/tUIKTk8HnjsBDdwwebKiyyaMrcWWPW3wv5qKJ+0b+cNXF1yJpb5 OF1zTHJdpzDe4jmB798T2ml520c/jbtlmR1ByVsIDwYkLCMwP1G8Y+RD1qtoaqcIF/4d gITg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mZN0trNPMDGK13UKBqW2zdfZhLOq96vtybPEWVfKPNw=; b=WDkEYfXhzdDQbo9RfXM1iccr2SqRwOH4QlPYaTLwdW29jZi01PMhZ5yGNWkNSj6O9M yvwlYuOPNAWSTiFM5PeGnUIYHSxIXMa7RHV7UGju4j27uUaFQutUZD+pb8xIvqqYF+Vg Ytj6IxUK3c5J7n7QhkoGHUqXtC/Nn6f5oxIoVYWSDrJg2jlldUhQ3ngch1M7GmUGCiB3 U8DlwLlze6voqsXapx/o79X18Dc1u1Jv0T5Y7NfFTb7tALTaQYcb66VXKzg/ut1WkMFB vaL23aJsWhH0knhoy5aL1SrYjhuwmk2wLoJ3+E2Uakms37ax1ZCahC8j7Lmh/lSLh4Pu KkNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eSu4o+D1; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id u8sor3673473ljj.24.2019.09.08.03.12.47 for (Google Transport Security); Sun, 08 Sep 2019 03:12:47 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eSu4o+D1; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mZN0trNPMDGK13UKBqW2zdfZhLOq96vtybPEWVfKPNw=; b=eSu4o+D14VPgj3Ynxc1N1DEPmO10ApZ1GvVsFUrqtPJRSKRwUCmUZEqTh5FWANi7DK Kx64es6+u0lX/QzhJ/Hvb+fUy2CtpUpvq5Tr54WwKwARFAjar4rmQ1Jpaie44uXp4MC7 QGvl/fbYdwdScf/L7DTqStNqxyq33b3BxDiLmUEikDGOeS7vx6IGbkV8Jpso8WWIlJz8 dN5erHSXWrVGemR8IYO3b1NBA4od7jAry3DZwPuZ2xdh/lXu48W8NULkDXHQTapEeAtx mxwDAZdX5djBy2GJSZv7T0XqRugKn5DVVOEWGnXscoIR6tjY/yFJAaJUsZw+UN3/J64X dfsQ== 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; bh=mZN0trNPMDGK13UKBqW2zdfZhLOq96vtybPEWVfKPNw=; b=idv5UMpnZWlhGFMYtbenyWwZWykG+cJodOePt7dkb48i17F6uZbKCsB+luVFXaWC1n fl2zuQgo/s9jTVkAHo3MtKO+5ySdpT4MzieznTSndh3d4CRlkP8k/aA8TqSSsRhNTf4s sNA7JGLVPfi430Pz3rrcINz8mAinBJCmK4K2xnp0d3w6cXrBr9zs3yfDdUGLFi5KMLSz esb2xn5tMaPmXdvZEUu/4Rljc7CgpY94qTy9HMPXmWBHjdcVoZeImA8VX9npy8o1VOXY HWy7b/3Hk8DeaGKl2npzyFm1UK+ZFdooy5l1zH2KSSvTxQsf+gY9SkW2RwjF+o12qSfl 21bw== X-Gm-Message-State: APjAAAWiZdEXaBl0ZdLRGfqlEAAL4UHLZPuNMbbMzpL3O/Dnt5Fmkq+U ncWztUeEcD1M9Sbwh73OGaq1KaYK X-Google-Smtp-Source: APXvYqz8cu6BKIqcffnELf83zGndaKhR4JEUPbfnLof3jUsv/FRYX5HaVItHDHcK51dNgNqZHOapSQ== X-Received: by 2002:a2e:331a:: with SMTP id d26mr12181565ljc.239.1567937567102; Sun, 08 Sep 2019 03:12:47 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([185.122.190.73]) by smtp.gmail.com with ESMTPSA id h25sm2444849lfj.81.2019.09.08.03.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2019 03:12:46 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Adrian Hunter , Douglas Anderson , Matthias Kaehlcke Cc: Shawn Lin , Jaehoon Chung , Yong Mao , Chaotian Jing , linux-kernel@vger.kernel.org Subject: [PATCH v2 04/11] mmc: core: Move code to get pending SDIO IRQs to a function Date: Sun, 8 Sep 2019 12:12:29 +0200 Message-Id: <20190908101236.2802-5-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190908101236.2802-1-ulf.hansson@linaro.org> References: <20190908101236.2802-1-ulf.hansson@linaro.org> From: Matthias Kaehlcke To improve code quality, let's move the code that gets pending SDIO IRQs from process_sdio_pending_irqs() into a dedicated function. Signed-off-by: Matthias Kaehlcke [Ulf: Converted function into static] Tested-by: Matthias Kaehlcke Signed-off-by: Ulf Hansson --- drivers/mmc/core/sdio_irq.c | 46 ++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 16 deletions(-) -- 2.17.1 Reviewed-by: Douglas Anderson diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c index 0bcc5e83bd1a..f75043266984 100644 --- a/drivers/mmc/core/sdio_irq.c +++ b/drivers/mmc/core/sdio_irq.c @@ -27,6 +27,34 @@ #include "core.h" #include "card.h" +static int sdio_get_pending_irqs(struct mmc_host *host, u8 *pending) +{ + struct mmc_card *card = host->card; + int ret; + + WARN_ON(!host->claimed); + + ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, pending); + if (ret) { + pr_debug("%s: error %d reading SDIO_CCCR_INTx\n", + mmc_card_id(card), ret); + return ret; + } + + if (*pending && mmc_card_broken_irq_polling(card) && + !(host->caps & MMC_CAP_SDIO_IRQ)) { + unsigned char dummy; + + /* A fake interrupt could be created when we poll SDIO_CCCR_INTx + * register with a Marvell SD8797 card. A dummy CMD52 read to + * function 0 register 0xff can avoid this. + */ + mmc_io_rw_direct(card, 0, 0, 0xff, 0, &dummy); + } + + return 0; +} + static int process_sdio_pending_irqs(struct mmc_host *host) { struct mmc_card *card = host->card; @@ -49,23 +77,9 @@ static int process_sdio_pending_irqs(struct mmc_host *host) return 1; } - ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending); - if (ret) { - pr_debug("%s: error %d reading SDIO_CCCR_INTx\n", - mmc_card_id(card), ret); + ret = sdio_get_pending_irqs(host, &pending); + if (ret) return ret; - } - - if (pending && mmc_card_broken_irq_polling(card) && - !(host->caps & MMC_CAP_SDIO_IRQ)) { - unsigned char dummy; - - /* A fake interrupt could be created when we poll SDIO_CCCR_INTx - * register with a Marvell SD8797 card. A dummy CMD52 read to - * function 0 register 0xff can avoid this. - */ - mmc_io_rw_direct(card, 0, 0, 0xff, 0, &dummy); - } count = 0; for (i = 1; i <= 7; i++) {