All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: make number of mmcblk minors configurable
@ 2010-08-18  4:13 Olof Johansson
  2010-08-19  0:16 ` Andrew Morton
  0 siblings, 1 reply; 16+ messages in thread
From: Olof Johansson @ 2010-08-18  4:13 UTC (permalink / raw)
  To: linux-mmc; +Cc: akpm, linux-kernel

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.

Signed-off-by: Olof Johansson <olof@lixom.net>
---
 drivers/mmc/card/Kconfig |   10 ++++++++++
 drivers/mmc/card/block.c |   20 ++++++++------------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/card/Kconfig b/drivers/mmc/card/Kconfig
index 3f2a912..e939dcf 100644
--- a/drivers/mmc/card/Kconfig
+++ b/drivers/mmc/card/Kconfig
@@ -14,6 +14,16 @@ config MMC_BLOCK
 	  mount the filesystem. Almost everyone wishing MMC support
 	  should say Y or M here.
 
+config MMC_BLOCK_MINORS
+	int "Number of minors per block device"
+	range 4 32
+	default 8
+	help
+	  Number of minors per block device. One is needed for every
+	  partition (plus one for the whole device).
+	  Default is 8 to be backwards compatible with previous
+	  hardcoded device numbering.
+
 config MMC_BLOCK_BOUNCE
 	bool "Use bounce buffer for simple hosts"
 	depends on MMC_BLOCK
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index d545f79..524e232 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -45,13 +45,9 @@
 
 MODULE_ALIAS("mmc:block");
 
-/*
- * max 8 partitions per card
- */
-#define MMC_SHIFT	3
-#define MMC_NUM_MINORS	(256 >> MMC_SHIFT)
+#define MMC_MAX_DEVICES	((255 + CONFIG_MMC_BLOCK_MINORS) / CONFIG_MMC_BLOCK_MINORS)
 
-static DECLARE_BITMAP(dev_use, MMC_NUM_MINORS);
+static DECLARE_BITMAP(dev_use, MMC_MAX_DEVICES);
 
 /*
  * There is one mmc_blk_data per slot.
@@ -88,10 +84,10 @@ static void mmc_blk_put(struct mmc_blk_data *md)
 	md->usage--;
 	if (md->usage == 0) {
 		int devmaj = MAJOR(disk_devt(md->disk));
-		int devidx = MINOR(disk_devt(md->disk)) >> MMC_SHIFT;
+		int devidx = MINOR(disk_devt(md->disk)) / CONFIG_MMC_BLOCK_MINORS;
 
 		if (!devmaj)
-			devidx = md->disk->first_minor >> MMC_SHIFT;
+			devidx = md->disk->first_minor / CONFIG_MMC_BLOCK_MINORS;
 
 		blk_cleanup_queue(md->queue.queue);
 
@@ -567,8 +563,8 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
 	struct mmc_blk_data *md;
 	int devidx, ret;
 
-	devidx = find_first_zero_bit(dev_use, MMC_NUM_MINORS);
-	if (devidx >= MMC_NUM_MINORS)
+	devidx = find_first_zero_bit(dev_use, MMC_MAX_DEVICES);
+	if (devidx >= MMC_MAX_DEVICES)
 		return ERR_PTR(-ENOSPC);
 	__set_bit(devidx, dev_use);
 
@@ -585,7 +581,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
 	 */
 	md->read_only = mmc_blk_readonly(card);
 
-	md->disk = alloc_disk(1 << MMC_SHIFT);
+	md->disk = alloc_disk(CONFIG_MMC_BLOCK_MINORS);
 	if (md->disk == NULL) {
 		ret = -ENOMEM;
 		goto err_kfree;
@@ -602,7 +598,7 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
 	md->queue.data = md;
 
 	md->disk->major	= MMC_BLOCK_MAJOR;
-	md->disk->first_minor = devidx << MMC_SHIFT;
+	md->disk->first_minor = devidx * CONFIG_MMC_BLOCK_MINORS;
 	md->disk->fops = &mmc_bdops;
 	md->disk->private_data = md;
 	md->disk->queue = md->queue.queue;
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-09-09  7:55 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-18  4:13 [PATCH] mmc: make number of mmcblk minors configurable Olof Johansson
2010-08-19  0:16 ` Andrew Morton
2010-08-19  3:22   ` Olof Johansson
2010-08-20  1:02     ` [PATCH v2] mmc: add config and runtime option for number of mmcblk minors Olof Johansson
2010-08-20 22:13       ` [PATCH v3] " Olof Johansson
2010-08-20 22:18         ` sys_init_module system call runcoderen
2010-08-20 22:32           ` Randy Dunlap
2010-08-20 22:50             ` runcoderen
2010-09-08 14:25         ` [PATCH v3] mmc: add config and runtime option for number of mmcblk minors Lei Wen
2010-09-08 14:57           ` Olof Johansson
2010-09-08 15:19             ` Kay Sievers
2010-09-08 15:57               ` Olof Johansson
2010-09-08 16:48                 ` Colin Cross
2010-09-08 16:50                   ` [PATCH] mmc_block: Allow more than 8 partitions per card Colin Cross
2010-09-09  2:49                     ` Lei Wen
2010-09-09  7:54                     ` Adrian Hunter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.