aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/mmc_ops.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2015-05-07 06:10:19 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2015-06-01 03:06:56 -0400
commited16f58dc00d47439c201ab18ca4d981210bcafd (patch)
tree469b5c2f61723e8bd9894234778b3a5b48daef24 /drivers/mmc/core/mmc_ops.c
parent436f8daa6f5a2943a20df8f3447da250b46f0d87 (diff)
mmc: core: Separate out the mmc_switch status check so it can be re-used
Make a separate function to do the mmc_switch status check so it can be re-used. This is preparation for adding support for HS400 re-tuning. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc/core/mmc_ops.c')
-rw-r--r--drivers/mmc/core/mmc_ops.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 4cad5f02837c..0e9ae1c276c8 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -450,6 +450,21 @@ int mmc_spi_set_crc(struct mmc_host *host, int use_crc)
450 return err; 450 return err;
451} 451}
452 452
453int mmc_switch_status_error(struct mmc_host *host, u32 status)
454{
455 if (mmc_host_is_spi(host)) {
456 if (status & R1_SPI_ILLEGAL_COMMAND)
457 return -EBADMSG;
458 } else {
459 if (status & 0xFDFFA000)
460 pr_warn("%s: unexpected status %#x after switch\n",
461 mmc_hostname(host), status);
462 if (status & R1_SWITCH_ERROR)
463 return -EBADMSG;
464 }
465 return 0;
466}
467
453/** 468/**
454 * __mmc_switch - modify EXT_CSD register 469 * __mmc_switch - modify EXT_CSD register
455 * @card: the MMC card associated with the data transfer 470 * @card: the MMC card associated with the data transfer
@@ -558,20 +573,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
558 } 573 }
559 } while (R1_CURRENT_STATE(status) == R1_STATE_PRG); 574 } while (R1_CURRENT_STATE(status) == R1_STATE_PRG);
560 575
561 if (mmc_host_is_spi(host)) { 576 err = mmc_switch_status_error(host, status);
562 if (status & R1_SPI_ILLEGAL_COMMAND) {
563 err = -EBADMSG;
564 goto out;
565 }
566 } else {
567 if (status & 0xFDFFA000)
568 pr_warn("%s: unexpected status %#x after switch\n",
569 mmc_hostname(host), status);
570 if (status & R1_SWITCH_ERROR) {
571 err = -EBADMSG;
572 goto out;
573 }
574 }
575out: 577out:
576 mmc_retune_release(host); 578 mmc_retune_release(host);
577 579