From f1e870c3e9a1a80be7a1d886d61ccac0f8e97e10 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Sat, 17 Jul 2010 20:08:33 +0300 Subject: libmtd: support MEMERASE64 This patch is base on Kevin Cernekee's patch posted to the MTD mailing list. It adds MEMERASE64 support to the 'mtd_erase()' call. Now it first tries to use MEMERASE64, and if that is not supported, falls back to the old MEMERASE ioctl. This patch also introduces an 'offs64_ioctl' flag to the libmtd descriptor. However, we cannot initialize it in 'libmtd_open()', because we need an MTD device node, which we do not have in 'libmtd_open()'. Thus, we firs mark this flag as "uninitialized", and at the first invocation of 'mtd_erase()' we initialize it. This also means that we have to pass the limbtd descriptor to 'mtd_erase()', to save the flag value. This, in turn, requires tweaking 'mtd_erase()' users. This is not very nice, but good enough so far. Signed-off-by: Artem Bityutskiy --- include/libmtd.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include/libmtd.h') diff --git a/include/libmtd.h b/include/libmtd.h index 0aea966..2bf9859 100644 --- a/include/libmtd.h +++ b/include/libmtd.h @@ -139,6 +139,7 @@ int mtd_get_dev_info1(libmtd_t desc, int mtd_num, struct mtd_dev_info *mtd); /** * mtd_erase - erase an eraseblock. + * @desc: MTD library descriptor * @mtd: MTD device description object * @fd: MTD device node file descriptor * @eb: eraseblock to erase @@ -146,10 +147,11 @@ int mtd_get_dev_info1(libmtd_t desc, int mtd_num, struct mtd_dev_info *mtd); * This function erases eraseblock @eb of MTD device described by @fd. Returns * %0 in case of success and %-1 in case of failure. */ -int mtd_erase(const struct mtd_dev_info *mtd, int fd, int eb); +int mtd_erase(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb); /** * mtd_torture - torture an eraseblock. + * @desc: MTD library descriptor * @mtd: MTD device description object * @fd: MTD device node file descriptor * @eb: eraseblock to torture @@ -157,7 +159,7 @@ int mtd_erase(const struct mtd_dev_info *mtd, int fd, int eb); * This function tortures eraseblock @eb. Returns %0 in case of success and %-1 * in case of failure. */ -int mtd_torture(const struct mtd_dev_info *mtd, int fd, int eb); +int mtd_torture(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb); /** * mtd_is_bad - check if eraseblock is bad. -- cgit v1.2.3