aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devices.txt6
-rw-r--r--drivers/mmc/card/Kconfig17
-rw-r--r--drivers/mmc/card/block.c43
3 files changed, 54 insertions, 12 deletions
diff --git a/Documentation/devices.txt b/Documentation/devices.txt
index c58abf1ccc71..170cc1e7e135 100644
--- a/Documentation/devices.txt
+++ b/Documentation/devices.txt
@@ -2520,6 +2520,12 @@ Your cooperation is appreciated.
2520 8 = /dev/mmcblk1 Second SD/MMC card 2520 8 = /dev/mmcblk1 Second SD/MMC card
2521 ... 2521 ...
2522 2522
2523 The start of next SD/MMC card can be configured with
2524 CONFIG_MMC_BLOCK_MINORS, or overridden at boot/modprobe
2525 time using the mmcblk.perdev_minors option. That would
2526 bump the offset between each card to be the configured
2527 value instead of the default 8.
2528
2523179 char CCube DVXChip-based PCI products 2529179 char CCube DVXChip-based PCI products
2524 0 = /dev/dvxirq0 First DVX device 2530 0 = /dev/dvxirq0 First DVX device
2525 1 = /dev/dvxirq1 Second DVX device 2531 1 = /dev/dvxirq1 Second DVX device
diff --git a/drivers/mmc/card/Kconfig b/drivers/mmc/card/Kconfig
index 3f2a912659af..57e4416b9ef0 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 a9970504cabb..217f82037fc1 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;