aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2010-09-17 21:19:57 -0400
committerChris Ball <cjb@laptop.org>2010-10-24 21:28:46 -0400
commit5e71b7a64cb4c6cff75ca42b535d8227526ec592 (patch)
tree8bec2645c764c2711853ba4300d5eabcf80c3245 /drivers/mmc
parent061c6c847eeb11743e489a16e907b41c6f9042b6 (diff)
mmc: make number of mmcblk minors configurable
The old limit of number of minor numbers per mmcblk device was hardcoded at 8. This isn't enough for some of the more elaborate partitioning schemes, for example those used by Chrome OS. Since there might be a bunch of systems out there with static /dev contents that relies on the old numbering scheme, let's make it a build-time option with the default set to the previous 8. Also provide a boot/modprobe-time parameter to override the config default: mmcblk.perdev_minors. Signed-off-by: Olof Johansson <olof@lixom.net> Cc: Mandeep Baines <msb@chromium.org> Cc: <linux-mmc@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/card/Kconfig17
-rw-r--r--drivers/mmc/card/block.c43
2 files changed, 48 insertions, 12 deletions
diff --git a/drivers/mmc/card/Kconfig b/drivers/mmc/card/Kconfig
index 3f2a912659a..57e4416b9ef 100644
--- a/drivers/mmc/card/Kconfig
+++ b/drivers/mmc/card/Kconfig
@@ -14,6 +14,23 @@ config MMC_BLOCK
14 mount the filesystem. Almost everyone wishing MMC support 14 mount the filesystem. Almost everyone wishing MMC support
15 should say Y or M here. 15 should say Y or M here.
16 16
17config MMC_BLOCK_MINORS
18 int "Number of minors per block device"
19 range 4 256
20 default 8
21 help
22 Number of minors per block device. One is needed for every
23 partition on the disk (plus one for the whole disk).
24
25 Number of total MMC minors available is 256, so your number
26 of supported block devices will be limited to 256 divided
27 by this number.
28
29 Default is 8 to be backwards compatible with previous
30 hardwired device numbering.
31
32 If unsure, say 8 here.
33
17config MMC_BLOCK_BOUNCE 34config MMC_BLOCK_BOUNCE
18 bool "Use bounce buffer for simple hosts" 35 bool "Use bounce buffer for simple hosts"
19 depends on MMC_BLOCK 36 depends on MMC_BLOCK
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index a9970504cab..217f82037fc 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -43,15 +43,27 @@
43#include "queue.h" 43#include "queue.h"
44 44
45MODULE_ALIAS("mmc:block"); 45MODULE_ALIAS("mmc:block");
46#ifdef MODULE_PARAM_PREFIX
47#undef MODULE_PARAM_PREFIX
48#endif
49#define MODULE_PARAM_PREFIX "mmcblk."
50
51static DEFINE_MUTEX(block_mutex);
46 52
47/* 53/*
48 * max 8 partitions per card 54 * The defaults come from config options but can be overriden by module
55 * or bootarg options.
49 */ 56 */
50#define MMC_SHIFT 3 57static int perdev_minors = CONFIG_MMC_BLOCK_MINORS;
51#define MMC_NUM_MINORS (256 >> MMC_SHIFT)
52 58
53static DEFINE_MUTEX(block_mutex); 59/*
54static DECLARE_BITMAP(dev_use, MMC_NUM_MINORS); 60 * We've only got one major, so number of mmcblk devices is
61 * limited to 256 / number of minors per device.
62 */
63static int max_devices;
64
65/* 256 minors, so at most 256 separate devices */
66static DECLARE_BITMAP(dev_use, 256);
55 67
56/* 68/*
57 * There is one mmc_blk_data per slot. 69 * There is one mmc_blk_data per slot.
@@ -67,6 +79,9 @@ struct mmc_blk_data {
67 79
68static DEFINE_MUTEX(open_lock); 80static DEFINE_MUTEX(open_lock);
69 81
82module_param(perdev_minors, int, 0444);
83MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device");
84
70static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk) 85static struct mmc_blk_data *mmc_blk_get(struct gendisk *disk)
71{ 86{
72 struct mmc_blk_data *md; 87 struct mmc_blk_data *md;
@@ -88,10 +103,10 @@ static void mmc_blk_put(struct mmc_blk_data *md)
88 md->usage--; 103 md->usage--;
89 if (md->usage == 0) { 104 if (md->usage == 0) {
90 int devmaj = MAJOR(disk_devt(md->disk)); 105 int devmaj = MAJOR(disk_devt(md->disk));
91 int devidx = MINOR(disk_devt(md->disk)) >> MMC_SHIFT; 106 int devidx = MINOR(disk_devt(md->disk)) / perdev_minors;
92 107
93 if (!devmaj) 108 if (!devmaj)
94 devidx = md->disk->first_minor >> MMC_SHIFT; 109 devidx = md->disk->first_minor / perdev_minors;
95 110
96 blk_cleanup_queue(md->queue.queue); 111 blk_cleanup_queue(md->queue.queue);
97 112
@@ -566,8 +581,8 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
566 struct mmc_blk_data *md; 581 struct mmc_blk_data *md;
567 int devidx, ret; 582 int devidx, ret;
568 583
569 devidx = find_first_zero_bit(dev_use, MMC_NUM_MINORS); 584 devidx = find_first_zero_bit(dev_use, max_devices);
570 if (devidx >= MMC_NUM_MINORS) 585 if (devidx >= max_devices)
571 return ERR_PTR(-ENOSPC); 586 return ERR_PTR(-ENOSPC);
572 __set_bit(devidx, dev_use); 587 __set_bit(devidx, dev_use);
573 588
@@ -584,7 +599,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
584 */ 599 */
585 md->read_only = mmc_blk_readonly(card); 600 md->read_only = mmc_blk_readonly(card);
586 601
587 md->disk = alloc_disk(1 << MMC_SHIFT); 602 md->disk = alloc_disk(perdev_minors);
588 if (md->disk == NULL) { 603 if (md->disk == NULL) {
589 ret = -ENOMEM; 604 ret = -ENOMEM;
590 goto err_kfree; 605 goto err_kfree;
@@ -601,7 +616,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
601 md->queue.data = md; 616 md->queue.data = md;
602 617
603 md->disk->major = MMC_BLOCK_MAJOR; 618 md->disk->major = MMC_BLOCK_MAJOR;
604 md->disk->first_minor = devidx << MMC_SHIFT; 619 md->disk->first_minor = devidx * perdev_minors;
605 md->disk->fops = &mmc_bdops; 620 md->disk->fops = &mmc_bdops;
606 md->disk->private_data = md; 621 md->disk->private_data = md;
607 md->disk->queue = md->queue.queue; 622 md->disk->queue = md->queue.queue;
@@ -670,7 +685,6 @@ static int mmc_blk_probe(struct mmc_card *card)
670{ 685{
671 struct mmc_blk_data *md; 686 struct mmc_blk_data *md;
672 int err; 687 int err;
673
674 char cap_str[10]; 688 char cap_str[10];
675 689
676 /* 690 /*
@@ -760,6 +774,11 @@ static int __init mmc_blk_init(void)
760{ 774{
761 int res; 775 int res;
762 776
777 if (perdev_minors != CONFIG_MMC_BLOCK_MINORS)
778 pr_info("mmcblk: using %d minors per device\n", perdev_minors);
779
780 max_devices = 256 / perdev_minors;
781
763 res = register_blkdev(MMC_BLOCK_MAJOR, "mmc"); 782 res = register_blkdev(MMC_BLOCK_MAJOR, "mmc");
764 if (res) 783 if (res)
765 goto out; 784 goto out;