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

Kyungmin Park kmpark at infradead.org
Tue Sep 9 03:15:53 CEST 2008


On Tue, Sep 9, 2008 at 4:30 AM, Scott Wood <scottwood at freescale.com> wrote:
> 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.
>

That's the reason I want to create new tree to sync u-boot tree. At
that time there's no point, ecc_stats, and ... fields at mtd_info, So
I disable it. Now it's included and we can remove #if 0.


>> ---
>> 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.

Yes I agree. As I know there's no users to use mtdpart. Instead it
used another mtdpart format at mtdpart command. Next time it changes
from previous one to MTD infrastructure.

>
>>  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.

I don't want to remove or modify imported codes at least MTD & UBI codes.

Thank you,
Kyungmin Park


More information about the U-Boot mailing list