x86/mm/pat: Don't report PAT on CPUs that don't support it
[linux/fpc-iii.git] / block / noop-iosched.c
blob2d1b15d89b4580e855eba7a7afe0b24650e029db
1 /*
2 * elevator noop
3 */
4 #include <linux/blkdev.h>
5 #include <linux/elevator.h>
6 #include <linux/bio.h>
7 #include <linux/module.h>
8 #include <linux/slab.h>
9 #include <linux/init.h>
11 struct noop_data {
12 struct list_head queue;
15 static void noop_merged_requests(struct request_queue *q, struct request *rq,
16 struct request *next)
18 list_del_init(&next->queuelist);
21 static int noop_dispatch(struct request_queue *q, int force)
23 struct noop_data *nd = q->elevator->elevator_data;
24 struct request *rq;
26 rq = list_first_entry_or_null(&nd->queue, struct request, queuelist);
27 if (rq) {
28 list_del_init(&rq->queuelist);
29 elv_dispatch_sort(q, rq);
30 return 1;
32 return 0;
35 static void noop_add_request(struct request_queue *q, struct request *rq)
37 struct noop_data *nd = q->elevator->elevator_data;
39 list_add_tail(&rq->queuelist, &nd->queue);
42 static struct request *
43 noop_former_request(struct request_queue *q, struct request *rq)
45 struct noop_data *nd = q->elevator->elevator_data;
47 if (rq->queuelist.prev == &nd->queue)
48 return NULL;
49 return list_prev_entry(rq, queuelist);
52 static struct request *
53 noop_latter_request(struct request_queue *q, struct request *rq)
55 struct noop_data *nd = q->elevator->elevator_data;
57 if (rq->queuelist.next == &nd->queue)
58 return NULL;
59 return list_next_entry(rq, queuelist);
62 static int noop_init_queue(struct request_queue *q, struct elevator_type *e)
64 struct noop_data *nd;
65 struct elevator_queue *eq;
67 eq = elevator_alloc(q, e);
68 if (!eq)
69 return -ENOMEM;
71 nd = kmalloc_node(sizeof(*nd), GFP_KERNEL, q->node);
72 if (!nd) {
73 kobject_put(&eq->kobj);
74 return -ENOMEM;
76 eq->elevator_data = nd;
78 INIT_LIST_HEAD(&nd->queue);
80 spin_lock_irq(q->queue_lock);
81 q->elevator = eq;
82 spin_unlock_irq(q->queue_lock);
83 return 0;
86 static void noop_exit_queue(struct elevator_queue *e)
88 struct noop_data *nd = e->elevator_data;
90 BUG_ON(!list_empty(&nd->queue));
91 kfree(nd);
94 static struct elevator_type elevator_noop = {
95 .ops.sq = {
96 .elevator_merge_req_fn = noop_merged_requests,
97 .elevator_dispatch_fn = noop_dispatch,
98 .elevator_add_req_fn = noop_add_request,
99 .elevator_former_req_fn = noop_former_request,
100 .elevator_latter_req_fn = noop_latter_request,
101 .elevator_init_fn = noop_init_queue,
102 .elevator_exit_fn = noop_exit_queue,
104 .elevator_name = "noop",
105 .elevator_owner = THIS_MODULE,
108 static int __init noop_init(void)
110 return elv_register(&elevator_noop);
113 static void __exit noop_exit(void)
115 elv_unregister(&elevator_noop);
118 module_init(noop_init);
119 module_exit(noop_exit);
122 MODULE_AUTHOR("Jens Axboe");
123 MODULE_LICENSE("GPL");
124 MODULE_DESCRIPTION("No-op IO scheduler");