Patchwork mtd: Allow platform to set partitions at runtime

login
register
mail settings
Submitter hartleys
Date March 5, 2009, 12:29 a.m.
Message ID <BD79186B4FD85F4B8E60E381CAEE1909013B6E09@mi8nycmail19.Mi8.com>
Download mbox | patch
Permalink /patch/24076/
State New
Headers show

Comments

hartleys - March 5, 2009, 12:29 a.m.
Any comments on this patch?  If it looks ok how do I get it applied?

Regards,
Hartley 

-----Original Message-----
From: linux-mtd-bounces@lists.infradead.org
[mailto:linux-mtd-bounces@lists.infradead.org] On Behalf Of hartleys
Sent: Monday, February 09, 2009 4:31 PM
To: linux-mtd@lists.infradead.org
Subject: [PATCH] mtd: Allow platform to set partitions at runtime

Add a callback to allow platform to initialize the static 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@visionengravers.com>

---

 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;
 };
Alexander Clouter - March 5, 2009, 8:56 a.m.
* hartleys <hartleys@visionengravers.com> [Wed, 4 Mar 2009 19:29:00 -0500]:
>
> Any comments on this patch?  If it looks ok how do I get it applied?
>
I think there is an 'inner-circle' of MTD coding ninja's that do not 
read this list...

Cheers

> -----Original Message-----
> From: linux-mtd-bounces@lists.infradead.org
> [mailto:linux-mtd-bounces@lists.infradead.org] On Behalf Of hartleys
> Sent: Monday, February 09, 2009 4:31 PM
> To: linux-mtd@lists.infradead.org
> Subject: [PATCH] mtd: Allow platform to set partitions at runtime
>
> Add a callback to allow platform to initialize the static 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@visionengravers.com>
>
> ---
>
> diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
> index 75f9f48..f10b5a6 100644
> --- a/drivers/mtd/nand/plat_nand.c
> +++ b/drivers/mtd/nand/plat_nand.c
> @@ -86,6 +86,8 @@ static int __init 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 db5b63d..4eaf328 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;
>  };
>   
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>


Cheers

Patch

diff --git a/drivers/mtd/nand/plat_nand.c b/drivers/mtd/nand/plat_nand.c
index 75f9f48..f10b5a6 100644
--- a/drivers/mtd/nand/plat_nand.c
+++ b/drivers/mtd/nand/plat_nand.c
@@ -86,6 +86,8 @@  static int __init 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 db5b63d..4eaf328 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
  */