[PATCH] block2mtd: mtd: Present block2mtd timely on boot time

Rodrigo Freire rfreire at redhat.com
Wed Sep 17 13:18:33 PDT 2014


Hi Jörn,

----- Original Message ----- 
From: "Jörn Engel" <joern at logfs.org> 
> On Mon, 8 September 2014 16:04:40 -0400, Rodrigo Freire wrote: 
> > 
> > @@ -257,13 +281,15 @@ static struct block2mtd_dev *add_device( 
> > 
> > /* Setup the MTD structure */ 
> > /* make the name contain the block device in */ 
> > - name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname); 
> > + if (!mtdname) 
> > + mtdname = devname; 
> > + name = kmalloc(strlen(mtdname) + 1, GFP_KERNEL); 
> > if (!name) 
> > goto err_destroy_mutex; 
> > 
> > + strcpy(name, mtdname); 
> kstrdup. 
> And see below for the ABI change. 

Thanks for pointing. Fixed.


> >  	dev->mtd.name = name;
> > -
> > -	dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
> > +	dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK & ~(erase_size - 1);
> 
> PAGE_MASK is no longer needed with the new term.  Or does anyone
> seriously want to support erase_size < PAGE_SIZE?

Makes sense. I was talking to Felix and indeed there are some MTD devices 
which have 4k erase page size. Unheard of something smaller.
But it is on the MTD land and not block2mtd.


> Timeout has a default value, but name defaults to NULL. Add three 
> devices without specifying the name and you get funny results. 
> If we handled the NULL case by doing what the driver used to do before 
> this patch, I think this would be fine. 

Please see the fragment below:

@@ -257,13 +281,15 @@ static struct block2mtd_dev *add_device(
 
 	/* Setup the MTD structure */
 	/* make the name contain the block device in */
-	name = kasprintf(GFP_KERNEL, "block2mtd: %s", devname);
+	if (!mtdname)
+		mtdname = devname;
+	name = kstrdup(mtdname, GFP_KERNEL);
 	if (!name)
 		goto err_destroy_mutex;

If the name is a NULL or not provided, the mtdname will then become the mtd device name.
I also tried mounting several partitions, with both specified name and not and everything seemed to work nicely.

See a V2 patch on the next message.



More information about the linux-mtd mailing list