diff options
author | Ulf Hansson <ulf.hansson@linaro.org> | 2014-01-28 08:05:39 -0500 |
---|---|---|
committer | Chris Ball <chris@printf.net> | 2014-02-23 10:40:34 -0500 |
commit | 636bd13c12d2331ad835b89681428eccb4cf102e (patch) | |
tree | 83fcd92867bfbb3fa61c71ba4eea3f8b0e3b14bb /drivers/mmc | |
parent | 4509f847751c9d2a724f37fe831393fbac34b80f (diff) |
mmc: core: Minor simplifications to __mmc_switch
Instead of using several references to card->host, let's use a local
variable. That means we can remove the BUG_ON verifications for the
same pointers.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/core/mmc_ops.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 5e1a2cbdc229..04ecdb913aa0 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c | |||
@@ -413,14 +413,12 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, | |||
413 | unsigned int timeout_ms, bool use_busy_signal, bool send_status, | 413 | unsigned int timeout_ms, bool use_busy_signal, bool send_status, |
414 | bool ignore_crc) | 414 | bool ignore_crc) |
415 | { | 415 | { |
416 | struct mmc_host *host = card->host; | ||
416 | int err; | 417 | int err; |
417 | struct mmc_command cmd = {0}; | 418 | struct mmc_command cmd = {0}; |
418 | unsigned long timeout; | 419 | unsigned long timeout; |
419 | u32 status = 0; | 420 | u32 status = 0; |
420 | 421 | ||
421 | BUG_ON(!card); | ||
422 | BUG_ON(!card->host); | ||
423 | |||
424 | cmd.opcode = MMC_SWITCH; | 422 | cmd.opcode = MMC_SWITCH; |
425 | cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) | | 423 | cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) | |
426 | (index << 16) | | 424 | (index << 16) | |
@@ -437,7 +435,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, | |||
437 | if (index == EXT_CSD_SANITIZE_START) | 435 | if (index == EXT_CSD_SANITIZE_START) |
438 | cmd.sanitize_busy = true; | 436 | cmd.sanitize_busy = true; |
439 | 437 | ||
440 | err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES); | 438 | err = mmc_wait_for_cmd(host, &cmd, MMC_CMD_RETRIES); |
441 | if (err) | 439 | if (err) |
442 | return err; | 440 | return err; |
443 | 441 | ||
@@ -449,7 +447,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, | |||
449 | * CRC errors shall only be ignored in cases were CMD13 is used to poll | 447 | * CRC errors shall only be ignored in cases were CMD13 is used to poll |
450 | * to detect busy completion. | 448 | * to detect busy completion. |
451 | */ | 449 | */ |
452 | if (card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) | 450 | if (host->caps & MMC_CAP_WAIT_WHILE_BUSY) |
453 | ignore_crc = false; | 451 | ignore_crc = false; |
454 | 452 | ||
455 | /* Must check status to be sure of no errors. */ | 453 | /* Must check status to be sure of no errors. */ |
@@ -460,9 +458,9 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, | |||
460 | if (err) | 458 | if (err) |
461 | return err; | 459 | return err; |
462 | } | 460 | } |
463 | if (card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) | 461 | if (host->caps & MMC_CAP_WAIT_WHILE_BUSY) |
464 | break; | 462 | break; |
465 | if (mmc_host_is_spi(card->host)) | 463 | if (mmc_host_is_spi(host)) |
466 | break; | 464 | break; |
467 | 465 | ||
468 | /* | 466 | /* |
@@ -478,18 +476,18 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, | |||
478 | /* Timeout if the device never leaves the program state. */ | 476 | /* Timeout if the device never leaves the program state. */ |
479 | if (time_after(jiffies, timeout)) { | 477 | if (time_after(jiffies, timeout)) { |
480 | pr_err("%s: Card stuck in programming state! %s\n", | 478 | pr_err("%s: Card stuck in programming state! %s\n", |
481 | mmc_hostname(card->host), __func__); | 479 | mmc_hostname(host), __func__); |
482 | return -ETIMEDOUT; | 480 | return -ETIMEDOUT; |
483 | } | 481 | } |
484 | } while (R1_CURRENT_STATE(status) == R1_STATE_PRG); | 482 | } while (R1_CURRENT_STATE(status) == R1_STATE_PRG); |
485 | 483 | ||
486 | if (mmc_host_is_spi(card->host)) { | 484 | if (mmc_host_is_spi(host)) { |
487 | if (status & R1_SPI_ILLEGAL_COMMAND) | 485 | if (status & R1_SPI_ILLEGAL_COMMAND) |
488 | return -EBADMSG; | 486 | return -EBADMSG; |
489 | } else { | 487 | } else { |
490 | if (status & 0xFDFFA000) | 488 | if (status & 0xFDFFA000) |
491 | pr_warning("%s: unexpected status %#x after " | 489 | pr_warn("%s: unexpected status %#x after switch\n", |
492 | "switch", mmc_hostname(card->host), status); | 490 | mmc_hostname(host), status); |
493 | if (status & R1_SWITCH_ERROR) | 491 | if (status & R1_SWITCH_ERROR) |
494 | return -EBADMSG; | 492 | return -EBADMSG; |
495 | } | 493 | } |