mtd: nand: add an mtd_to_nand() helper
authorBoris BREZILLON <boris.brezillon@free-electrons.com>
Mon, 16 Nov 2015 13:37:35 +0000 (14:37 +0100)
committerBrian Norris <computersforpeace@gmail.com>
Thu, 19 Nov 2015 19:09:10 +0000 (11:09 -0800)
Some drivers are retrieving the nand_chip pointer using the container_of
macro on a struct wrapping both the nand_chip and the mtd_info struct while
the standard way of retrieving this pointer is through mtd->priv.
Provide an helper to do that.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
include/linux/mtd/nand.h

index 5a9d1d4c2487fc2cf8f08489f317bf60df93b06f..a4839b3f27da0b14baaf946bd3467f63ef96426a 100644 (file)
@@ -719,6 +719,11 @@ struct nand_chip {
        void *priv;
 };
 
+static inline struct nand_chip *mtd_to_nand(struct mtd_info *mtd)
+{
+       return mtd->priv;
+}
+
 /*
  * NAND Flash Manufacturer ID Codes
  */