Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Adrian Hunter and committed by
Ulf Hansson
ed16f58d 436f8daa

+17 -14
+16 -14
drivers/mmc/core/mmc_ops.c
··· 450 450 return err; 451 451 } 452 452 453 + int 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 469 * __mmc_switch - modify EXT_CSD register 455 470 * @card: the MMC card associated with the data transfer ··· 573 558 } 574 559 } while (R1_CURRENT_STATE(status) == R1_STATE_PRG); 575 560 576 - if (mmc_host_is_spi(host)) { 577 - if (status & R1_SPI_ILLEGAL_COMMAND) { 578 - err = -EBADMSG; 579 - goto out; 580 - } 581 - } else { 582 - if (status & 0xFDFFA000) 583 - pr_warn("%s: unexpected status %#x after switch\n", 584 - mmc_hostname(host), status); 585 - if (status & R1_SWITCH_ERROR) { 586 - err = -EBADMSG; 587 - goto out; 588 - } 589 - } 561 + err = mmc_switch_status_error(host, status); 590 562 out: 591 563 mmc_retune_release(host); 592 564
+1
drivers/mmc/core/mmc_ops.h
··· 27 27 int mmc_bus_test(struct mmc_card *card, u8 bus_width); 28 28 int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status); 29 29 int mmc_can_ext_csd(struct mmc_card *card); 30 + int mmc_switch_status_error(struct mmc_host *host, u32 status); 30 31 31 32 #endif 32 33