Convert CONFIG_SYS_INTERLAKEN et al to Kconfig
[platform/kernel/u-boot.git] / cmd / read.c
index 8710288..fecfada 100644 (file)
 
 #include <common.h>
 #include <command.h>
+#include <mapmem.h>
 #include <part.h>
 
-int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+int do_read(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
        char *ep;
-       block_dev_desc_t *dev_desc = NULL;
+       struct blk_desc *dev_desc = NULL;
        int dev;
        int part = 0;
-       disk_partition_t part_info;
+       struct disk_partition part_info;
        ulong offset = 0u;
        ulong limit = 0u;
        void *addr;
@@ -30,34 +31,34 @@ int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                return 1;
        }
 
-       dev = (int)simple_strtoul(argv[2], &ep, 16);
+       dev = (int)hextoul(argv[2], &ep);
        if (*ep) {
                if (*ep != ':') {
                        printf("Invalid block device %s\n", argv[2]);
                        return 1;
                }
-               part = (int)simple_strtoul(++ep, NULL, 16);
+               part = (int)hextoul(++ep, NULL);
        }
 
-       dev_desc = get_dev(argv[1], dev);
+       dev_desc = blk_get_dev(argv[1], dev);
        if (dev_desc == NULL) {
                printf("Block device %s %d not supported\n", argv[1], dev);
                return 1;
        }
 
-       addr = (void *)simple_strtoul(argv[3], NULL, 16);
-       blk = simple_strtoul(argv[4], NULL, 16);
-       cnt = simple_strtoul(argv[5], NULL, 16);
+       addr = map_sysmem(hextoul(argv[3], NULL), 0);
+       blk = hextoul(argv[4], NULL);
+       cnt = hextoul(argv[5], NULL);
 
        if (part != 0) {
-               if (get_partition_info(dev_desc, part, &part_info)) {
+               if (part_get_info(dev_desc, part, &part_info)) {
                        printf("Cannot find partition %d\n", part);
                        return 1;
                }
                offset = part_info.start;
                limit = part_info.size;
        } else {
-               /* Largest address not available in block_dev_desc_t. */
+               /* Largest address not available in struct blk_desc. */
                limit = ~0;
        }
 
@@ -66,7 +67,7 @@ int do_read(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                return 1;
        }
 
-       if (dev_desc->block_read(dev_desc, offset + blk, cnt, addr) < 0) {
+       if (blk_dread(dev_desc, offset + blk, cnt, addr) != cnt) {
                printf("Error reading blocks\n");
                return 1;
        }