summaryrefslogtreecommitdiff
path: root/ubi-utils/new-utils/src/libubi.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-04-20 18:14:37 +0300
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-04-20 18:14:37 +0300
commit1e9b0691a9c52f8b56abc10a214a8aaa228b361b (patch)
tree0a6c23bcbcca951b69a664e1367817aeda59ca0f /ubi-utils/new-utils/src/libubi.c
parent49953500edc32e949b5f567fca67ed5430a68540 (diff)
ubi-utils: various clean-ups and preparations
This patch introduces many clean-ups, nicifications and preparations to the following ubiformat utility. There are also fixes. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/new-utils/src/libubi.c')
-rw-r--r--ubi-utils/new-utils/src/libubi.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/ubi-utils/new-utils/src/libubi.c b/ubi-utils/new-utils/src/libubi.c
index 5e6f9b1..8f95108 100644
--- a/ubi-utils/new-utils/src/libubi.c
+++ b/ubi-utils/new-utils/src/libubi.c
@@ -477,12 +477,13 @@ static int dev_node2num(struct libubi *lib, const char *node, int *dev_num)
return -1;
}
-static int mtd_num2ubi_dev(struct libubi *lib, int mtd_num, int *dev_num)
+int mtd_num2ubi_dev(libubi_t desc, int mtd_num, int *dev_num)
{
struct ubi_info info;
int i, ret, mtd_num1;
+ struct libubi *lib = desc;
- if (ubi_get_info((libubi_t *)lib, &info))
+ if (ubi_get_info(desc, &info))
return -1;
for (i = info.lowest_dev_num; i <= info.highest_dev_num; i++) {
@@ -500,7 +501,7 @@ static int mtd_num2ubi_dev(struct libubi *lib, int mtd_num, int *dev_num)
}
}
- errno = ENODEV;
+ errno = 0;
return -1;
}
@@ -714,8 +715,10 @@ int ubi_detach_mtd(libubi_t desc, const char *node, int mtd_num)
int ret, ubi_dev;
ret = mtd_num2ubi_dev(desc, mtd_num, &ubi_dev);
- if (ret == -1)
+ if (ret == -1) {
+ errno = ENODEV;
return ret;
+ }
return ubi_remove_dev(desc, node, ubi_dev);
}