Linux 2.6.22
[deliverable/linux.git] / drivers / mmc / card / queue.c
CommitLineData
1da177e4 1/*
98ac2162 2 * linux/drivers/mmc/queue.c
1da177e4
LT
3 *
4 * Copyright (C) 2003 Russell King, All Rights Reserved.
98ac2162 5 * Copyright 2006-2007 Pierre Ossman
1da177e4
LT
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 */
12#include <linux/module.h>
13#include <linux/blkdev.h>
87598a2b 14#include <linux/kthread.h>
1da177e4
LT
15
16#include <linux/mmc/card.h>
17#include <linux/mmc/host.h>
98ac2162 18#include "queue.h"
1da177e4 19
87598a2b 20#define MMC_QUEUE_SUSPENDED (1 << 0)
1da177e4
LT
21
22/*
9c9f2d63 23 * Prepare a MMC request. This just filters out odd stuff.
1da177e4
LT
24 */
25static int mmc_prep_request(struct request_queue *q, struct request *req)
26{
9c9f2d63
PO
27 /*
28 * We only like normal block requests.
29 */
30 if (!blk_fs_request(req) && !blk_pc_request(req)) {
1da177e4 31 blk_dump_rq_flags(req, "MMC bad request");
9c9f2d63 32 return BLKPREP_KILL;
1da177e4
LT
33 }
34
9c9f2d63 35 req->cmd_flags |= REQ_DONTPREP;
1da177e4 36
9c9f2d63 37 return BLKPREP_OK;
1da177e4
LT
38}
39
40static int mmc_queue_thread(void *d)
41{
42 struct mmc_queue *mq = d;
43 struct request_queue *q = mq->queue;
1da177e4
LT
44
45 /*
46 * Set iothread to ensure that we aren't put to sleep by
47 * the process freezing. We handle suspension ourselves.
48 */
49 current->flags |= PF_MEMALLOC|PF_NOFREEZE;
50
1da177e4 51 down(&mq->thread_sem);
1da177e4
LT
52 do {
53 struct request *req = NULL;
54
55 spin_lock_irq(q->queue_lock);
56 set_current_state(TASK_INTERRUPTIBLE);
57 if (!blk_queue_plugged(q))