diff options
author | Alex Dubov <oakad@yahoo.com> | 2008-07-25 19:45:01 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-26 12:00:04 -0700 |
commit | 17017d8d2c005734d7088d8281ce2daab8fcb097 (patch) | |
tree | df689658df7d342143ad399bddf0df7257e8ec20 /drivers/memstick/core/mspro_block.c | |
parent | b77899985bdfd85a8e5a6e485033a9b4713d2471 (diff) |
memstick: add "start" and "stop" methods to memstick device
In some cases it may be desirable to ensure that associated driver is not
going to access the media in some period of time. "start" and "stop"
methods are provided therefore to allow it.
Signed-off-by: Alex Dubov <oakad@yahoo.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/memstick/core/mspro_block.c')
-rw-r--r-- | drivers/memstick/core/mspro_block.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c index 477d0fb6e588..004ac4d176d9 100644 --- a/drivers/memstick/core/mspro_block.c +++ b/drivers/memstick/core/mspro_block.c @@ -752,6 +752,37 @@ static int mspro_block_has_request(struct mspro_block_data *msb) return rc; } +static void mspro_block_stop(struct memstick_dev *card) +{ + struct mspro_block_data *msb = memstick_get_drvdata(card); + int rc = 0; + unsigned long flags; + + while (1) { + spin_lock_irqsave(&msb->q_lock, flags); + if (!msb->has_request) { + blk_stop_queue(msb->queue); + rc = 1; + } + spin_unlock_irqrestore(&msb->q_lock, flags); + + if (rc) + break; + + wait_for_completion(&card->mrq_complete); + } +} + +static void mspro_block_start(struct memstick_dev *card) +{ + struct mspro_block_data *msb = memstick_get_drvdata(card); + unsigned long flags; + + spin_lock_irqsave(&msb->q_lock, flags); + blk_start_queue(msb->queue); + spin_unlock_irqrestore(&msb->q_lock, flags); +} + static int mspro_block_queue_thread(void *data) { struct memstick_dev *card = data; @@ -1272,6 +1303,8 @@ static int mspro_block_probe(struct memstick_dev *card) rc = mspro_block_init_disk(card); if (!rc) { card->check = mspro_block_check_card; + card->stop = mspro_block_stop; + card->start = mspro_block_start; return 0; } |