mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 8/8] nand: make reading oob optional
Date: Fri,  8 Apr 2011 16:56:19 +0200	[thread overview]
Message-ID: <1302274579-11158-9-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1302274579-11158-1-git-send-email-s.hauer@pengutronix.de>

The nand oob functions occupy quite some binary space. If not needed,
we can save this space by making this configurable.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/nand/Kconfig      |    5 ++++
 drivers/mtd/nand/nand.c       |   42 +++++++++++++++++++++++++++++++++-------
 drivers/mtd/nand/nand_base.c  |    9 +++++++-
 drivers/mtd/nand/nand_hwecc.c |    2 +
 4 files changed, 49 insertions(+), 9 deletions(-)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 331aac8..126f7cc 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -49,6 +49,11 @@ config NAND_BBT
 	  Say y here to include support for bad block tables. This speeds
 	  up the process of checking for bad blocks
 
+config NAND_READ_OOB
+	bool
+	default y
+	prompt "create a device for reading the OOB data"
+
 config NAND_IMX
 	bool
 	prompt "i.MX NAND driver"
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
index 2333160..deb9400 100644
--- a/drivers/mtd/nand/nand.c
+++ b/drivers/mtd/nand/nand.c
@@ -184,6 +184,7 @@ static struct file_operations nand_ops = {
 	.lseek  = dev_lseek_default,
 };
 
+#ifdef CONFIG_NAND_READ_OOB
 static ssize_t nand_read_oob(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags)
 {
 	struct mtd_info *info = cdev->priv;
@@ -215,9 +216,39 @@ static struct file_operations nand_ops_oob = {
 	.lseek  = dev_lseek_default,
 };
 
-int add_mtd_device(struct mtd_info *mtd)
+static int nand_init_oob_cdev(struct mtd_info *mtd)
 {
 	struct nand_chip *chip = mtd->priv;
+
+	mtd->cdev_oob.ops = &nand_ops_oob;
+	mtd->cdev_oob.size = (mtd->size >> chip->page_shift) * mtd->oobsize;
+	mtd->cdev_oob.name = asprintf("nand_oob%d", mtd->class_dev.id);
+	mtd->cdev_oob.priv = mtd;
+	mtd->cdev_oob.dev = &mtd->class_dev;
+	devfs_create(&mtd->cdev_oob);
+
+	return 0;
+}
+
+static void nand_exit_oob_cdev(struct mtd_info *mtd)
+{
+	free(mtd->cdev_oob.name);
+}
+#else
+
+static int nand_init_oob_cdev(struct mtd_info *mtd)
+{
+	return 0;
+}
+
+static void nand_exit_oob_cdev(struct mtd_info *mtd)
+{
+	return;
+}
+#endif
+
+int add_mtd_device(struct mtd_info *mtd)
+{
 	char str[16];
 
 	strcpy(mtd->class_dev.name, "nand");
@@ -235,12 +266,7 @@ int add_mtd_device(struct mtd_info *mtd)
 
 	devfs_create(&mtd->cdev);
 
-	mtd->cdev_oob.ops = &nand_ops_oob;
-	mtd->cdev_oob.size = (mtd->size >> chip->page_shift) * mtd->oobsize;
-	mtd->cdev_oob.name = asprintf("nand_oob%d", mtd->class_dev.id);
-	mtd->cdev_oob.priv = mtd;
-	mtd->cdev_oob.dev = &mtd->class_dev;
-	devfs_create(&mtd->cdev_oob);
+	nand_init_oob_cdev(mtd);
 
 	return 0;
 }
@@ -248,7 +274,7 @@ int add_mtd_device(struct mtd_info *mtd)
 int del_mtd_device (struct mtd_info *mtd)
 {
 	unregister_device(&mtd->class_dev);
-	free(mtd->cdev_oob.name);
+	nand_exit_oob_cdev(mtd);
 	free(mtd->param_size.value);
 	free(mtd->cdev.name);
 	return 0;
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index f641f8d..d627f16 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -601,6 +601,7 @@ static int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
  * @ops:	oob ops structure
  * @len:	size of oob to transfer
  */
+#ifdef CONFIG_NAND_READ_OOB
 static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
 				  struct mtd_oob_ops *ops, size_t len)
 {
@@ -641,6 +642,7 @@ static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob,
 	}
 	return NULL;
 }
