From 780ebf0db71429b508ac64b3133f8e4901f64733 Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Wed, 25 Jan 2012 23:31:49 -0800 Subject: libubi: make `ubi_dev_present()' a library function We will use this function in ubinfo. Signed-off-by: Brian Norris Signed-off-by: Artem Bityutskiy --- ubi-utils/include/libubi.h | 9 +++++++++ ubi-utils/libubi.c | 12 +++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/ubi-utils/include/libubi.h b/ubi-utils/include/libubi.h index 02017e8..dc03d02 100644 --- a/ubi-utils/include/libubi.h +++ b/ubi-utils/include/libubi.h @@ -345,6 +345,15 @@ int ubi_probe_node(libubi_t desc, const char *node); int ubi_get_dev_info(libubi_t desc, const char *node, struct ubi_dev_info *info); +/** + * ubi_dev_present - check whether an UBI device is present. + * @desc: UBI library descriptor + * @dev_num: UBI device number to check + * + * This function returns %1 if UBI device is present and %0 if not. + */ +int ubi_dev_present(libubi_t desc, int dev_num); + /** * ubi_get_dev_info1 - get UBI device information. * @desc: UBI library descriptor diff --git a/ubi-utils/libubi.c b/ubi-utils/libubi.c index 4d5f316..c898e36 100644 --- a/ubi-utils/libubi.c +++ b/ubi-utils/libubi.c @@ -1121,16 +1121,10 @@ int ubi_leb_change_start(libubi_t desc, int fd, int lnum, int bytes, int dtype) return 0; } -/** - * dev_present - check whether an UBI device is present. - * @lib: libubi descriptor - * @dev_num: UBI device number to check - * - * This function returns %1 if UBI device is present and %0 if not. - */ -static int dev_present(struct libubi *lib, int dev_num) +int ubi_dev_present(libubi_t desc, int dev_num) { struct stat st; + struct libubi *lib = (struct libubi *)desc; char file[strlen(lib->ubi_dev) + 50]; sprintf(file, lib->ubi_dev, dev_num); @@ -1146,7 +1140,7 @@ int ubi_get_dev_info1(libubi_t desc, int dev_num, struct ubi_dev_info *info) memset(info, 0, sizeof(struct ubi_dev_info)); info->dev_num = dev_num; - if (!dev_present(lib, dev_num)) + if (!ubi_dev_present(desc, dev_num)) return -1; sysfs_ubi = opendir(lib->sysfs_ubi); -- cgit v1.2.3