This source file includes following definitions.
- sm_sector_valid
- sm_block_valid
- sm_block_erased
1
2
3
4
5
6 #include <linux/bitops.h>
7 #include <linux/mtd/mtd.h>
8
9
10 struct sm_oob {
11 uint32_t reserved;
12 uint8_t data_status;
13 uint8_t block_status;
14 uint8_t lba_copy1[2];
15 uint8_t ecc2[3];
16 uint8_t lba_copy2[2];
17 uint8_t ecc1[3];
18 } __packed;
19
20
21
22 #define SM_SECTOR_SIZE 512
23
24
25 #define SM_OOB_SIZE 16
26
27
28
29 #define SM_MAX_ZONE_SIZE 1024
30
31
32 #define SM_SMALL_PAGE 256
33 #define SM_SMALL_OOB_SIZE 8
34
35
36 int sm_register_device(struct mtd_info *mtd, int smartmedia);
37
38
39 static inline int sm_sector_valid(struct sm_oob *oob)
40 {
41 return hweight16(oob->data_status) >= 5;
42 }
43
44 static inline int sm_block_valid(struct sm_oob *oob)
45 {
46 return hweight16(oob->block_status) >= 7;
47 }
48
49 static inline int sm_block_erased(struct sm_oob *oob)
50 {
51 static const uint32_t erased_pattern[4] = {
52 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
53
54
55 if (!memcmp(oob, erased_pattern, sizeof(*oob)))
56 return 1;
57 return 0;
58 }