+#endif
 
 /**
  * nand_do_read_ops - [Internal] Read data with ECC
@@ -706,6 +708,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 
 			buf += bytes;
 
+#ifdef CONFIG_NAND_READ_OOB
 			if (unlikely(oob)) {
 				/* Raw mode does data:oob:data:oob */
 				if (ops->mode != MTD_OOB_RAW) {
@@ -720,7 +723,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from,
 					buf = nand_transfer_oob(chip,
 						buf, ops, mtd->oobsize);
 			}
-
+#endif
 			if (!(chip->options & NAND_NO_READRDY)) {
 				/*
 				 * Apply delay or wait for ready/busy pin. Do
@@ -836,6 +839,7 @@ int nand_read_oob_std(struct mtd_info *mtd, struct nand_chip *chip,
  *
  * NAND read out-of-band data from the spare area
  */
+#ifdef CONFIG_NAND_READ_OOB
 static int nand_do_read_oob(struct mtd_info *mtd, loff_t from,
 			    struct mtd_oob_ops *ops)
 {
@@ -961,6 +965,7 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from,
  out:
 	return ret;
 }
+#endif
 
 /**
  * nand_block_isbad - [MTD Interface] Check if block at offset is bad
@@ -1420,7 +1425,9 @@ int nand_scan_tail(struct mtd_info *mtd)
 	mtd->write_oob = nand_write_oob;
 #endif
 	mtd->read = nand_read;
+#ifdef CONFIG_NAND_READ_OOB
 	mtd->read_oob = nand_read_oob;
+#endif
 	mtd->lock = NULL;
 	mtd->unlock = NULL;
 	mtd->block_isbad = nand_block_isbad;
diff --git a/drivers/mtd/nand/nand_hwecc.c b/drivers/mtd/nand/nand_hwecc.c
index e5de30a..95b08d3 100644
--- a/drivers/mtd/nand/nand_hwecc.c
+++ b/drivers/mtd/nand/nand_hwecc.c
@@ -90,8 +90,10 @@ void nand_init_ecc_hw(struct nand_chip *chip)
 	/* Use standard hwecc read page function ? */
 	if (!chip->ecc.read_page)
 		chip->ecc.read_page = nand_read_page_hwecc;
+#ifdef CONFIG_NAND_READ_OOB
 	if (!chip->ecc.read_oob)
 		chip->ecc.read_oob = nand_read_oob_std;
+#endif
 #ifdef CONFIG_NAND_WRITE
 	if (!chip->ecc.write_oob)
 		chip->ecc.write_oob = nand_write_oob_std;
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2011-04-08 14:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-08 14:56 Size reduction patches Sascha Hauer
2011-04-08 14:56 ` [PATCH 1/8] env: Make environment variable support optional Sascha Hauer
2011-04-08 14:56 ` [PATCH 2/8] make command " Sascha Hauer
2011-04-08 14:56 ` [PATCH 3/8] add noshell support Sascha Hauer
2011-04-08 14:56 ` [PATCH 4/8] arm: compile icache command only when command support is present Sascha Hauer
2011-04-08 14:56 ` [PATCH 5/8] malloc: put common memory functions to seperate file Sascha Hauer
2011-04-08 14:56 ` [PATCH 6/8] add dummy_malloc functions Sascha Hauer
2011-04-08 14:56 ` [PATCH 7/8] ARM: make exception handling optional Sascha Hauer
2011-04-08 14:56 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302274579-11158-9-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox