mmc: use the generic error number
[oweals/u-boot.git] / drivers / mmc / sdhci.c
index 9fdbed8aa9e3471656a6de743591caba0cb985f7..1d6d2fde0d8489dba3490f4e1714b4b65631cb89 100644 (file)
@@ -170,7 +170,7 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
                                       cmd_timeout);
                        } else {
                                puts("timeout.\n");
-                               return COMM_ERR;
+                               return -ECOMM;
                        }
                }
                time++;
@@ -184,7 +184,8 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
                flags = SDHCI_CMD_RESP_LONG;
        else if (cmd->resp_type & MMC_RSP_BUSY) {
                flags = SDHCI_CMD_RESP_SHORT_BUSY;
-               mask |= SDHCI_INT_DATA_END;
+               if (data)
+                       mask |= SDHCI_INT_DATA_END;
        } else
                flags = SDHCI_CMD_RESP_SHORT;
 
@@ -252,17 +253,17 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
                stat = sdhci_readl(host, SDHCI_INT_STATUS);
                if (stat & SDHCI_INT_ERROR)
                        break;
-       } while (((stat & mask) != mask) &&
-                (get_timer(start) < SDHCI_READ_STATUS_TIMEOUT));
 
-       if (get_timer(start) >= SDHCI_READ_STATUS_TIMEOUT) {
-               if (host->quirks & SDHCI_QUIRK_BROKEN_R1B)
-                       return 0;
-               else {
-                       printf("%s: Timeout for status update!\n", __func__);
-                       return TIMEOUT;
+               if (get_timer(start) >= SDHCI_READ_STATUS_TIMEOUT) {
+                       if (host->quirks & SDHCI_QUIRK_BROKEN_R1B) {
+                               return 0;
+                       } else {
+                               printf("%s: Timeout for status update!\n",
+                                      __func__);
+                               return -ETIMEDOUT;
+                       }
                }
-       }
+       } while ((stat & mask) != mask);
 
        if ((stat & (SDHCI_INT_ERROR | mask)) == mask) {
                sdhci_cmd_done(host, cmd);
@@ -288,9 +289,9 @@ static int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
        sdhci_reset(host, SDHCI_RESET_CMD);
        sdhci_reset(host, SDHCI_RESET_DATA);
        if (stat & SDHCI_INT_TIMEOUT)
-               return TIMEOUT;
+               return -ETIMEDOUT;
        else
-               return COMM_ERR;
+               return -ECOMM;
 }
 
 static int sdhci_set_clock(struct mmc *mmc, unsigned int clock)