summaryrefslogtreecommitdiff
path: root/ubi-utils
diff options
context:
space:
mode:
Diffstat (limited to 'ubi-utils')
-rw-r--r--ubi-utils/include/libubi.h20
-rw-r--r--ubi-utils/src/libubi.c31
-rw-r--r--ubi-utils/src/ubiattach.c2
3 files changed, 27 insertions, 26 deletions
diff --git a/ubi-utils/include/libubi.h b/ubi-utils/include/libubi.h
index ffc4be9..03b16ad 100644
--- a/ubi-utils/include/libubi.h
+++ b/ubi-utils/include/libubi.h
@@ -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.
diff --git a/ubi-utils/src/libubi.c b/ubi-utils/src/libubi.c
index 3fe7956..2eab3ba 100644
--- a/ubi-utils/src/libubi.c
+++ b/ubi-utils/src/libubi.c
@@ -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;
diff --git a/ubi-utils/src/ubiattach.c b/ubi-utils/src/ubiattach.c
index 67f8c85..210624b 100644
--- a/ubi-utils/src/ubiattach.c
+++ b/ubi-utils/src/ubiattach.c
@@ -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) {