diff options
author | Todd Poynor <tpoynor@mvista.com> | 2005-07-29 15:42:07 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@mtd.linutronix.de> | 2005-08-04 06:51:18 -0400 |
commit | 65a8de36b48f1c1cd02940c4480bc8e290540d18 (patch) | |
tree | 733f1f4f457925be88d3dc5451f0413ed8e37108 /drivers/mtd | |
parent | 7ad2b7f5955f117bfca99c6b7cd7483d25f6a8af (diff) |
[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@mvista.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/mtd_blkdevs.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 5d0e13d9f24a..d6cb3d194efb 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * $Id: mtd_blkdevs.c,v 1.25 2005/07/29 01:57:55 tpoynor Exp $ | 2 | * $Id: mtd_blkdevs.c,v 1.26 2005/07/29 19:42:04 tpoynor Exp $ |
3 | * | 3 | * |
4 | * (C) 2003 David Woodhouse <dwmw2@infradead.org> | 4 | * (C) 2003 David Woodhouse <dwmw2@infradead.org> |
5 | * | 5 | * |
@@ -289,8 +289,18 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) | |||
289 | gd->first_minor = (new->devnum) << tr->part_bits; | 289 | gd->first_minor = (new->devnum) << tr->part_bits; |
290 | gd->fops = &mtd_blktrans_ops; | 290 | gd->fops = &mtd_blktrans_ops; |
291 | 291 | ||
292 | snprintf(gd->disk_name, sizeof(gd->disk_name), | 292 | if (tr->part_bits) |
293 | "%s%c", tr->name, (tr->part_bits?'a':'0') + new->devnum); | 293 | if (new->devnum < 26) |
294 | snprintf(gd->disk_name, sizeof(gd->disk_name), | ||
295 | "%s%c", tr->name, 'a' + new->devnum); | ||
296 | else | ||
297 | snprintf(gd->disk_name, sizeof(gd->disk_name), | ||
298 | "%s%c%c", tr->name, | ||
299 | 'a' - 1 + new->devnum / 26, | ||
300 | 'a' + new->devnum % 26); | ||
301 | else | ||
302 | snprintf(gd->disk_name, sizeof(gd->disk_name), | ||
303 | "%s%d", tr->name, new->devnum); | ||
294 | 304 | ||
295 | /* 2.5 has capacity in units of 512 bytes while still | 305 | /* 2.5 has capacity in units of 512 bytes while still |
296 | having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */ | 306 | having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */ |