]> www.infradead.org Git - mtd-utils.git/commitdiff
ubi-utils: harmonize mtd device node variables
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 15 Jun 2010 10:03:14 +0000 (13:03 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 15 Jun 2010 10:04:54 +0000 (13:04 +0300)
Consistently use 'mtd_dev_node' to name variables consining
MTD device node path.

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

index ffc4be9dcbd776a17ff81a08e7badb6f8bbf79a2..03b16adb84f293617f2af221fbe001e6cd7af677 100644 (file)
@@ -43,8 +43,8 @@ typedef void * libubi_t;
  * @dev_num: number to assign to the newly created UBI device
  *           (%UBI_DEV_NUM_AUTO should be used to automatically assign the
  *           number)
- * @mtd_num: MTD device number to attach (used if @dev is %NULL)
- * @dev: path to MTD device node to attach
+ * @mtd_num: MTD device number to attach (used if @mtd_dev_node is %NULL)
+ * @mtd_dev_node: path to MTD device node to attach
  * @vid_hdr_offset: VID header offset (%0 means default offset and this is what
  *                  most of the users want)
  */
@@ -52,7 +52,7 @@ struct ubi_attach_request
 {
        int dev_num;
        int mtd_num;
-       const char *dev;
+       const char *mtd_dev_node;
        int vid_hdr_offset;
 };
 
@@ -226,9 +226,9 @@ int ubi_attach_mtd(libubi_t desc, const char *node,
  * @req: MTD attach request
  *
  * This function creates new UBI device by attaching an MTD device described by
- * @req. If @req->dev is given it should contain path to the MTD device node.
- * Otherwise functionality is similar than in function 'ubi_attach_mtd()' where
- * @req->mtd_num is used.
+ * @req. If @req->mtd_dev_node is given it should contain path to the MTD
+ * device node. Otherwise functionality is similar than in function
+ * 'ubi_attach_mtd()' where @req->mtd_num is used.
  *
  * Returns %0 in case of success and %-1 in case of failure (errno is set). The
  * newly created UBI device number is returned in @req->dev_num.
@@ -252,12 +252,12 @@ int ubi_detach_mtd(libubi_t desc, const char *node, int mtd_num);
  * ubi_detach - detach an MTD device by its node path.
  * @desc: UBI library descriptor
  * @node: name of the UBI control character device node
- * @dev: path to an MTD device node
+ * @mtd_dev_node: path to an MTD device node
  *
- * This function detaches an MTD device @dev from UBI. Returns zero in case of
- * success and %-1 in case of failure.
+ * This function detaches an MTD device @mtd_dev_node from UBI. Returns zero in
+ * case of success and %-1 in case of failure.
  */
-int ubi_detach(libubi_t desc, const char *node, const char *dev);
+int ubi_detach(libubi_t desc, const char *node, const char *mtd_dev_node);
 
 /**
  * ubi_remove_dev - remove an UBI device.
index 3fe7956e0ffdd199546755716a8aa848520a8721..2eab3bae4e58643e4dcc74e4bd1001e7995de0c5 100644 (file)
@@ -736,24 +736,25 @@ int ubi_attach_mtd(libubi_t desc, const char *node,
 #endif
 
 /**
- * dev_to_mtdnum - converts device node to MTD number.
- * @dev: path to device node to convert
+ * mtd_node_to_num - converts device node to MTD number.
+ * @mtd_dev_node: path to device node to convert
  *
- * This function converts given @dev to MTD device number. @dev should contain
- * path to the MTD device node. Returns MTD device number in case of success and
- * %-1 in case of failure (errno is set).
+ * This function converts given @mtd_dev_node to MTD device number.
+ * @mtd_dev_node should contain path to the MTD device node. Returns MTD device
+ * number in case of success and %-1 in case of failure (errno is set).
  */
-static int dev_to_mtdnum(const char *dev)
+static int mtd_node_to_num(const char *mtd_dev_node)
 {
        int major, minor;
        struct stat sb;
 
-       if (stat(dev, &sb) < 0)
-               return sys_errmsg("cannot stat \"%s\"", dev);
+       if (stat(mtd_dev_node, &sb) < 0)
+               return sys_errmsg("cannot stat \"%s\"", mtd_dev_node);
 
        if (!S_ISCHR(sb.st_mode)) {
                errno = EINVAL;
-               return sys_errmsg("\"%s\" is not a character device", dev);
+               return sys_errmsg("\"%s\" is not a character device",
+                                 mtd_dev_node);
        }
 
        major = major(sb.st_rdev);
@@ -761,7 +762,7 @@ static int dev_to_mtdnum(const char *dev)
 
        if (major != MTD_CHAR_MAJOR) {
                errno = EINVAL;
-               return sys_errmsg("\"%s\" is not an MTD device", dev);
+               return sys_errmsg("\"%s\" is not an MTD device", mtd_dev_node);
        }
 
        return minor / 2;
@@ -772,7 +773,7 @@ int ubi_attach(libubi_t desc, const char *node, struct ubi_attach_request *req)
        struct ubi_attach_req r;
        int ret;
 
-       if (!req->dev)
+       if (!req->mtd_dev_node)
                /* Fallback to opening by mtd_num */
                return ubi_attach_mtd(desc, node, req);
 
@@ -784,7 +785,7 @@ int ubi_attach(libubi_t desc, const char *node, struct ubi_attach_request *req)
         * User has passed path to device node. Lets find out MTD device number
         * of the device and pass it to the kernel.
         */
-       r.mtd_num = dev_to_mtdnum(req->dev);
+       r.mtd_num = mtd_node_to_num(req->mtd_dev_node);
        if (r.mtd_num == -1)
                return -1;
 
@@ -808,16 +809,16 @@ int ubi_detach_mtd(libubi_t desc, const char *node, int mtd_num)
        return ubi_remove_dev(desc, node, ubi_dev);
 }
 
-int ubi_detach(libubi_t desc, const char *node, const char *dev)
+int ubi_detach(libubi_t desc, const char *node, const char *mtd_dev_node)
 {
        int mtd_num;
 
-       if (!dev) {
+       if (!mtd_dev_node) {
                errno = EINVAL;
                return -1;
        }
 
-       mtd_num = dev_to_mtdnum(dev);
+       mtd_num = mtd_node_to_num(mtd_dev_node);
        if (mtd_num == -1)
                return -1;
 
index 67f8c856bfb12cc7adebd1f1ccbc59840631476d..210624b487fd106dd585955a5dfa7c55f1e87ffb 100644 (file)
@@ -188,7 +188,7 @@ int main(int argc, char * const argv[])
        req.dev_num = args.devn;
        req.mtd_num = args.mtdn;
        req.vid_hdr_offset = args.vidoffs;
-       req.dev = args.dev;
+       req.mtd_dev_node = args.dev;
 
        err = ubi_attach(libubi, args.node, &req);
        if (err) {