]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[MTD] mtd_blkdevs.c: Fix names when many devices/partitions are created
authorTodd Poynor <tpoynor@mvista.com>
Fri, 29 Jul 2005 19:42:07 +0000 (20:42 +0100)
committerThomas Gleixner <tglx@mtd.linutronix.de>
Thu, 4 Aug 2005 10:51:18 +0000 (12:51 +0200)
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@mvista.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
drivers/mtd/mtd_blkdevs.c

index 5d0e13d9f24adc01370063e808dd4e546cc9d5fa..d6cb3d194efbf8f871ea0e7608a8c66cd7bebc28 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: mtd_blkdevs.c,v 1.25 2005/07/29 01:57:55 tpoynor Exp $
+ * $Id: mtd_blkdevs.c,v 1.26 2005/07/29 19:42:04 tpoynor Exp $
  *
  * (C) 2003 David Woodhouse <dwmw2@infradead.org>
  *
@@ -289,8 +289,18 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
        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. */