diff options
author | Andrei Warkentin <andreiw@motorola.com> | 2011-04-21 23:46:13 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2011-05-24 21:02:38 -0400 |
commit | f06c9153f5ecd47dfed23f87b9d08e42ff0e4170 (patch) | |
tree | 0557ae6ba11f6bf1c100f3432a1547c62cbcc864 /drivers/mmc | |
parent | 393c1a34dd852dbf0c409ec94dd48057100480ea (diff) |
mmc: Ensure hardware partitions don't mess with mmcblk device naming.
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>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | 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 adf0ed3f2c08..e5bf2bfb5463 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -75,6 +75,7 @@ static int max_devices; | |||
75 | 75 | ||
76 | /* 256 minors, so at most 256 separate devices */ | 76 | /* 256 minors, so at most 256 separate devices */ |
77 | static DECLARE_BITMAP(dev_use, 256); | 77 | static DECLARE_BITMAP(dev_use, 256); |
78 | static DECLARE_BITMAP(name_use, 256); | ||
78 | 79 | ||
79 | /* | 80 | /* |
80 | * There is one mmc_blk_data per slot. | 81 | * There is one mmc_blk_data per slot. |
@@ -88,6 +89,7 @@ struct mmc_blk_data { | |||
88 | unsigned int usage; | 89 | unsigned int usage; |
89 | unsigned int read_only; | 90 | unsigned int read_only; |
90 | unsigned int part_type; | 91 | unsigned int part_type; |
92 | unsigned int name_idx; | ||
91 | 93 | ||
92 | /* | 94 | /* |
93 | * Only set in main mmc_blk_data associated | 95 | * Only set in main mmc_blk_data associated |
@@ -767,6 +769,20 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, | |||
767 | } | 769 | } |
768 | 770 | ||
769 | /* | 771 | /* |
772 | * !subname implies we are creating main mmc_blk_data that will be | ||
773 | * associated with mmc_card with mmc_set_drvdata. Due to device | ||
774 | * partitions, devidx will not coincide with a per-physical card | ||
775 | * index anymore so we keep track of a name index. | ||
776 | */ | ||
777 | if (!subname) { | ||
778 | md->name_idx = find_first_zero_bit(name_use, max_devices); | ||
779 | __set_bit(md->name_idx, name_use); | ||
780 | } | ||
781 | else | ||
782 | md->name_idx = ((struct mmc_blk_data *) | ||
783 | dev_to_disk(parent)->private_data)->name_idx; | ||
784 | |||
785 | /* | ||
770 | * Set the read-only status based on the supported commands | 786 | * Set the read-only status based on the supported commands |
771 | * and the write protect switch. | 787 | * and the write protect switch. |
772 | */ | 788 | */ |
@@ -811,13 +827,8 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, | |||
811 | * messages to tell when the card is present. | 827 | * messages to tell when the card is present. |
812 | */ | 828 | */ |
813 | 829 | ||
814 | if (subname) | 830 | snprintf(md->disk->disk_name, sizeof(md->disk->disk_name), |
815 | snprintf(md->disk->disk_name, sizeof(md->disk->disk_name), | 831 | "mmcblk%d%s", md->name_idx, subname ? subname : ""); |
816 | "mmcblk%d%s", | ||
817 | mmc_get_devidx(dev_to_disk(parent)), subname); | ||
818 | else | ||
819 | snprintf(md->disk->disk_name, sizeof(md->disk->disk_name), | ||
820 | "mmcblk%d", devidx); | ||
821 | 832 | ||
822 | blk_queue_logical_block_size(md->queue.queue, 512); | 833 | blk_queue_logical_block_size(md->queue.queue, 512); |
823 | set_capacity(md->disk, size); | 834 | set_capacity(md->disk, size); |
@@ -944,6 +955,7 @@ static void mmc_blk_remove_parts(struct mmc_card *card, | |||
944 | struct list_head *pos, *q; | 955 | struct list_head *pos, *q; |
945 | struct mmc_blk_data *part_md; | 956 | struct mmc_blk_data *part_md; |
946 | 957 | ||
958 | __clear_bit(md->name_idx, name_use); | ||
947 | list_for_each_safe(pos, q, &md->part) { | 959 | list_for_each_safe(pos, q, &md->part) { |
948 | part_md = list_entry(pos, struct mmc_blk_data, part); | 960 | part_md = list_entry(pos, struct mmc_blk_data, part); |
949 | list_del(pos); | 961 | list_del(pos); |