aboutsummaryrefslogtreecommitdiff
path: root/ubi-utils/include
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2009-04-18 16:01:40 +0300
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2009-04-18 16:05:50 +0300
commit194b2a55f626b94323b377d75edb295f536359c5 (patch)
tree91e771457a49ca06775f2e1afcbb6756f8cfc5ce /ubi-utils/include
parenta2ce5f7a0f5abf0077e057c476440d10e5e5ef45 (diff)
libmtd: amend interface
Remove the fd field from the mtd information data structure, because libmtd does not really know the device node file name, and serves only as a place to save the descriptor. The callers should find a better place. This patch improves code readability and prepares for further changes. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/include')
-rw-r--r--ubi-utils/include/libmtd.h23
-rw-r--r--ubi-utils/include/libscan.h4
2 files changed, 17 insertions, 10 deletions
diff --git a/ubi-utils/include/libmtd.h b/ubi-utils/include/libmtd.h
index c50059d..9c7a6e3 100644
--- a/ubi-utils/include/libmtd.h
+++ b/ubi-utils/include/libmtd.h
@@ -41,7 +41,6 @@ extern "C" {
* @subpage_size: sub-page size (not set by 'mtd_get_info()'!!!)
* @rdonly: non-zero if the device is read-only
* @allows_bb: non-zero if the MTD device may have bad eraseblocks
- * @fd: descriptor of the opened MTD character device node
*/
struct mtd_info
{
@@ -57,7 +56,6 @@ struct mtd_info
int subpage_size;
unsigned int rdonly:1;
unsigned int allows_bb:1;
- int fd;
};
/**
@@ -74,36 +72,40 @@ int mtd_get_info(const char *node, struct mtd_info *mtd);
/**
* mtd_erase - erase an eraseblock.
* @mtd: MTD device description object
+ * @fd: MTD device node file descriptor
* @eb: eraseblock to erase
*
- * This function erases the eraseblock and returns %0 in case of success and
- * %-1 in case of failure.
+ * This function erases eraseblock @eb of MTD device decribed by @fd. Returns
+ * %0 in case of success and %-1 in case of failure.
*/
-int mtd_erase(const struct mtd_info *mtd, int eb);
+int mtd_erase(const struct mtd_info *mtd, int fd, int eb);
/**
* mtd_is_bad - check if eraseblock is bad.
* @mtd: MTD device description object
+ * @fd: MTD device node file descriptor
* @eb: eraseblock to check
*
* This function checks if eraseblock @eb is bad. Returns %0 if not, %1 if yes,
* and %-1 in case of failure.
*/
-int mtd_is_bad(const struct mtd_info *mtd, int eb);
+int mtd_is_bad(const struct mtd_info *mtd, int fd, int eb);
/**
* mtd_mark_bad - marks the block as bad.
* @mtd: MTD device description object
+ * @fd: MTD device node file descriptor
* @eb: eraseblock to mark bad
*
* This function marks the eraseblock @eb as bad. Returns %0 if success
* %-1 if failure
*/
-int mtd_mark_bad(const struct mtd_info *mtd, int eb);
+int mtd_mark_bad(const struct mtd_info *mtd, int fd, int eb);
/**
* mtd_read - read data from an MTD device.
* @mtd: MTD device description object
+ * @fd: MTD device node file descriptor
* @eb: eraseblock to read from
* @offs: offset withing the eraseblock to read from
* @buf: buffer to read data to
@@ -113,11 +115,13 @@ int mtd_mark_bad(const struct mtd_info *mtd, int eb);
* of the MTD device defined by @mtd and stores the read data at buffer @buf.
* Returns %0 in case of success and %-1 in case of failure.
*/
-int mtd_read(const struct mtd_info *mtd, int eb, int offs, void *buf, int len);
+int mtd_read(const struct mtd_info *mtd, int fd, int eb, int offs, void *buf,
+ int len);
/**
* mtd_write - write data to an MTD device.
* @mtd: MTD device description object
+ * @fd: MTD device node file descriptor
* @eb: eraseblock to write to
* @offs: offset withing the eraseblock to write to
* @buf: buffer to write
@@ -127,7 +131,8 @@ int mtd_read(const struct mtd_info *mtd, int eb, int offs, void *buf, int len);
* of the MTD device defined by @mtd. Returns %0 in case of success and %-1 in
* case of failure.
*/
-int mtd_write(const struct mtd_info *mtd, int eb, int offs, void *buf, int len);
+int mtd_write(const struct mtd_info *mtd, int fd, int eb, int offs, void *buf,
+ int len);
#ifdef __cplusplus
}
diff --git a/ubi-utils/include/libscan.h b/ubi-utils/include/libscan.h
index 5afc93e..8597b98 100644
--- a/ubi-utils/include/libscan.h
+++ b/ubi-utils/include/libscan.h
@@ -92,11 +92,13 @@ struct mtd_info;
/**
* ubi_scan - scan an MTD device.
* @mtd: information about the MTD device to scan
+ * @fd: MTD device node file descriptor
* @info: the result of the scanning is returned here
* @verbose: verbose mode: %0 - be silent, %1 - output progress information,
* 2 - debugging output mode
*/
-int ubi_scan(struct mtd_info *mtd, struct ubi_scan_info **info, int verbose);
+int ubi_scan(struct mtd_info *mtd, int fd, struct ubi_scan_info **info,
+ int verbose);
/**
* ubi_scan_free - free scanning information.