ACPI: thinkpad-acpi: register with the device model
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / md / dm-bio-list.h
blobda4349649f7f2cd5c7c6d628f40d8bf1a1463b84
1 /*
2 * Copyright (C) 2004 Red Hat UK Ltd.
4 * This file is released under the GPL.
5 */
7 #ifndef DM_BIO_LIST_H
8 #define DM_BIO_LIST_H
10 #include <linux/bio.h>
12 struct bio_list {
13 struct bio *head;
14 struct bio *tail;
17 static inline void bio_list_init(struct bio_list *bl)
19 bl->head = bl->tail = NULL;
22 static inline void bio_list_add(struct bio_list *bl, struct bio *bio)
24 bio->bi_next = NULL;
26 if (bl->tail)
27 bl->tail->bi_next = bio;
28 else
29 bl->head = bio;
31 bl->tail = bio;
34 static inline void bio_list_merge(struct bio_list *bl, struct bio_list *bl2)
36 if (!bl2->head)
37 return;
39 if (bl->tail)
40 bl->tail->bi_next = bl2->head;
41 else
42 bl->head = bl2->head;
44 bl->tail = bl2->tail;
47 static inline void bio_list_merge_head(struct bio_list *bl,
48 struct bio_list *bl2)
50 if (!bl2->head)
51 return;
53 if (bl->head)
54 bl2->tail->bi_next = bl->head;
55 else
56 bl->tail = bl2->tail;
58 bl->head = bl2->head;
61 static inline struct bio *bio_list_pop(struct bio_list *bl)
63 struct bio *bio = bl->head;
65 if (bio) {
66 bl->head = bl->head->bi_next;
67 if (!bl->head)
68 bl->tail = NULL;
70 bio->bi_next = NULL;
73 return bio;
76 static inline struct bio *bio_list_get(struct bio_list *bl)
78 struct bio *bio = bl->head;
80 bl->head = bl->tail = NULL;
82 return bio;
85 #endif