[PATCH] [MTD] BLOCK_RO: Readonly Block Device Layer Over MTD

Konstantin Baydarov kbaidarov at dev.rtsoft.ru
Wed Nov 22 11:56:33 EST 2006


On Tue, 21 Nov 2006 13:30:15 +0300
Vitaly Wool <vwool at ru.mvista.com> wrote:

> Josh Boyer wrote:
> 
> <snip>
> >> +static struct mtd_blktrans_ops mtdblock_tr = {
> >> +	.name		= "mtdblock",
> >> +	.major		= 258,
> >> +	.part_bits	= 0,
> >> +	.readsect	= mtdblock_readsect,
> >> +	.writesect	= mtdblock_writesect,
> >> +	.add_mtd	= mtdblock_add_mtd,
> >> +	.remove_dev	= mtdblock_remove_dev,
> >> +	.owner		= THIS_MODULE,
> >> +};
> >>     
> >
> > You went to the trouble of getting a new major number assigned...
> > why not call it something other than mtdblock?
> >   
> Agree.
> >   
> >> Index: mips-kernel-2.6/drivers/mtd/Kconfig
> >> ===================================================================
> >> --- mips-kernel-2.6.orig/drivers/mtd/Kconfig
> >> +++ mips-kernel-2.6/drivers/mtd/Kconfig
> >> @@ -197,6 +197,13 @@ config MTD_BLOCK_RO
> >>  	  You do not need this option for use with the DiskOnChip
> >> devices. For those, enable NFTL support (CONFIG_NFTL) instead.
> >>
> >> +config MTD_BLOCK_RO_BBFREE
> >> +	tristate "Readonly bad block free block device access to
> >> MTD devices"
> >> +	depends on MTD_BLOCK!=y && MTD && MTD_BLOCK_RO!=y
> >> +	help
> >> +	  Same as readonly block driver, but this allow you to
> >> mount read-only file
> >> +	  systems from an MTD device, containing bad blocks.
> >> +
> >>     
> >
> > This part seems hacky to me...  why can't use use mtdblock or
> > mtdblock_ro when this is enabled?  And what happens in the module
> > case? 
> I guess this line is borrowed from MTD_BLOCK_RO:
> 
> config MTD_BLOCK_RO
>         tristate "Readonly block device access to MTD devices"
>         depends on MTD_BLOCK!=y && MTD && BLOCK
> 
> I think though that these limitations are redundant at least for 
> MTD_BLOCK_RO_BBFREE b/c there might be the cases where there're both 
> NAND and NOR chips in the system so MTD_BLOCK_RO and
> MTD_BLOCK_RO_BBFREE might be needed to be present in the system at
> the same time.
> 
> Vitaly
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/

Corrected typo, renamed driver, got rid from redundant dependency.
Also I've tested mtdblock_ro_bbfree as module - ok.

Interdiff:
diff -u mtd-2.6/drivers/mtd/mtdblock_ro_bbfree.c
mtd-2.6/drivers/mtd/mtdblock_ro_bbfree.c ---
mtd-2.6/drivers/mtd/mtdblock_ro_bbfree.c +++
mtd-2.6/drivers/mtd/mtdblock_ro_bbfree.c @@ -73,7 +73,7 @@
 			if ((*mtd->block_isbad)(mtd, i *
mtd->erasesize) == 0) break;
 
-		/* exchausted ? */
+		/* exhausted ? */
 		if (i >= block_top) {
 			printk (KERN_WARNING "map_over_bad_blocks():
no more good blocks!\n"); return (loff_t)-1;
@@ -137,7 +137,7 @@
 }
 
 static struct mtd_blktrans_ops mtdblock_tr = {
-	.name		= "mtdblock",
+	.name		= "mtdblock_bbfree",
 	.major		= 258,
 	.part_bits	= 0,
 	.readsect	= mtdblock_readsect,
diff -u mtd-2.6/drivers/mtd/Kconfig mtd-2.6/drivers/mtd/Kconfig
--- mtd-2.6/drivers/mtd/Kconfig
+++ mtd-2.6/drivers/mtd/Kconfig
@@ -199,7 +199,7 @@
 
 config MTD_BLOCK_RO_BBFREE
 	tristate "Readonly bad block free block device access to MTD
devices"
-	depends on MTD_BLOCK!=y && MTD && MTD_BLOCK_RO!=y
+	depends on MTD_BLOCK!=y && MTD
 	help
 	  Same as readonly block driver, but this allow you to mount
read-only file systems from an MTD device, containing bad blocks.

Whole patch is attached.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bbfree_mtd_ro.patch
Type: text/x-patch
Size: 5996 bytes
Desc: not available
Url : http://lists.infradead.org/pipermail/linux-mtd/attachments/20061122/1c1acb68/attachment.bin 


More information about the linux-mtd mailing list