Lines Matching defs:dfu

11 #include <dfu.h>
35 static int mtd_block_op(enum dfu_op op, struct dfu_entity *dfu,
39 struct mtd_info *mtd = dfu->data.mtd.info;
47 *len = dfu->data.mtd.size;
51 off = lock_ofs = dfu->data.mtd.start + offset + dfu->bad_skip;
52 lim = dfu->data.mtd.start + dfu->data.mtd.size;
154 dfu->bad_skip += mtd->erasesize;
160 else if (has_pages && dfu->data.mtd.ubi && mtd_page_is_empty(&io_op)) {
195 static int dfu_get_medium_size_mtd(struct dfu_entity *dfu, u64 *size)
197 *size = dfu->data.mtd.info->size;
202 static int dfu_read_medium_mtd(struct dfu_entity *dfu, u64 offset, void *buf,
207 switch (dfu->layout) {
209 ret = mtd_block_op(DFU_OP_READ, dfu, offset, buf, len);
213 dfu_get_layout(dfu->layout));
219 static int dfu_write_medium_mtd(struct dfu_entity *dfu,
224 switch (dfu->layout) {
226 ret = mtd_block_op(DFU_OP_WRITE, dfu, offset, buf, len);
230 dfu_get_layout(dfu->layout));
236 static int dfu_flush_medium_mtd(struct dfu_entity *dfu)
238 struct mtd_info *mtd = dfu->data.mtd.info;
243 if (dfu->data.mtd.ubi) {
246 erase_op.mtd = dfu->data.mtd.info;
247 erase_op.addr = round_up(dfu->data.mtd.start + dfu->offset +
248 dfu->bad_skip, mtd->erasesize);
252 remaining = dfu->data.mtd.start + dfu->data.mtd.size -
274 static unsigned int dfu_polltimeout_mtd(struct dfu_entity *dfu)
281 if (dfu->data.mtd.ubi)
287 int dfu_fill_entity_mtd(struct dfu_entity *dfu, char *devstr, char **argv, int argc)
298 dfu->dev_type = DFU_DEV_MTD;
299 dfu->data.mtd.info = mtd;
300 dfu->max_buf_size = mtd->erasesize;
307 dfu->layout = DFU_RAW_ADDR;
308 dfu->data.mtd.start = hextoul(argv[1], &s);
311 dfu->data.mtd.size = hextoul(argv[2], &s);
322 dfu->layout = DFU_RAW_ADDR;
345 dfu->data.mtd.start = partition->offset;
346 dfu->data.mtd.size = partition->size;
348 dfu->data.mtd.ubi = 1;
354 if (!mtd_is_aligned_with_block_size(mtd, dfu->data.mtd.start)) {
359 if (!mtd_is_aligned_with_block_size(mtd, dfu->data.mtd.size)) {
365 dfu->get_medium_size = dfu_get_medium_size_mtd;
366 dfu->read_medium = dfu_read_medium_mtd;
367 dfu->write_medium = dfu_write_medium_mtd;
368 dfu->flush_medium = dfu_flush_medium_mtd;
369 dfu->poll_timeout = dfu_polltimeout_mtd;
372 dfu->inited = 0;