drivers: use req op accessor
[cascardo/linux.git] / drivers / mmc / card / queue.h
1 #ifndef MMC_QUEUE_H
2 #define MMC_QUEUE_H
3
4 static inline bool mmc_req_is_special(struct request *req)
5 {
6         return req && (req->cmd_flags & REQ_FLUSH || req_op(req) == REQ_OP_DISCARD);
7 }
8
9 struct request;
10 struct task_struct;
11
12 struct mmc_blk_request {
13         struct mmc_request      mrq;
14         struct mmc_command      sbc;
15         struct mmc_command      cmd;
16         struct mmc_command      stop;
17         struct mmc_data         data;
18         int                     retune_retry_done;
19 };
20
21 enum mmc_packed_type {
22         MMC_PACKED_NONE = 0,
23         MMC_PACKED_WRITE,
24 };
25
26 #define mmc_packed_cmd(type)    ((type) != MMC_PACKED_NONE)
27 #define mmc_packed_wr(type)     ((type) == MMC_PACKED_WRITE)
28
29 struct mmc_packed {
30         struct list_head        list;
31         u32                     cmd_hdr[1024];
32         unsigned int            blocks;
33         u8                      nr_entries;
34         u8                      retries;
35         s16                     idx_failure;
36 };
37
38 struct mmc_queue_req {
39         struct request          *req;
40         struct mmc_blk_request  brq;
41         struct scatterlist      *sg;
42         char                    *bounce_buf;
43         struct scatterlist      *bounce_sg;
44         unsigned int            bounce_sg_len;
45         struct mmc_async_req    mmc_active;
46         enum mmc_packed_type    cmd_type;
47         struct mmc_packed       *packed;
48 };
49
50 struct mmc_queue {
51         struct mmc_card         *card;
52         struct task_struct      *thread;
53         struct semaphore        thread_sem;
54         unsigned int            flags;
55 #define MMC_QUEUE_SUSPENDED     (1 << 0)
56 #define MMC_QUEUE_NEW_REQUEST   (1 << 1)
57
58         int                     (*issue_fn)(struct mmc_queue *, struct request *);
59         void                    *data;
60         struct request_queue    *queue;
61         struct mmc_queue_req    mqrq[2];
62         struct mmc_queue_req    *mqrq_cur;
63         struct mmc_queue_req    *mqrq_prev;
64 };
65
66 extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
67                           const char *);
68 extern void mmc_cleanup_queue(struct mmc_queue *);
69 extern void mmc_queue_suspend(struct mmc_queue *);
70 extern void mmc_queue_resume(struct mmc_queue *);
71
72 extern unsigned int mmc_queue_map_sg(struct mmc_queue *,
73                                      struct mmc_queue_req *);
74 extern void mmc_queue_bounce_pre(struct mmc_queue_req *);
75 extern void mmc_queue_bounce_post(struct mmc_queue_req *);
76
77 extern int mmc_packed_init(struct mmc_queue *, struct mmc_card *);
78 extern void mmc_packed_clean(struct mmc_queue *);
79
80 extern int mmc_access_rpmb(struct mmc_queue *);
81
82 #endif