mtd: plat_nand: allow platform to set partitions

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Jun 5 14:59:20 EDT 2009


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=f36e20c01ad0104688f2eaebdf2213e749929c97
Commit:     f36e20c01ad0104688f2eaebdf2213e749929c97
Parent:     bf95efd41b1a760128eb25402791b0a4941eb655
Author:     H Hartley Sweeten <hsweeten at visionengravers.com>
AuthorDate: Tue May 12 13:46:59 2009 -0700
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Jun 5 18:11:55 2009 +0100

    mtd: plat_nand: allow platform to set partitions
    
    Add optional callback to allow platform to initialize partitions.
    
    Static partitions on a nand device could vary depending on the size of the
    device.  This patch allows an optional platform callback to be used to
    setup this partition information at runtime.
    
    Scan order is:
    	1) chip.part_probe_types
    	2) chip.set_parts
    	3) chip.partitions
    	4) full mtd device (fallback for no partitions)
    
    Some of the existing nand drivers could possibly be replaced by the
    plat_nand driver by using this patch.  These include autcpu12.c and
    ts7250.c drivers.
    
    Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/nand/plat_nand.c |    2 ++
 include/linux/mtd/nand.h     |    3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
index 22e0ce7..4e16c6f 100644
--- a/drivers/mtd/nand/plat_nand.c
+++ b/drivers/mtd/nand/plat_nand.c
@@ -95,6 +95,8 @@ static int __devinit plat_nand_probe(struct platform_device *pdev)
 			return 0;
 		}
 	}
+	if (pdata->chip.set_parts)
+		pdata->chip.set_parts(data->mtd.size, &pdata->chip);
 	if (pdata->chip.partitions) {
 		data->parts = pdata->chip.partitions;
 		res = add_mtd_partitions(&data->mtd, data->parts,
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index 7f2d693..4030eba 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -563,6 +563,7 @@ extern int nand_do_read(struct mtd_info *mtd, loff_t from, size_t len,
  * @options:		Option flags, e.g. 16bit buswidth
  * @ecclayout:		ecc layout info structure
  * @part_probe_types:	NULL-terminated array of probe types
+ * @set_parts:		platform specific function to set partitions
  * @priv:		hardware controller specific settings
  */
 struct platform_nand_chip {
@@ -574,6 +575,8 @@ struct platform_nand_chip {
 	int			chip_delay;
 	unsigned int		options;
 	const char		**part_probe_types;
+	void			(*set_parts)(uint64_t size,
+					struct platform_nand_chip *chip);
 	void			*priv;
 };
 



More information about the linux-mtd-cvs mailing list