aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host/tifm_sd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/host/tifm_sd.c')
-rw-r--r--drivers/mmc/host/tifm_sd.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c
index 8b736e968447..9b904795eb77 100644
--- a/drivers/mmc/host/tifm_sd.c
+++ b/drivers/mmc/host/tifm_sd.c
@@ -16,6 +16,7 @@
16#include <linux/mmc/host.h> 16#include <linux/mmc/host.h>
17#include <linux/highmem.h> 17#include <linux/highmem.h>
18#include <linux/scatterlist.h> 18#include <linux/scatterlist.h>
19#include <linux/log2.h>
19#include <asm/io.h> 20#include <asm/io.h>
20 21
21#define DRIVER_NAME "tifm_sd" 22#define DRIVER_NAME "tifm_sd"
@@ -404,14 +405,14 @@ static void tifm_sd_check_status(struct tifm_sd *host)
404 struct tifm_dev *sock = host->dev; 405 struct tifm_dev *sock = host->dev;
405 struct mmc_command *cmd = host->req->cmd; 406 struct mmc_command *cmd = host->req->cmd;
406 407
407 if (cmd->error != MMC_ERR_NONE) 408 if (cmd->error)
408 goto finish_request; 409 goto finish_request;
409 410
410 if (!(host->cmd_flags & CMD_READY)) 411 if (!(host->cmd_flags & CMD_READY))
411 return; 412 return;
412 413
413 if (cmd->data) { 414 if (cmd->data) {
414 if (cmd->data->error != MMC_ERR_NONE) { 415 if (cmd->data->error) {
415 if ((host->cmd_flags & SCMD_ACTIVE) 416 if ((host->cmd_flags & SCMD_ACTIVE)
416 && !(host->cmd_flags & SCMD_READY)) 417 && !(host->cmd_flags & SCMD_READY))
417 return; 418 return;
@@ -504,7 +505,7 @@ static void tifm_sd_card_event(struct tifm_dev *sock)
504{ 505{
505 struct tifm_sd *host; 506 struct tifm_sd *host;
506 unsigned int host_status = 0; 507 unsigned int host_status = 0;
507 int cmd_error = MMC_ERR_NONE; 508 int cmd_error = 0;
508 struct mmc_command *cmd = NULL; 509 struct mmc_command *cmd = NULL;
509 unsigned long flags; 510 unsigned long flags;
510 511
@@ -521,15 +522,15 @@ static void tifm_sd_card_event(struct tifm_dev *sock)
521 writel(host_status & TIFM_MMCSD_ERRMASK, 522 writel(host_status & TIFM_MMCSD_ERRMASK,
522 sock->addr + SOCK_MMCSD_STATUS); 523 sock->addr + SOCK_MMCSD_STATUS);
523 if (host_status & TIFM_MMCSD_CTO) 524 if (host_status & TIFM_MMCSD_CTO)
524 cmd_error = MMC_ERR_TIMEOUT; 525 cmd_error = -ETIMEDOUT;
525 else if (host_status & TIFM_MMCSD_CCRC) 526 else if (host_status & TIFM_MMCSD_CCRC)
526 cmd_error = MMC_ERR_BADCRC; 527 cmd_error = -EILSEQ;
527 528
528 if (cmd->data) { 529 if (cmd->data) {
529 if (host_status & TIFM_MMCSD_DTO) 530 if (host_status & TIFM_MMCSD_DTO)
530 cmd->data->error = MMC_ERR_TIMEOUT; 531 cmd->data->error = -ETIMEDOUT;
531 else if (host_status & TIFM_MMCSD_DCRC) 532 else if (host_status & TIFM_MMCSD_DCRC)
532 cmd->data->error = MMC_ERR_BADCRC; 533 cmd->data->error = -EILSEQ;
533 } 534 }
534 535
535 writel(TIFM_FIFO_INT_SETALL, 536 writel(TIFM_FIFO_INT_SETALL,
@@ -626,14 +627,21 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
626 627
627 spin_lock_irqsave(&sock->lock, flags); 628 spin_lock_irqsave(&sock->lock, flags);
628 if (host->eject) { 629 if (host->eject) {
629 spin_unlock_irqrestore(&sock->lock, flags); 630 mrq->cmd->error = -ENOMEDIUM;
630 goto err_out; 631 goto err_out;
631 } 632 }
632 633
633 if (host->req) { 634 if (host->req) {
634 printk(KERN_ERR "%s : unfinished request detected\n", 635 printk(KERN_ERR "%s : unfinished request detected\n",
635 sock->dev.bus_id); 636 sock->dev.bus_id);
636 spin_unlock_irqrestore(&sock->lock, flags); 637 mrq->cmd->error = -ETIMEDOUT;
638 goto err_out;
639 }
640
641 if (mrq->data && !is_power_of_2(mrq->data->blksz)) {
642 printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n",
643 sock->dev.bus_id, mrq->data->blksz);
644 mrq->cmd->error = -EINVAL;
637 goto err_out; 645 goto err_out;
638 } 646 }
639 647
@@ -722,7 +730,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
722 return; 730 return;
723 731
724err_out: 732err_out:
725 mrq->cmd->error = MMC_ERR_TIMEOUT; 733 spin_unlock_irqrestore(&sock->lock, flags);
726 mmc_request_done(mmc, mrq); 734 mmc_request_done(mmc, mrq);
727} 735}
728 736
@@ -1012,9 +1020,9 @@ static void tifm_sd_remove(struct tifm_dev *sock)
1012 writel(TIFM_FIFO_INT_SETALL, 1020 writel(TIFM_FIFO_INT_SETALL,
1013 sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR); 1021 sock->addr + SOCK_DMA_FIFO_INT_ENABLE_CLEAR);
1014 writel(0, sock->addr + SOCK_DMA_FIFO_INT_ENABLE_SET); 1022 writel(0, sock->addr + SOCK_DMA_FIFO_INT_ENABLE_SET);
1015 host->req->cmd->error = MMC_ERR_TIMEOUT; 1023 host->req->cmd->error = -ENOMEDIUM;
1016 if (host->req->stop) 1024 if (host->req->stop)
1017 host->req->stop->error = MMC_ERR_TIMEOUT; 1025 host->req->stop->error = -ENOMEDIUM;
1018 tasklet_schedule(&host->finish_tasklet); 1026 tasklet_schedule(&host->finish_tasklet);
1019 } 1027 }
1020 spin_unlock_irqrestore(&sock->lock, flags); 1028 spin_unlock_irqrestore(&sock->lock, flags);