aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/card
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw2@infradead.org>2007-11-21 12:45:12 -0500
committerPierre Ossman <drzeus@drzeus.cx>2007-11-21 12:45:38 -0500
commit1dff314451fa24d6b107aa05393d3169e56a7e0a (patch)
tree6aeca206d6b9ec3b8f3168351822183342e9604c /drivers/mmc/card
parentb37a05069b9ab9fb1e52393a3448d710c50c54d5 (diff)
mmc: Avoid re-using minor numbers before the original device is closed.
Move the code which marks the minor number as free to mmc_blk_put() so that it happens on the final close() (or removal), instead of doing it at removal even when the device is still logically open. Signed-off-by: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc/card')
-rw-r--r--drivers/mmc/card/block.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index acaa05200ae7..aeb32a93f6a0 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -44,6 +44,9 @@
44 * max 8 partitions per card 44 * max 8 partitions per card
45 */ 45 */
46#define MMC_SHIFT 3 46#define MMC_SHIFT 3
47#define MMC_NUM_MINORS (256 >> MMC_SHIFT)
48
49static unsigned long dev_use[MMC_NUM_MINORS/(8*sizeof(unsigned long))];
47 50
48/* 51/*
49 * There is one mmc_blk_data per slot. 52 * There is one mmc_blk_data per slot.
@@ -80,6 +83,9 @@ static void mmc_blk_put(struct mmc_blk_data *md)
80 mutex_lock(&open_lock); 83 mutex_lock(&open_lock);
81 md->usage--; 84 md->usage--;
82 if (md->usage == 0) { 85 if (md->usage == 0) {
86 int devidx = md->disk->first_minor >> MMC_SHIFT;
87 __clear_bit(devidx, dev_use);
88
83 put_disk(md->disk); 89 put_disk(md->disk);
84 kfree(md); 90 kfree(md);
85 } 91 }
@@ -406,9 +412,6 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
406 return 0; 412 return 0;
407} 413}
408 414
409#define MMC_NUM_MINORS (256 >> MMC_SHIFT)
410
411static unsigned long dev_use[MMC_NUM_MINORS/(8*sizeof(unsigned long))];
412 415
413static inline int mmc_blk_readonly(struct mmc_card *card) 416static inline int mmc_blk_readonly(struct mmc_card *card)
414{ 417{
@@ -574,17 +577,12 @@ static void mmc_blk_remove(struct mmc_card *card)
574 struct mmc_blk_data *md = mmc_get_drvdata(card); 577 struct mmc_blk_data *md = mmc_get_drvdata(card);
575 578
576 if (md) { 579 if (md) {
577 int devidx;
578
579 /* Stop new requests from getting into the queue */ 580 /* Stop new requests from getting into the queue */
580 del_gendisk(md->disk); 581 del_gendisk(md->disk);
581 582
582 /* Then flush out any already in there */ 583 /* Then flush out any already in there */
583 mmc_cleanup_queue(&md->queue); 584 mmc_cleanup_queue(&md->queue);
584 585
585 devidx = md->disk->first_minor >> MMC_SHIFT;
586 __clear_bit(devidx, dev_use);
587
588 mmc_blk_put(md); 586 mmc_blk_put(md);
589 } 587 }
590 mmc_set_drvdata(card, NULL); 588 mmc_set_drvdata(card, NULL);