From dac2639f9833e858139d7e07f6ee45fb2191a9f2 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 28 Dec 2011 17:50:34 +0200 Subject: mtd: do not use mtd->read_oob directly Instead of checking whether 'mtd->read_oob' is defined, just call 'mtd_read_oob()' and handle the '-EOPNOTSUPP' error which will be returned if the function is undefined. Additionally, make 'mtd_write_oob()' return '-EOPNOTSUPP' if the function is undefined. Signed-off-by: Artem Bityutskiy Signed-off-by: David Woodhouse --- include/linux/mtd/mtd.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/linux/mtd') diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index b72964049cdc..721a63ffeb96 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -320,6 +320,8 @@ static inline int mtd_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) { ops->retlen = ops->oobretlen = 0; + if (!mtd->read_oob) + return -EOPNOTSUPP; return mtd->read_oob(mtd, from, ops); } @@ -327,6 +329,8 @@ static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) { ops->retlen = ops->oobretlen = 0; + if (!mtd->write_oob) + return -EOPNOTSUPP; return mtd->write_oob(mtd, to, ops); } -- cgit v1.2.3