mtd: define `mtd_is_*()' functions

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon Nov 7 11:59:34 EST 2011


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=7387ce773256f446bdd0280b2449b635441f906e
Commit:     7387ce773256f446bdd0280b2449b635441f906e
Parent:     b61bf5bbf619fc66ca866a27038da0b91cafb92d
Author:     Brian Norris <computersforpeace at gmail.com>
AuthorDate: Tue Sep 20 18:30:51 2011 -0700
Committer:  Artem Bityutskiy <artem.bityutskiy at intel.com>
CommitDate: Wed Sep 21 09:19:06 2011 +0300

    mtd: define `mtd_is_*()' functions
    
    These functions can be used instead of referencing -EUCLEAN and -EBADMSG
    all over the place. They should help make code a little bit more
    readable.
    
    Signed-off-by: Brian Norris <computersforpeace at gmail.com>
    Signed-off-by: Artem Bityutskiy <artem.bityutskiy at intel.com>
---
 include/linux/mtd/mtd.h |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 37d0827..4bce1eb 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -348,4 +348,16 @@ void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
 
 void mtd_erase_callback(struct erase_info *instr);
 
+static inline int mtd_is_bitflip(int err) {
+	return err == -EUCLEAN;
+}
+
+static inline int mtd_is_eccerr(int err) {
+	return err == -EBADMSG;
+}
+
+static inline int mtd_is_bitflip_or_eccerr(int err) {
+	return mtd_is_bitflip(err) || mtd_is_eccerr(err);
+}
+
 #endif /* __MTD_MTD_H__ */



More information about the linux-mtd-cvs mailing list