Patchwork [v2] MTD: make panic_write() conditionnal to CONFIG_MTD_OOPS

login
register
mail settings
Submitter Florian Fainelli
Date Jan. 10, 2012, 5:02 p.m.
Message ID <1326214937-10543-1-git-send-email-ffainelli@freebox.fr>
Download mbox | patch
Permalink /patch/135264/
State New
Headers show

Comments

Florian Fainelli - Jan. 10, 2012, 5:02 p.m.
The mtdoops driver is the only user of the panic_write callback
make all panic_write related code conditionnal to CONFIG_MTD_OOPS.

It is safe to define the panic_write callback as NULL when
CONFIG_MTD_OOPS is enabled since the mtdoops drivers check for the
callback being non-NULL and returns an error if this the case.

Signed-off-by: Florian Fainelli <ffainelli@freebox.fr>
---
Changes since v1:
- fixed commit message second paragraph: disabled -> enabled
- moved #if IS_ENABLE() above onenand_panic_wait which was

 drivers/mtd/mtdpart.c              |    5 +++++
 drivers/mtd/nand/nand_base.c       |    7 +++++++
 drivers/mtd/onenand/onenand_base.c |    5 +++++
 3 files changed, 17 insertions(+), 0 deletions(-)

Patch

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index a3d44c3..0322388 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -189,6 +189,7 @@  static int part_write(struct mtd_info *mtd, loff_t to, size_t len,
 	return mtd_write(part->master, to + part->offset, len, retlen, buf);
 }
 
+#if IS_ENABLED(CONFIG_MTD_OOPS)
 static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
 		size_t *retlen, const u_char *buf)
 {
@@ -202,6 +203,10 @@  static int part_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
 	return mtd_panic_write(part->master, to + part->offset, len, retlen,
 			       buf);
 }
+#else
+#define part_panic_write	NULL
+#endif
+
 
 static int part_write_oob(struct mtd_info *mtd, loff_t to,
 		struct mtd_oob_ops *ops)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 8a393f9..da8d4a6 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -753,6 +753,7 @@  static void nand_command_lp(struct mtd_info *mtd, unsigned int command,
  *
  * Used when in panic, no locks are taken.
  */
+#if IS_ENABLED(CONFIG_MTD_OOPS)
 static void panic_nand_get_device(struct nand_chip *chip,
 		      struct mtd_info *mtd, int new_state)
 {
@@ -760,6 +761,7 @@  static void panic_nand_get_device(struct nand_chip *chip,
 	chip->controller->active = chip;
 	chip->state = new_state;
 }
+#endif
 
 /**
  * nand_get_device - [GENERIC] Get chip for selected access
@@ -2286,6 +2288,7 @@  static int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
  * NAND write with ECC. Used when performing writes in interrupt context, this
  * may for example be called by mtdoops when writing an oops while in panic.
  */
+#if IS_ENABLED(CONFIG_MTD_OOPS)
 static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
 			    size_t *retlen, const uint8_t *buf)
 {
@@ -2315,6 +2318,10 @@  static int panic_nand_write(struct mtd_info *mtd, loff_t to, size_t len,
 	*retlen = ops.retlen;
 	return ret;
 }
+#else
+#define panic_nand_write	NULL
+#endif
+
 
 /**
  * nand_write - [MTD Interface] NAND write with ECC
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index a061bc1..fc0787d 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -1712,6 +1712,7 @@  static int onenand_verify(struct mtd_info *mtd, const u_char *buf, loff_t addr,
 
 #define NOTALIGNED(x)	((x & (this->subpagesize - 1)) != 0)
 
+#if IS_ENABLED(CONFIG_MTD_OOPS)
 static void onenand_panic_wait(struct mtd_info *mtd)
 {
 	struct onenand_chip *this = mtd->priv;
@@ -1819,6 +1820,10 @@  static int onenand_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
 	*retlen = written;
 	return ret;
 }
+#else
+#define onenand_panic_write	NULL
+#endif
+
 
 /**
  * onenand_fill_auto_oob - [INTERN] oob auto-placement transfer