From f84804d118c902f452fd4a1c9d113232d5c610e8 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Sun, 18 Jul 2010 07:26:59 +0300 Subject: libmtd: add OOB read and write interfaces This patch is based on Kevin Cernekee's patch posted to the MTD mailing list. It adds 'mtd_read_oob()' and 'mtd_write_oob()' interfaces support. The interfaces use MEMREADOOB64/MEMWRITEOOB64 MTD ioctls if possible, and fall-back to MEMREADOOB/MEMWRITEOOB if the 64-bit versions are not supported. The information about ioctls support is then cashed in 'offs64_ioctls' libmtd flag. Signed-off-by: Artem Bityutskiy --- include/libmtd.h | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'include/libmtd.h') diff --git a/include/libmtd.h b/include/libmtd.h index 2bf9859..afaba42 100644 --- a/include/libmtd.h +++ b/include/libmtd.h @@ -215,6 +215,40 @@ int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs, int mtd_write(const struct mtd_dev_info *mtd, int fd, int eb, int offs, void *buf, int len); +/** + * mtd_read_oob - read out-of-band area. + * @desc: MTD library descriptor + * @mtd: MTD device description object + * @fd: MTD device node file descriptor + * @start: page-aligned start address + * @length: number of OOB bytes to read + * @data: read buffer + * + * This function reads @length OOB bytes starting from address @start on + * MTD device described by @fd. The address is specified as page byte offset + * from the beginning of the MTD device. This function returns %0 in case of + * success and %-1 in case of failure. + */ +int mtd_read_oob(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, + uint64_t start, uint64_t length, void *data); + +/** + * mtd_write_oob - write out-of-band area. + * @desc: MTD library descriptor + * @mtd: MTD device description object + * @fd: MTD device node file descriptor + * @start: page-aligned start address + * @length: number of OOB bytes to write + * @data: write buffer + * + * This function writes @length OOB bytes starting from address @start on + * MTD device described by @fd. The address is specified as page byte offset + * from the beginning of the MTD device. Returns %0 in case of success and %-1 + * in case of failure. + */ +int mtd_write_oob(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, + uint64_t start, uint64_t length, void *data); + /** * mtd_write_img - write a file to MTD device. * @mtd: MTD device description object @@ -236,7 +270,7 @@ int mtd_write_img(const struct mtd_dev_info *mtd, int fd, int eb, int offs, * @node: the node to test * * This function tests whether @node is an MTD device node and returns %1 if it - * is, and %-1 if it is not (errno is ENODEV in this case) or if an error + * is, and %-1 if it is not (errno is %ENODEV in this case) or if an error * occurred. */ int mtd_probe_node(libmtd_t desc, const char *node); -- cgit v1.2.3