]> www.infradead.org Git - mtd-utils.git/commitdiff
libmtd: rename num field
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sun, 26 Apr 2009 05:19:42 +0000 (08:19 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 8 May 2009 16:07:26 +0000 (19:07 +0300)
This is a preparation for the coming sysfs support.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/include/libmtd.h
ubi-utils/src/libmtd.c
ubi-utils/src/ubiformat.c

index 242ecf5a56cd1fd701813eaf41eb0561c221472f..d1290e0e934654e81f05106f225ebd5fd5a95742 100644 (file)
@@ -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;
index 7675dcd73dfa080015f64c425162c75705dafcb2..086ee428a7bf181b545da484b69177cba1569491 100644 (file)
@@ -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;
 }
index b64d187d8d82b32254d1cb79e8aceae8ce03a857..1c201a62e70f16e32de83e5e962343d113a4af82 100644 (file)
@@ -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;
        }