1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <linux/mtd/blktrans.h>
15#include <linux/kfifo.h>
16#include <linux/sched.h>
17#include <linux/completion.h>
18#include <linux/mtd/mtd.h>
19
20
21
22struct ftl_zone {
23 bool initialized;
24 int16_t *lba_to_phys_table;
25 struct kfifo free_sectors;
26};
27
28struct sm_ftl {
29 struct mtd_blktrans_dev *trans;
30
31 struct mutex mutex;
32 struct ftl_zone *zones;
33
34
35 int block_size;
36 int zone_size;
37 int zone_count;
38 int max_lba;
39 int smallpagenand;
40 bool readonly;
41 bool unstable;
42 int cis_block;
43 int cis_boffset;
44 int cis_page_offset;
45 void *cis_buffer;
46
47
48 int cache_block;
49 int cache_zone;
50 unsigned char *cache_data;
51 long unsigned int cache_data_invalid_bitmap;
52 bool cache_clean;
53 struct work_struct flush_work;
54 struct timer_list timer;
55
56
57 int heads;
58 int sectors;
59 int cylinders;
60
61 struct attribute_group *disk_attributes;
62};
63
64struct chs_entry {
65 unsigned long size;
66 unsigned short cyl;
67 unsigned char head;
68 unsigned char sec;
69};
70
71
72#define SM_FTL_PARTN_BITS 3
73
74#define sm_printk(format, ...) \
75 printk(KERN_WARNING "sm_ftl" ": " format "\n", ## __VA_ARGS__)
76
77#define dbg(format, ...) \
78 if (debug) \
79 printk(KERN_DEBUG "sm_ftl" ": " format "\n", ## __VA_ARGS__)
80
81#define dbg_verbose(format, ...) \
82 if (debug > 1) \
83 printk(KERN_DEBUG "sm_ftl" ": " format "\n", ## __VA_ARGS__)
84
85
86static int sm_erase_block(struct sm_ftl *ftl, int zone_num, uint16_t block,
87 int put_free);
88static void sm_mark_block_bad(struct sm_ftl *ftl, int zone_num, int block);
89
90static int sm_recheck_media(struct sm_ftl *ftl);
91