0001
0002
0003
0004
0005
0006 #include <linux/bitops.h>
0007 #include <linux/mtd/mtd.h>
0008
0009
0010 struct sm_oob {
0011 uint32_t reserved;
0012 uint8_t data_status;
0013 uint8_t block_status;
0014 uint8_t lba_copy1[2];
0015 uint8_t ecc2[3];
0016 uint8_t lba_copy2[2];
0017 uint8_t ecc1[3];
0018 } __packed;
0019
0020
0021
0022 #define SM_SECTOR_SIZE 512
0023
0024
0025 #define SM_OOB_SIZE 16
0026
0027
0028
0029 #define SM_MAX_ZONE_SIZE 1024
0030
0031
0032 #define SM_SMALL_PAGE 256
0033 #define SM_SMALL_OOB_SIZE 8
0034
0035
0036 int sm_register_device(struct mtd_info *mtd, int smartmedia);
0037
0038
0039 static inline int sm_sector_valid(struct sm_oob *oob)
0040 {
0041 return hweight16(oob->data_status) >= 5;
0042 }
0043
0044 static inline int sm_block_valid(struct sm_oob *oob)
0045 {
0046 return hweight16(oob->block_status) >= 7;
0047 }
0048
0049 static inline int sm_block_erased(struct sm_oob *oob)
0050 {
0051 static const uint32_t erased_pattern[4] = {
0052 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
0053
0054
0055 if (!memcmp(oob, erased_pattern, sizeof(*oob)))
0056 return 1;
0057 return 0;
0058 }