]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_mmc.c
block: pass block dev not num to read/write/erase()
[u-boot] / common / cmd_mmc.c
index 4e28c9d7a4d6541f0c1633ee494b77e476b5e776..6b5c1ac1109eb6e10c27ad7fb88ddd0e8a8fa2f8 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <console.h>
 #include <mmc.h>
 
 static int curr_device = -1;
@@ -85,8 +86,12 @@ static void print_mmcinfo(struct mmc *mmc)
        printf("Tran Speed: %d\n", mmc->tran_speed);
        printf("Rd Block Len: %d\n", mmc->read_bl_len);
 
-       printf("%s version %d.%d\n", IS_SD(mmc) ? "SD" : "MMC",
-                       (mmc->version >> 8) & 0xf, mmc->version & 0xff);
+       printf("%s version %d.%d", IS_SD(mmc) ? "SD" : "MMC",
+                       EXTRACT_SDMMC_MAJOR_VERSION(mmc->version),
+                       EXTRACT_SDMMC_MINOR_VERSION(mmc->version));
+       if (EXTRACT_SDMMC_CHANGE_VERSION(mmc->version) != 0)
+               printf(".%d", EXTRACT_SDMMC_CHANGE_VERSION(mmc->version));
+       printf("\n");
 
        printf("High Capacity: %s\n", mmc->high_capacity ? "Yes" : "No");
        puts("Capacity: ");
@@ -346,7 +351,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
        printf("\nMMC read: dev # %d, block # %d, count %d ... ",
               curr_device, blk, cnt);
 
-       n = mmc->block_dev.block_read(curr_device, blk, cnt, addr);
+       n = mmc->block_dev.block_read(&mmc->block_dev, blk, cnt, addr);
        /* flush cache after read */
        flush_cache((ulong)addr, cnt * 512); /* FIXME */
        printf("%d blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR");
@@ -378,7 +383,7 @@ static int do_mmc_write(cmd_tbl_t *cmdtp, int flag,
                printf("Error: card is write protected!\n");
                return CMD_RET_FAILURE;
        }
-       n = mmc->block_dev.block_write(curr_device, blk, cnt, addr);
+       n = mmc->block_dev.block_write(&mmc->block_dev, blk, cnt, addr);
        printf("%d blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR");
 
        return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
@@ -406,7 +411,7 @@ static int do_mmc_erase(cmd_tbl_t *cmdtp, int flag,
                printf("Error: card is write protected!\n");
                return CMD_RET_FAILURE;
        }
-       n = mmc->block_dev.block_erase(curr_device, blk, cnt);
+       n = mmc->block_dev.block_erase(&mmc->block_dev, blk, cnt);
        printf("%d blocks erased: %s\n", n, (n == cnt) ? "OK" : "ERROR");
 
        return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
@@ -742,7 +747,7 @@ static int do_mmc_rst_func(cmd_tbl_t *cmdtp, int flag,
        dev = simple_strtoul(argv[1], NULL, 10);
        enable = simple_strtoul(argv[2], NULL, 10);
 
-       if (enable > 2 || enable < 0) {
+       if (enable > 2) {
                puts("Invalid RST_n_ENABLE value\n");
                return CMD_RET_USAGE;
        }