aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVenkatraman S <svenkatr@ti.com>2012-08-09 11:06:07 -0400
committerChris Ball <cjb@laptop.org>2012-09-04 13:58:24 -0400
commitae4bf788ee9bf7c2d51b0309117d1fcccbdd50a2 (patch)
tree6b1f9d252d3cbb32252dd1749c213f101157095b
parent1f6b9fa40e76fffaaa0b3bd6a0bfdcf1cdc06efa (diff)
mmc: omap_hsmmc: consolidate error report handling of HSMMC IRQ
Consolidate the duplicated code around the handling of CMD_TIMEOUT, CMD_CRC, DATA_TIMEOUT, DATA_CRC and CARD_ERR handling into a single function. This generally shrinks code bloat, but is also required for implementing software based guard timers. Signed-off-by: Venkatraman S <svenkatr@ti.com> Acked-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r--drivers/mmc/host/omap_hsmmc.c63
1 files changed, 21 insertions, 42 deletions
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 20453c82d0f2..9afdd202b873 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -964,6 +964,18 @@ static inline void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host,
964 __func__); 964 __func__);
965} 965}
966 966
967static void hsmmc_command_incomplete(struct omap_hsmmc_host *host, int err)
968{
969 omap_hsmmc_reset_controller_fsm(host, SRC);
970 host->cmd->error = err;
971
972 if (host->data) {
973 omap_hsmmc_reset_controller_fsm(host, SRD);
974 omap_hsmmc_dma_cleanup(host, err);
975 }
976
977}
978
967static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status) 979static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status)
968{ 980{
969 struct mmc_data *data; 981 struct mmc_data *data;
@@ -974,48 +986,15 @@ static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status)
974 986
975 if (status & ERR) { 987 if (status & ERR) {
976 omap_hsmmc_dbg_report_irq(host, status); 988 omap_hsmmc_dbg_report_irq(host, status);
977 if ((status & CMD_TIMEOUT) || 989 if (status & (CMD_TIMEOUT | DATA_TIMEOUT))
978 (status & CMD_CRC)) { 990 hsmmc_command_incomplete(host, -ETIMEDOUT);
979 if (host->cmd) { 991 else if (status & (CMD_CRC | DATA_CRC))
980 if (status & CMD_TIMEOUT) { 992 hsmmc_command_incomplete(host, -EILSEQ);
981 omap_hsmmc_reset_controller_fsm(host, 993
982 SRC); 994 end_cmd = 1;
983 host->cmd->error = -ETIMEDOUT; 995 if (host->data || host->response_busy) {
984 } else { 996 end_trans = 1;
985 host->cmd->error = -EILSEQ; 997 host->response_busy = 0;
986 }
987 end_cmd = 1;
988 }
989 if (host->data || host->response_busy) {
990 if (host->data)
991 omap_hsmmc_dma_cleanup(host,
992 -ETIMEDOUT);
993 host->response_busy = 0;
994 omap_hsmmc_reset_controller_fsm(host, SRD);
995 }
996 }
997 if ((status & DATA_TIMEOUT) ||
998 (status & DATA_CRC)) {
999 if (host->data || host->response_busy) {
1000 int err = (status & DATA_TIMEOUT) ?
1001 -ETIMEDOUT : -EILSEQ;
1002
1003 if (host->data)
1004 omap_hsmmc_dma_cleanup(host, err);
1005 else
1006 host->mrq->cmd->error = err;
1007 host->response_busy = 0;
1008 omap_hsmmc_reset_controller_fsm(host, SRD);
1009 end_trans = 1;
1010 }
1011 }
1012 if (status & CARD_ERR) {
1013 dev_dbg(mmc_dev(host->mmc),
1014 "Ignoring card err CMD%d\n", host->cmd->opcode);
1015 if (host->cmd)
1016 end_cmd = 1;
1017 if (host->data)
1018 end_trans = 1;
1019 } 998 }
1020 } 999 }
1021 1000