The discovered bit in PGCCSR register indicates if the device has been
[linux-2.6/next.git] / include / linux / frontswap.h
blobb25bceae1052f895f29e557672885b7e2d40c6d5
1 #ifndef _LINUX_FRONTSWAP_H
2 #define _LINUX_FRONTSWAP_H
4 #include <linux/swap.h>
5 #include <linux/mm.h>
7 struct frontswap_ops {
8 void (*init)(unsigned);
9 int (*put_page)(unsigned, pgoff_t, struct page *);
10 int (*get_page)(unsigned, pgoff_t, struct page *);
11 void (*flush_page)(unsigned, pgoff_t);
12 void (*flush_area)(unsigned);
15 extern int frontswap_enabled;
16 extern struct frontswap_ops
17 frontswap_register_ops(struct frontswap_ops *ops);
18 extern void frontswap_shrink(unsigned long);
19 extern unsigned long frontswap_curr_pages(void);
21 extern void __frontswap_init(unsigned type);
22 extern int __frontswap_put_page(struct page *page);
23 extern int __frontswap_get_page(struct page *page);
24 extern void __frontswap_flush_page(unsigned, pgoff_t);
25 extern void __frontswap_flush_area(unsigned);
27 #ifdef CONFIG_FRONTSWAP
29 static inline int frontswap_test(struct swap_info_struct *sis, pgoff_t offset)
31 int ret = 0;
33 if (frontswap_enabled && sis->frontswap_map)
34 ret = test_bit(offset, sis->frontswap_map);
35 return ret;
38 static inline void frontswap_set(struct swap_info_struct *sis, pgoff_t offset)
40 if (frontswap_enabled && sis->frontswap_map)
41 set_bit(offset, sis->frontswap_map);
44 static inline void frontswap_clear(struct swap_info_struct *sis, pgoff_t offset)
46 if (frontswap_enabled && sis->frontswap_map)
47 clear_bit(offset, sis->frontswap_map);
50 static inline void frontswap_map_set(struct swap_info_struct *p,
51 unsigned long *map)
53 p->frontswap_map = map;
56 static inline unsigned long *frontswap_map_get(struct swap_info_struct *p)
58 return p->frontswap_map;
60 #else
61 /* all inline routines become no-ops and all externs are ignored */
63 #define frontswap_enabled (0)
65 static inline int frontswap_test(struct swap_info_struct *sis, pgoff_t offset)
67 return 0;
70 static inline void frontswap_set(struct swap_info_struct *sis, pgoff_t offset)
74 static inline void frontswap_clear(struct swap_info_struct *sis, pgoff_t offset)
78 static inline void frontswap_map_set(struct swap_info_struct *p,
79 unsigned long *map)
83 static inline unsigned long *frontswap_map_get(struct swap_info_struct *p)
85 return NULL;
87 #endif
89 static inline int frontswap_put_page(struct page *page)
91 int ret = -1;
93 if (frontswap_enabled)
94 ret = __frontswap_put_page(page);
95 return ret;
98 static inline int frontswap_get_page(struct page *page)
100 int ret = -1;
102 if (frontswap_enabled)
103 ret = __frontswap_get_page(page);
104 return ret;
107 static inline void frontswap_flush_page(unsigned type, pgoff_t offset)
109 if (frontswap_enabled)
110 __frontswap_flush_page(type, offset);
113 static inline void frontswap_flush_area(unsigned type)
115 if (frontswap_enabled)
116 __frontswap_flush_area(type);
119 static inline void frontswap_init(unsigned type)
121 if (frontswap_enabled)
122 __frontswap_init(type);
125 #endif /* _LINUX_FRONTSWAP_H */