mtd/drivers/mtd mtd_blkdevs.c,1.25,1.26

tpoynor at infradead.org tpoynor at infradead.org
Fri Jul 29 15:42:07 EDT 2005


Update of /home/cvs/mtd/drivers/mtd
In directory phoenix.infradead.org:/tmp/cvs-serv6485/drivers/mtd

Modified Files:
	mtd_blkdevs.c 
Log Message:
[MTD] mtd_blkdevs.c: Fix names when many devices/partitions are created

mtdblock (and other mtd modules that use the mtd_blkdevs interface
between the mtd translation layers and the linux block layer) handles
incorrectly more than 10 devices or 26 partitions in the names passed to
the generic disk layer.  This causes the device file names and other
info kept by the generic disk/block layers to have names such as
"mtdblock<".  Use integer formatting for device numbers; use "aa-az"
for partitions 27-52, "ba-bz" for 53-78...

Signed-off-by: Todd Poynor <tpoynor at mvista.com>


Index: mtd_blkdevs.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtd_blkdevs.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- mtd_blkdevs.c	29 Jul 2005 01:57:55 -0000	1.25
+++ mtd_blkdevs.c	29 Jul 2005 19:42:04 -0000	1.26
@@ -289,8 +289,18 @@
 	gd->first_minor = (new->devnum) << tr->part_bits;
 	gd->fops = &mtd_blktrans_ops;
 	
-	snprintf(gd->disk_name, sizeof(gd->disk_name),
-		 "%s%c", tr->name, (tr->part_bits?'a':'0') + new->devnum);
+	if (tr->part_bits)
+		if (new->devnum < 26)
+			snprintf(gd->disk_name, sizeof(gd->disk_name),
+				 "%s%c", tr->name, 'a' + new->devnum);
+		else
+			snprintf(gd->disk_name, sizeof(gd->disk_name),
+				 "%s%c%c", tr->name,
+				 'a' - 1 + new->devnum / 26,
+				 'a' + new->devnum % 26);
+	else
+		snprintf(gd->disk_name, sizeof(gd->disk_name),
+			 "%s%d", tr->name, new->devnum);
 
 	/* 2.5 has capacity in units of 512 bytes while still
 	   having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */





More information about the linux-mtd-cvs mailing list