[U-Boot] [PATCH] Add MTD core & partition

Scott Wood scottwood at freescale.com
Mon Sep 8 21:30:27 CEST 2008


On Fri, Aug 29, 2008 at 05:13:23PM +0900, Kyungmin Park wrote:
> It's preparation for UBI codes.
> UBI uses partition and get & put mtd devices

Please import the latest MTD code; there have been several cleanups/fixes
in mtdpart.c recently (in particular, the patches from Atsushi Nemoto
dated Jul 19).

As for the #if 0 blocks, I'd rather leave them out entirely -- I think
the increased readability would be worth the occasional extra merge
conflict when importing new upstream code.

> Signed-off-by: Kyungmin Park <kyungmin.park at samsung.com>
> ---
> diff --git a/drivers/mtd/Makefile b/drivers/mtd/Makefile
> index 6538f7a..d225a68 100644
> --- a/drivers/mtd/Makefile
> +++ b/drivers/mtd/Makefile
> @@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk
>  
>  LIB	:= $(obj)libmtd.a
>  
> +COBJS-$(CONFIG_CMD_UBI) += mtdcore.o mtdpart.o

Is UBI the only case where we want the generic MTD infrastructure?  Maybe
we can remove some duplication and/or add partition support elsewhere.

>  COBJS-$(CONFIG_HAS_DATAFLASH) += at45.o
>  COBJS-$(CONFIG_FLASH_CFI_DRIVER) += cfi_flash.o
>  COBJS-$(CONFIG_HAS_DATAFLASH) += dataflash.o
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> new file mode 100644
> index 0000000..2fb6099
> --- /dev/null
> +++ b/drivers/mtd/mtdcore.c
> @@ -0,0 +1,142 @@
> +/*
> + * $Id: mtdcore.c,v 1.47 2005/11/07 11:14:20 gleixner Exp $
> + *
> + * Core registration and callback routines for MTD
> + * drivers and users.
> + */
> +
> +#include <linux/mtd/mtd.h>
> +#include <mtd_uboot.h>
> +#include <ubi_uboot.h>

I don't see mtd_uboot.h or ubi_uboot.h in the current tree, nor are they
added by this patch.

Is this patch supposed to depend on the giant UBI patch (I'd think not,
since the changelog says it's preparing for UBI)?

> +/**
> + *      del_mtd_device - unregister an MTD device
> + *      @mtd: pointer to MTD device info structure
> + *
> + *      Remove a device from the list of MTD devices present in the system,
> + *      and notify each currently active MTD 'user' of its departure.
> + *      Returns zero on success or 1 on failure, which currently will happen
> + *      if the requested device does not appear to be present in the list.
> + */
> +int del_mtd_device (struct mtd_info *mtd)
> +{
> +	int ret;
> +
> +	if (mtd_table[mtd->index] != mtd) {
> +		ret = -ENODEV;
> +	} else if (mtd->usecount) {
> +		printk(KERN_NOTICE "Removing MTD device #%d (%s) with use count %d\n",
> +				mtd->index, mtd->name, mtd->usecount);
> +		ret = -EBUSY;
> +	} else {
> +		/* No need to get a refcount on the module containing
> +		 *                    the notifier, since we hold the mtd_table_mutex */
> +		mtd_table[mtd->index] = NULL;
> +
> +		ret = 0;
> +	}
> +
> +	return ret;
> +}

We should remove all the refcounting/removal stuff -- it's just bloat in
u-boot.

-Scott


More information about the U-Boot mailing list