Skip to content

Commit a29b5fc

Browse files
mkaehlckeUlf Hansson
authored andcommitted
mmc: core: Move code to get pending SDIO IRQs to a function
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 <mka@chromium.org> [Ulf: Converted function into static] Tested-by: Matthias Kaehlcke <mka@chromium.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 1c81d69 commit a29b5fc

1 file changed

Lines changed: 30 additions & 16 deletions

File tree

‎drivers/mmc/core/sdio_irq.c‎

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,34 @@
2727
#include "core.h"
2828
#include "card.h"
2929

30+
static int sdio_get_pending_irqs(struct mmc_host *host, u8 *pending)
31+
{
32+
struct mmc_card *card = host->card;
33+
int ret;
34+
35+
WARN_ON(!host->claimed);
36+
37+
ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, pending);
38+
if (ret) {
39+
pr_debug("%s: error %d reading SDIO_CCCR_INTx\n",
40+
mmc_card_id(card), ret);
41+
return ret;
42+
}
43+
44+
if (*pending && mmc_card_broken_irq_polling(card) &&
45+
!(host->caps & MMC_CAP_SDIO_IRQ)) {
46+
unsigned char dummy;
47+
48+
/* A fake interrupt could be created when we poll SDIO_CCCR_INTx
49+
* register with a Marvell SD8797 card. A dummy CMD52 read to
50+
* function 0 register 0xff can avoid this.
51+
*/
52+
mmc_io_rw_direct(card, 0, 0, 0xff, 0, &dummy);
53+
}
54+
55+
return 0;
56+
}
57+
3058
static int process_sdio_pending_irqs(struct mmc_host *host)
3159
{
3260
struct mmc_card *card = host->card;
@@ -49,23 +77,9 @@ static int process_sdio_pending_irqs(struct mmc_host *host)
4977
return 1;
5078
}
5179

52-
ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending);
53-
if (ret) {
54-
pr_debug("%s: error %d reading SDIO_CCCR_INTx\n",
55-
mmc_card_id(card), ret);
80+
ret = sdio_get_pending_irqs(host, &pending);
81+
if (ret)
5682
return ret;
57-
}
58-
59-
if (pending && mmc_card_broken_irq_polling(card) &&
60-
!(host->caps & MMC_CAP_SDIO_IRQ)) {
61-
unsigned char dummy;
62-
63-
/* A fake interrupt could be created when we poll SDIO_CCCR_INTx
64-
* register with a Marvell SD8797 card. A dummy CMD52 read to
65-
* function 0 register 0xff can avoid this.
66-
*/
67-
mmc_io_rw_direct(card, 0, 0, 0xff, 0, &dummy);
68-
}
6983

7084
count = 0;
7185
for (i = 1; i <= 7; i++) {

0 commit comments

Comments
 (0)