i2c-viapro: Add VIA VX900 device ID
[deliverable/linux.git] / include / linux / frontswap.h
1 #ifndef _LINUX_FRONTSWAP_H
2 #define _LINUX_FRONTSWAP_H
3
4 #include <linux/swap.h>
5 #include <linux/mm.h>
6 #include <linux/bitops.h>
7
8 struct frontswap_ops {
9 void (*init)(unsigned);
10 int (*store)(unsigned, pgoff_t, struct page *);
11 int (*load)(unsigned, pgoff_t, struct page *);
12 void (*invalidate_page)(unsigned, pgoff_t);
13 void (*invalidate_area)(unsigned);
14 };
15
16 extern bool frontswap_enabled;
17 extern struct frontswap_ops
18 frontswap_register_ops(struct frontswap_ops *ops);
19 extern void frontswap_shrink(unsigned long);
20 extern unsigned long frontswap_curr_pages(void);
21 extern void frontswap_writethrough(bool);
22 #define FRONTSWAP_HAS_EXCLUSIVE_GETS
23 extern void frontswap_tmem_exclusive_gets(bool);
24
25 extern void __frontswap_init(unsigned type);
26 extern int __frontswap_store(struct page *page);
27 extern int __frontswap_load(struct page *page);
28 extern void __frontswap_invalidate_page(unsigned, pgoff_t);
29 extern void __frontswap_invalidate_area(unsigned);
30
31 #ifdef CONFIG_FRONTSWAP
32
33 static inline bool frontswap_test(struct swap_info_struct *sis, pgoff_t offset)
34 {
35 bool ret = false;
36
37 if (frontswap_enabled && sis->frontswap_map)
38 ret = test_bit(offset, sis->frontswap_map);
39 return ret;
40 }
41
42 static inline void frontswap_set(struct swap_info_struct *sis, pgoff_t offset)
43 {
44 if (frontswap_enabled && sis->frontswap_map)
45 set_bit(offset, sis->frontswap_map);
46 }
47
48 static inline void frontswap_clear(struct swap_info_struct *sis, pgoff_t offset)
49 {
50 if (frontswap_enabled && sis->frontswap_map)
51 clear_bit(offset, sis->frontswap_map);
52 }
53
54 static inline void frontswap_map_set(struct swap_info_struct *p,
55 unsigned long *map)
56 {
57 p->frontswap_map = map;
58 }
59
60 static inline unsigned long *frontswap_map_get(struct swap_info_struct *p)
61 {
62 return p->frontswap_map;
63 }
64 #else
65 /* all inline routines become no-ops and all externs are ignored */
66
67 #define frontswap_enabled (0)
68
69 static inline bool frontswap_test(struct swap_info_struct *sis, pgoff_t offset)
70 {
71 return false;
72 }
73
74 static inline void frontswap_set(struct swap_info_struct *sis, pgoff_t offset)
75 {
76 }
77
78 static inline void frontswap_clear(struct swap_info_struct *sis, pgoff_t offset)
79 {
80 }
81
82 static inline void frontswap_map_set(struct swap_info_struct *p,
83 unsigned long *map)
84 {
85 }
86
87 static inline unsigned long *frontswap_map_get(struct swap_info_struct *p)
88 {
89 return NULL;
90 }
91 #endif
92
93 static inline int frontswap_store(struct page *page)
94 {
95 int ret = -1;
96
97 if (frontswap_enabled)
98 ret = __frontswap_store(page);
99 return ret;
100 }
101
102 static inline int frontswap_load(struct page *page)
103 {
104 int ret = -1;
105
106 if (frontswap_enabled)
107 ret = __frontswap_load(page);
108 return ret;
109 }
110
111 static inline void frontswap_invalidate_page(unsigned type, pgoff_t offset)
112 {
113 if (frontswap_enabled)
114 __frontswap_invalidate_page(type, offset);
115 }
116
117 static inline void frontswap_invalidate_area(unsigned type)
118 {
119 if (frontswap_enabled)
120 __frontswap_invalidate_area(type);
121 }
122
123 static inline void frontswap_init(unsigned type)
124 {
125 if (frontswap_enabled)
126 __frontswap_init(type);
127 }
128
129 #endif /* _LINUX_FRONTSWAP_H */
This page took 0.034909 seconds and 5 git commands to generate.