Merge branch 'master' of git://git.denx.de/u-boot-arm
[platform/kernel/u-boot.git] / drivers / dfu / dfu_mmc.c
index 0871a77..0816f46 100644 (file)
 #include <div64.h>
 #include <dfu.h>
 
-enum dfu_mmc_op {
-       DFU_OP_READ = 1,
-       DFU_OP_WRITE,
-};
-
 static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE)
                                dfu_file_buf[CONFIG_SYS_DFU_MAX_FILE_SIZE];
 static long dfu_file_buf_len;
 
-static int mmc_block_op(enum dfu_mmc_op op, struct dfu_entity *dfu,
+static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu,
                        u64 offset, void *buf, long *len)
 {
        char cmd_buf[DFU_CMD_BUF_SIZE];
@@ -65,7 +60,7 @@ static int mmc_file_buffer(struct dfu_entity *dfu, void *buf, long *len)
        return 0;
 }
 
-static int mmc_file_op(enum dfu_mmc_op op, struct dfu_entity *dfu,
+static int mmc_file_op(enum dfu_op op, struct dfu_entity *dfu,
                        void *buf, long *len)
 {
        char cmd_buf[DFU_CMD_BUF_SIZE];
@@ -78,16 +73,12 @@ static int mmc_file_op(enum dfu_mmc_op op, struct dfu_entity *dfu,
                        op == DFU_OP_READ ? "load" : "write",
                        dfu->data.mmc.dev, dfu->data.mmc.part,
                        (unsigned int) buf, dfu->name);
-               if (op == DFU_OP_WRITE)
-                       sprintf(cmd_buf + strlen(cmd_buf), " %lx", *len);
                break;
        case DFU_FS_EXT4:
                sprintf(cmd_buf, "ext4%s mmc %d:%d 0x%x /%s",
                        op == DFU_OP_READ ? "load" : "write",
                        dfu->data.mmc.dev, dfu->data.mmc.part,
                        (unsigned int) buf, dfu->name);
-               if (op == DFU_OP_WRITE)
-                       sprintf(cmd_buf + strlen(cmd_buf), " %ld", *len);
                break;
        default:
                printf("%s: Layout (%s) not (yet) supported!\n", __func__,
@@ -95,6 +86,9 @@ static int mmc_file_op(enum dfu_mmc_op op, struct dfu_entity *dfu,
                return -1;
        }
 
+       if (op == DFU_OP_WRITE)
+               sprintf(cmd_buf + strlen(cmd_buf), " %lx", *len);
+
        debug("%s: %s 0x%p\n", __func__, cmd_buf, cmd_buf);
 
        ret = run_command(cmd_buf, 0);