From: Andrei Warkentin <andreiw@motorola.com>
To: linux-mmc@vger.kernel.org
Cc: cjb@laptop.org, Andrei Warkentin <andreiw@motorola.com>
Subject: [PATCH] MMC: Block: Ensure hardware partitions don't mess with mmcblk device naming.
Date: Thu, 21 Apr 2011 22:46:13 -0500 [thread overview]
Message-ID: <1303443973-1608-1-git-send-email-andreiw@motorola.com> (raw)
In-Reply-To: <m3ipu76srt.fsf@pullcord.laptop.org>
With the hardware partitions support (which represent additional logical devices
present on MMC), devidx does not correspond with index used to form
/dev/mmcblkX names. So use an additional allocated index for device names.
Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
---
drivers/mmc/card/block.c | 26 +++++++++++++++++++-------
1 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 9e30cf6..92e4a00 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -75,6 +75,7 @@ static int max_devices;
/* 256 minors, so at most 256 separate devices */
static DECLARE_BITMAP(dev_use, 256);
+static DECLARE_BITMAP(name_use, 256);
/*
* There is one mmc_blk_data per slot.
@@ -88,6 +89,7 @@ struct mmc_blk_data {
unsigned int usage;
unsigned int read_only;
unsigned int part_type;
+ unsigned int name_idx;
/*
* Only set in main mmc_blk_data associated
@@ -776,6 +778,20 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
}
/*
+ * !subname implies we are creating main mmc_blk_data that will be
+ * associated with mmc_card with mmc_set_drvdata. Due to device partitions,
+ * devidx will not coincide with a per-physical card index anymore
+ * so we keep track of a name index.
+ */
+ if (!subname) {
+ md->name_idx = find_first_zero_bit(name_use, max_devices);
+ __set_bit(md->name_idx, name_use);
+ }
+ else
+ md->name_idx = ((struct mmc_blk_data *)
+ dev_to_disk(parent)->private_data)->name_idx;
+
+ /*
* Set the read-only status based on the supported commands
* and the write protect switch.
*/
@@ -820,13 +836,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
* messages to tell when the card is present.
*/
- if (subname)
- snprintf(md->disk->disk_name, sizeof(md->disk->disk_name),
- "mmcblk%d%s",
- mmc_get_devidx(dev_to_disk(parent)), subname);
- else
- snprintf(md->disk->disk_name, sizeof(md->disk->disk_name),
- "mmcblk%d", devidx);
+ snprintf(md->disk->disk_name, sizeof(md->disk->disk_name),
+ "mmcblk%d%s", md->name_idx, subname ? subname : "");
blk_queue_logical_block_size(md->queue.queue, 512);
set_capacity(md->disk, size);
@@ -953,6 +964,7 @@ static void mmc_blk_remove_parts(struct mmc_card *card,
struct list_head *pos, *q;
struct mmc_blk_data *part_md;
+ __clear_bit(md->name_idx, name_use);
list_for_each_safe(pos, q, &md->part) {
part_md = list_entry(pos, struct mmc_blk_data, part);
list_del(pos);
--
1.7.0.4
next prev parent reply other threads:[~2011-04-22 3:46 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-19 11:18 MMC/eMMC partitioning support Andrei Warkentin
2011-03-19 11:18 ` [RFC] MMC: MMC boot partitions support Andrei Warkentin
2011-03-19 12:13 ` Andrei Warkentin
2011-03-21 14:19 ` [PATCH] " Andrei Warkentin
2011-03-22 3:54 ` [PATCHv3] " Andrei Warkentin
2011-03-22 21:11 ` MMC partitions support (4th revision) Andrei Warkentin
2011-03-22 21:11 ` [PATCHv4] MMC: MMC boot partitions support Andrei Warkentin
2011-03-29 22:45 ` Andrei Warkentin
2011-03-30 12:03 ` Arnd Bergmann
2011-03-30 20:07 ` Andrei Warkentin
2011-03-30 22:43 ` Chris Ball
2011-03-30 22:46 ` Chris Ball
2011-03-30 23:18 ` Andrei Warkentin
2011-03-30 23:34 ` Chris Ball
2011-03-31 6:57 ` Andrei Warkentin
2011-03-31 11:01 ` Arnd Bergmann
2011-03-31 19:17 ` Andrei Warkentin
2011-03-31 19:37 ` Chris Ball
2011-03-31 20:01 ` Andrei Warkentin
2011-03-31 20:03 ` Chris Ball
2011-03-31 20:01 ` Andrei Warkentin
2011-04-01 9:23 ` Arnd Bergmann
2011-04-01 14:52 ` Chris Ball
2011-04-01 9:21 ` Arnd Bergmann
2011-03-31 11:17 ` Arnd Bergmann
2011-03-31 19:29 ` Andrei Warkentin
2011-04-01 10:38 ` Arnd Bergmann
2011-04-01 18:42 ` Andrei Warkentin
2011-04-01 19:25 ` Arnd Bergmann
2011-04-01 19:42 ` Andrei Warkentin
2011-04-04 12:22 ` [PATCH] " Andrei Warkentin
2011-04-04 11:52 ` Andrei Warkentin
2011-04-11 21:13 ` [patchv3 1/4] MMC: Rename erase_timeout to cmd_timeout_ms Andrei Warkentin
2011-04-11 21:13 ` [patchv3 2/4] MMC: SDHCI R1B command handling + MMC_CAP_ERASE Andrei Warkentin
2011-04-12 9:06 ` Dong, Chuanxiao
2011-04-12 18:05 ` Andrei Warkentin
2011-04-13 1:59 ` Dong, Chuanxiao
2011-04-13 5:44 ` Andrei Warkentin
2011-04-15 21:34 ` Cyril Hrubis
2011-08-10 13:30 ` Chris Ball
2011-04-11 21:13 ` [patchv3 3/4] MMC: Allow setting CMD timeout for CMD6 (SWITCH) Andrei Warkentin
2011-04-11 21:13 ` [patchv3 4/4] MMC: MMC boot partitions support Andrei Warkentin
2011-04-11 22:00 ` Chris Ball
2011-04-11 22:10 ` Andrei Warkentin
2011-04-11 22:22 ` Chris Ball
2011-04-11 22:18 ` Andrei Warkentin
2011-04-11 23:10 ` [patchv4 1/2] MMC: block.c cleanup for host claim/release Andrei Warkentin
2011-04-11 23:10 ` [patchv4 2/2] MMC: MMC boot partitions support Andrei Warkentin
2011-04-11 23:20 ` [patchv3 4/4] " Chris Ball
2011-04-11 23:24 ` Andrei Warkentin
2011-04-21 1:13 ` Chris Ball
2011-04-21 1:30 ` Chris Ball
2011-04-21 5:09 ` Philip Rakity
2011-04-21 5:22 ` Chris Ball
2011-04-21 5:31 ` Andrei Warkentin
2011-04-21 6:07 ` [RFC] MMC: Block: Ensure hardware partitions don't mess with mmcblk device naming Andrei Warkentin
2011-04-21 8:17 ` Andrei Warkentin
2011-04-21 14:44 ` Chris Ball
2011-04-22 0:20 ` Chris Ball
2011-04-22 3:46 ` Andrei Warkentin [this message]
2011-04-22 3:50 ` [PATCH] " Andrei Warkentin
2011-04-22 22:34 ` Chris Ball
2011-04-21 4:31 ` [patchv3 4/4] MMC: MMC boot partitions support Jaehoon Chung
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1303443973-1608-1-git-send-email-andreiw@motorola.com \
--to=andreiw@motorola.com \
--cc=cjb@laptop.org \
--cc=linux-mmc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).