mkimage: fix argument parsing on BSD systems
[oweals/u-boot.git] / cmd / sata.c
index 76baceae8c939eff77fcd45d46c820f3feb8a5d5..8748ccef69685fee1b250633118f908fac69db5c 100644 (file)
 #include <sata.h>
 
 static int sata_curr_device = -1;
-block_dev_desc_t sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE];
+struct blk_desc sata_dev_desc[CONFIG_SYS_SATA_MAX_DEVICE];
 
-static unsigned long sata_bread(block_dev_desc_t *block_dev, lbaint_t start,
+static unsigned long sata_bread(struct blk_desc *block_dev, lbaint_t start,
                                lbaint_t blkcnt, void *dst)
 {
-       return sata_read(block_dev->dev, start, blkcnt, dst);
+       return sata_read(block_dev->devnum, start, blkcnt, dst);
 }
 
-static unsigned long sata_bwrite(block_dev_desc_t *block_dev, lbaint_t start,
+static unsigned long sata_bwrite(struct blk_desc *block_dev, lbaint_t start,
                                 lbaint_t blkcnt, const void *buffer)
 {
-       return sata_write(block_dev->dev, start, blkcnt, buffer);
+       return sata_write(block_dev->devnum, start, blkcnt, buffer);
 }
 
 int __sata_initialize(void)
@@ -36,9 +36,9 @@ int __sata_initialize(void)
        int i;
 
        for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) {
-               memset(&sata_dev_desc[i], 0, sizeof(struct block_dev_desc));
+               memset(&sata_dev_desc[i], 0, sizeof(struct blk_desc));
                sata_dev_desc[i].if_type = IF_TYPE_SATA;
-               sata_dev_desc[i].dev = i;
+               sata_dev_desc[i].devnum = i;
                sata_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
                sata_dev_desc[i].type = DEV_TYPE_HARDDISK;
                sata_dev_desc[i].lba = 0;
@@ -52,7 +52,7 @@ int __sata_initialize(void)
                        rc = scan_sata(i);
                        if (!rc && (sata_dev_desc[i].lba > 0) &&
                                (sata_dev_desc[i].blksz > 0))
-                               init_part(&sata_dev_desc[i]);
+                               part_init(&sata_dev_desc[i]);
                }
        }
        sata_curr_device = 0;
@@ -75,7 +75,7 @@ __weak int __sata_stop(void)
 int sata_stop(void) __attribute__((weak, alias("__sata_stop")));
 
 #ifdef CONFIG_PARTITIONS
-block_dev_desc_t *sata_get_dev(int dev)
+struct blk_desc *sata_get_dev(int dev)
 {
        return (dev < CONFIG_SYS_SATA_MAX_DEVICE) ? &sata_dev_desc[dev] : NULL;
 }
@@ -131,7 +131,7 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                                        ++ok;
                                        if (dev)
                                                putc ('\n');
-                                       print_part(&sata_dev_desc[dev]);
+                                       part_print(&sata_dev_desc[dev]);
                                }
                        }
                        if (!ok) {
@@ -164,7 +164,7 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        int dev = (int)simple_strtoul(argv[2], NULL, 10);
 
                        if (sata_dev_desc[dev].part_type != PART_TYPE_UNKNOWN) {
-                               print_part(&sata_dev_desc[dev]);
+                               part_print(&sata_dev_desc[dev]);
                        } else {
                                printf("\nSATA device %d not available\n", dev);
                                rc = 1;
@@ -183,7 +183,8 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        printf("\nSATA read: device %d block # %ld, count %ld ... ",
                                sata_curr_device, blk, cnt);
 
-                       n = sata_read(sata_curr_device, blk, cnt, (u32 *)addr);
+                       n = blk_dread(&sata_dev_desc[sata_curr_device],
+                                     blk, cnt, (u32 *)addr);
 
                        /* flush cache after read */
                        flush_cache(addr, cnt * sata_dev_desc[sata_curr_device].blksz);
@@ -201,7 +202,8 @@ static int do_sata(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        printf("\nSATA write: device %d block # %ld, count %ld ... ",
                                sata_curr_device, blk, cnt);
 
-                       n = sata_write(sata_curr_device, blk, cnt, (u32 *)addr);
+                       n = blk_dwrite(&sata_dev_desc[sata_curr_device],
+                                      blk, cnt, (u32 *)addr);
 
                        printf("%ld blocks written: %s\n",
                                n, (n == cnt) ? "OK" : "ERROR");