[PATCH] MTD OneNAND OMAP2/3: allow giving partition layout as module parameter

Vimal Singh vimal.newwork at gmail.com
Thu Oct 29 09:25:53 EDT 2009


On Thu, Sep 3, 2009 at 4:45 PM, Mika Korhonen
<ext-mika.2.korhonen at nokia.com> wrote:
> Add module parameter "parts" to omap2-onenand driver. Parameter format is
> the same as for cmdlinepart except mtd-id must not be specified - it
> gets prepended by the driver, i.e.: parts=<partdef>[,<partdef>]*
>
> This allows one to repartition the OneNAND chip and is useful for flashing
> applications that do the partitioning from scratch or want to backup and
> update the partitioning.
>
> Signed-off-by: Mika Korhonen <ext-mika.2.korhonen at nokia.com>
> ---
>  drivers/mtd/cmdlinepart.c   |   35 +++++++++++++++++++++++++++++------
>  drivers/mtd/onenand/omap2.c |   29 +++++++++++++++++++++++++++++
>  2 files changed, 58 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
> index 1479da6..77fa7b7 100644
> --- a/drivers/mtd/cmdlinepart.c
> +++ b/drivers/mtd/cmdlinepart.c
> @@ -5,7 +5,7 @@
>  *
>  * The format for the command line is as follows:
>  *
> - * mtdparts=<mtddef>[;<mtddef]
> + * mtdparts=<mtddef>[;<mtddef>]
>  * <mtddef>  := <mtd-id>:<partdef>[,<partdef>]
>  *              where <mtd-id> is the name from the "cat /proc/mtd" command
>  * <partdef> := <size>[@offset][<name>][ro][lk]
> @@ -54,7 +54,7 @@ struct cmdline_mtd_partition {
>  /* mtdpart_setup() parses into here */
>  static struct cmdline_mtd_partition *partitions;
>
> -/* the command line passed to mtdpart_setupd() */
> +/* the command line passed to mtdpart_setup() */
>  static char *cmdline;
>  static int cmdline_parsed = 0;
>
> @@ -219,9 +219,8 @@ static int mtdpart_setup_real(char *s)
>  {
>        cmdline_parsed = 1;
>
> -       for( ; s != NULL; )
> -       {
> -               struct cmdline_mtd_partition *this_mtd;
> +       for ( ; s != NULL; ) {
> +               struct cmdline_mtd_partition *this_mtd, *mtd, *mtd_prev;
>                struct mtd_partition *parts;
>                int mtd_id_len;
>                int num_parts;
> @@ -270,6 +269,27 @@ static int mtdpart_setup_real(char *s)
>                this_mtd->mtd_id = (char*)(this_mtd + 1);
>                strlcpy(this_mtd->mtd_id, mtd_id, mtd_id_len + 1);
>
> +               /* remove existing ones with the same id */
> +               mtd_prev = NULL;
> +               for (mtd = partitions; mtd;)    {
Space instead of tab.

> +                       if (strcmp(this_mtd->mtd_id, mtd->mtd_id) == 0) {
Hmm... I guess you won't get your device id matched here. Since the
string you are passing from omap onenand driver is something like
this:
omap2-onenand:.....

while mtd registers device ids in different format, something like:
'omap2-onenand.0'

-- 
Regards,
Vimal Singh

[snip]

> +
> +#ifdef CONFIG_MTD_CMDLINE_PARTS
> +extern int mtdpart_setup(char *);
> +
> +static const char *part_probes[] = { "cmdlinepart", NULL };
> +static char parts[256] = DRIVER_NAME ":";
> +
> +module_param_string(parts, parts + DRIVER_NAME_SIZE, 256 - DRIVER_NAME_SIZE, 0);
> +#endif
> +
> +
>  static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data)
>  {
>        struct omap2_onenand *c = data;
> @@ -709,6 +721,23 @@ static int __devinit omap2_onenand_probe(struct platform_device *pdev)
>        }
>
>  #ifdef CONFIG_MTD_PARTITIONS
> +#ifdef CONFIG_MTD_CMDLINE_PARTS
> +       printk(KERN_INFO "parts=%s\n", parts);
> +       /* check module parameter */
> +       if (parts[DRIVER_NAME_SIZE] != '\0') {
> +               /* check parts string */
> +               if (strchr(parts, ';') || strchr(parts + DRIVER_NAME_SIZE, ':')) {
> +                       printk(KERN_ERR "onenand_probe: invalid partition parameter\n");
> +               } else {
> +                       mtdpart_setup(parts);
> +               }
> +       }
> +       r = parse_mtd_partitions(&c->mtd, part_probes, &c->parts, 0);
> +       if (r > 0) {
> +               /* module param or kernel command line arg */
> +               r = add_mtd_partitions(&c->mtd, c->parts, r);
> +       } else
> +#endif
>        if (pdata->parts != NULL)
>                r = add_mtd_partitions(&c->mtd, pdata->parts,
>                                       pdata->nr_parts);
> --
> 1.6.0.4
>
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
>



More information about the linux-mtd mailing list