This source file includes following definitions.
- devm_exit_badblocks
1
2 #ifndef _LINUX_BADBLOCKS_H
3 #define _LINUX_BADBLOCKS_H
4
5 #include <linux/seqlock.h>
6 #include <linux/device.h>
7 #include <linux/kernel.h>
8 #include <linux/stddef.h>
9 #include <linux/types.h>
10
11 #define BB_LEN_MASK (0x00000000000001FFULL)
12 #define BB_OFFSET_MASK (0x7FFFFFFFFFFFFE00ULL)
13 #define BB_ACK_MASK (0x8000000000000000ULL)
14 #define BB_MAX_LEN 512
15 #define BB_OFFSET(x) (((x) & BB_OFFSET_MASK) >> 9)
16 #define BB_LEN(x) (((x) & BB_LEN_MASK) + 1)
17 #define BB_ACK(x) (!!((x) & BB_ACK_MASK))
18 #define BB_MAKE(a, l, ack) (((a)<<9) | ((l)-1) | ((u64)(!!(ack)) << 63))
19
20
21
22
23
24
25 #define MAX_BADBLOCKS (PAGE_SIZE/8)
26
27 struct badblocks {
28 struct device *dev;
29 int count;
30 int unacked_exist;
31
32
33
34 int shift;
35
36
37 u64 *page;
38 int changed;
39 seqlock_t lock;
40 sector_t sector;
41 sector_t size;
42 };
43
44 int badblocks_check(struct badblocks *bb, sector_t s, int sectors,
45 sector_t *first_bad, int *bad_sectors);
46 int badblocks_set(struct badblocks *bb, sector_t s, int sectors,
47 int acknowledged);
48 int badblocks_clear(struct badblocks *bb, sector_t s, int sectors);
49 void ack_all_badblocks(struct badblocks *bb);
50 ssize_t badblocks_show(struct badblocks *bb, char *page, int unack);
51 ssize_t badblocks_store(struct badblocks *bb, const char *page, size_t len,
52 int unack);
53 int badblocks_init(struct badblocks *bb, int enable);
54 void badblocks_exit(struct badblocks *bb);
55 struct device;
56 int devm_init_badblocks(struct device *dev, struct badblocks *bb);
57 static inline void devm_exit_badblocks(struct device *dev, struct badblocks *bb)
58 {
59 if (bb->dev != dev) {
60 dev_WARN_ONCE(dev, 1, "%s: badblocks instance not associated\n",
61 __func__);
62 return;
63 }
64 badblocks_exit(bb);
65 }
66 #endif