diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-04-26 08:19:42 +0300 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-05-08 19:07:26 +0300 |
commit | c900dff50cb7a6c21194aacd0ef2bfe734f7de8e (patch) | |
tree | 0f961a50051784d9ba38f7cdef31950e50070b31 | |
parent | ff17b78ed0e37eb288460d87873599eae748cde7 (diff) |
libmtd: rename num field
This is a preparation for the coming sysfs support.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r-- | ubi-utils/include/libmtd.h | 4 | ||||
-rw-r--r-- | ubi-utils/src/libmtd.c | 38 | ||||
-rw-r--r-- | ubi-utils/src/ubiformat.c | 12 |
3 files changed, 27 insertions, 27 deletions
diff --git a/ubi-utils/include/libmtd.h b/ubi-utils/include/libmtd.h index 242ecf5..d1290e0 100644 --- a/ubi-utils/include/libmtd.h +++ b/ubi-utils/include/libmtd.h @@ -29,7 +29,7 @@ extern "C" { /** * struct mtd_dev_info - information about an MTD device. - * @num: MTD device number + * @dev_num: MTD device number * @major: major number of corresponding character device * @minor: minor number of corresponding character device * @type: flash type (constants like %MTD_NANDFLASH defined in mtd-abi.h) @@ -44,7 +44,7 @@ extern "C" { */ struct mtd_dev_info { - int num; + int dev_num; int major; int minor; int type; diff --git a/ubi-utils/src/libmtd.c b/ubi-utils/src/libmtd.c index 7675dcd..086ee42 100644 --- a/ubi-utils/src/libmtd.c +++ b/ubi-utils/src/libmtd.c @@ -57,7 +57,7 @@ int mtd_get_dev_info(const char *node, struct mtd_dev_info *mtd) "major %d", node, mtd->major, MTD_DEV_MAJOR); } - mtd->num = mtd->minor / 2; + mtd->dev_num = mtd->minor / 2; mtd->writable = !(mtd->minor & 1); fd = open(node, O_RDWR); @@ -87,17 +87,17 @@ int mtd_get_dev_info(const char *node, struct mtd_dev_info *mtd) if (mtd->min_io_size <= 0) { errmsg("mtd%d (%s) has insane min. I/O unit size %d", - mtd->num, node, mtd->min_io_size); + mtd->dev_num, node, mtd->min_io_size); goto out_close; } if (mtd->eb_size <= 0 || mtd->eb_size < mtd->min_io_size) { errmsg("mtd%d (%s) has insane eraseblock size %d", - mtd->num, node, mtd->eb_size); + mtd->dev_num, node, mtd->eb_size); goto out_close; } if (mtd->size <= 0 || mtd->size < mtd->eb_size) { errmsg("mtd%d (%s) has insane size %lld", - mtd->num, node, mtd->size); + mtd->dev_num, node, mtd->size); goto out_close; } mtd->eb_cnt = mtd->size / mtd->eb_size; @@ -105,7 +105,7 @@ int mtd_get_dev_info(const char *node, struct mtd_dev_info *mtd) switch(mtd->type) { case MTD_ABSENT: errmsg("mtd%d (%s) is removable and is not present", - mtd->num, node); + mtd->dev_num, node); goto out_close; case MTD_RAM: mtd->type_str = "RAM-based"; @@ -157,7 +157,7 @@ int mtd_is_bad(const struct mtd_dev_info *mtd, int fd, int eb) if (eb < 0 || eb >= mtd->eb_cnt) { errmsg("bad eraseblock number %d, mtd%d has %d eraseblocks", - eb, mtd->num, mtd->eb_cnt); + eb, mtd->dev_num, mtd->eb_cnt); errno = EINVAL; return -1; } @@ -169,7 +169,7 @@ int mtd_is_bad(const struct mtd_dev_info *mtd, int fd, int eb) ret = ioctl(fd, MEMGETBADBLOCK, &seek); if (ret == -1) return sys_errmsg("MEMGETBADBLOCK ioctl failed for " - "eraseblock %d (mtd%d)", eb, mtd->num); + "eraseblock %d (mtd%d)", eb, mtd->dev_num); return ret; } @@ -185,7 +185,7 @@ int mtd_mark_bad(const struct mtd_dev_info *mtd, int fd, int eb) if (eb < 0 || eb >= mtd->eb_cnt) { errmsg("bad eraseblock number %d, mtd%d has %d eraseblocks", - eb, mtd->num, mtd->eb_cnt); + eb, mtd->dev_num, mtd->eb_cnt); errno = EINVAL; return -1; } @@ -194,7 +194,7 @@ int mtd_mark_bad(const struct mtd_dev_info *mtd, int fd, int eb) ret = ioctl(fd, MEMSETBADBLOCK, &seek); if (ret == -1) return sys_errmsg("MEMSETBADBLOCK ioctl failed for " - "eraseblock %d (mtd%d)", eb, mtd->num); + "eraseblock %d (mtd%d)", eb, mtd->dev_num); return 0; } @@ -206,13 +206,13 @@ int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs, if (eb < 0 || eb >= mtd->eb_cnt) { errmsg("bad eraseblock number %d, mtd%d has %d eraseblocks", - eb, mtd->num, mtd->eb_cnt); + eb, mtd->dev_num, mtd->eb_cnt); errno = EINVAL; return -1; } if (offs < 0 || offs + len > mtd->eb_size) { errmsg("bad offset %d or length %d, mtd%d eraseblock size is %d", - offs, len, mtd->num, mtd->eb_size); + offs, len, mtd->dev_num, mtd->eb_size); errno = EINVAL; return -1; } @@ -221,13 +221,13 @@ int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs, seek = (off_t)eb * mtd->eb_size + offs; if (lseek(fd, seek, SEEK_SET) != seek) return sys_errmsg("cannot seek mtd%d to offset %llu", - mtd->num, (unsigned long long)seek); + mtd->dev_num, (unsigned long long)seek); while (rd < len) { ret = read(fd, buf, len); if (ret < 0) return sys_errmsg("cannot read %d bytes from mtd%d (eraseblock %d, offset %d)", - len, mtd->num, eb, offs); + len, mtd->dev_num, eb, offs); rd += ret; } @@ -242,26 +242,26 @@ int mtd_write(const struct mtd_dev_info *mtd, int fd, int eb, int offs, if (eb < 0 || eb >= mtd->eb_cnt) { errmsg("bad eraseblock number %d, mtd%d has %d eraseblocks", - eb, mtd->num, mtd->eb_cnt); + eb, mtd->dev_num, mtd->eb_cnt); errno = EINVAL; return -1; } if (offs < 0 || offs + len > mtd->eb_size) { errmsg("bad offset %d or length %d, mtd%d eraseblock size is %d", - offs, len, mtd->num, mtd->eb_size); + offs, len, mtd->dev_num, mtd->eb_size); errno = EINVAL; return -1; } #if 0 if (offs % mtd->subpage_size) { errmsg("write offset %d is not aligned to mtd%d min. I/O size %d", - offs, mtd->num, mtd->subpage_size); + offs, mtd->dev_num, mtd->subpage_size); errno = EINVAL; return -1; } if (len % mtd->subpage_size) { errmsg("write length %d is not aligned to mtd%d min. I/O size %d", - len, mtd->num, mtd->subpage_size); + len, mtd->dev_num, mtd->subpage_size); errno = EINVAL; return -1; } @@ -271,12 +271,12 @@ int mtd_write(const struct mtd_dev_info *mtd, int fd, int eb, int offs, seek = (off_t)eb * mtd->eb_size + offs; if (lseek(fd, seek, SEEK_SET) != seek) return sys_errmsg("cannot seek mtd%d to offset %llu", - mtd->num, (unsigned long long)seek); + mtd->dev_num, (unsigned long long)seek); ret = write(fd, buf, len); if (ret != len) return sys_errmsg("cannot write %d bytes to mtd%d (eraseblock %d, offset %d)", - len, mtd->num, eb, offs); + len, mtd->dev_num, eb, offs); return 0; } diff --git a/ubi-utils/src/ubiformat.c b/ubi-utils/src/ubiformat.c index b64d187..1c201a6 100644 --- a/ubi-utils/src/ubiformat.c +++ b/ubi-utils/src/ubiformat.c @@ -733,7 +733,7 @@ int main(int argc, char * const argv[]) mtd.subpage_size = args.subpage_size; if (!mtd.writable) { - errmsg("mtd%d (%s) is a read-only device", mtd.num, args.node); + errmsg("mtd%d (%s) is a read-only device", mtd.dev_num, args.node); goto out; } @@ -742,17 +742,17 @@ int main(int argc, char * const argv[]) if (libubi) { int ubi_dev_num; - err = mtd_num2ubi_dev(libubi, mtd.num, &ubi_dev_num); + err = mtd_num2ubi_dev(libubi, mtd.dev_num, &ubi_dev_num); libubi_close(libubi); if (!err) { errmsg("please, first detach mtd%d (%s) from ubi%d", - mtd.num, args.node, ubi_dev_num); + mtd.dev_num, args.node, ubi_dev_num); goto out; } } if (!args.quiet) { - normsg_cont("mtd%d (%s), size ", mtd.num, mtd.type_str); + normsg_cont("mtd%d (%s), size ", mtd.dev_num, mtd.type_str); ubiutils_print_bytes(mtd.size, 1); printf(", %d eraseblocks of ", mtd.eb_size); ubiutils_print_bytes(mtd.eb_size, 1); @@ -767,7 +767,7 @@ int main(int argc, char * const argv[]) verbose = 1; err = ubi_scan(&mtd, args.node_fd, &si, verbose); if (err) { - errmsg("failed to scan mtd%d (%s)", mtd.num, args.node); + errmsg("failed to scan mtd%d (%s)", mtd.dev_num, args.node); goto out; } @@ -777,7 +777,7 @@ int main(int argc, char * const argv[]) } if (si->good_cnt < 2 && (!args.novtbl || args.image)) { - errmsg("too few non-bad eraseblocks (%d) on mtd%d", si->good_cnt, mtd.num); + errmsg("too few non-bad eraseblocks (%d) on mtd%d", si->good_cnt, mtd.dev_num); goto out_free; } |