0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <linux/mtd/blktrans.h>
0012 #include <linux/kfifo.h>
0013 #include <linux/sched.h>
0014 #include <linux/completion.h>
0015 #include <linux/mtd/mtd.h>
0016
0017
0018
0019 struct ftl_zone {
0020 bool initialized;
0021 int16_t *lba_to_phys_table;
0022 struct kfifo free_sectors;
0023 };
0024
0025 struct sm_ftl {
0026 struct mtd_blktrans_dev *trans;
0027
0028 struct mutex mutex;
0029 struct ftl_zone *zones;
0030
0031
0032 int block_size;
0033 int zone_size;
0034 int zone_count;
0035 int max_lba;
0036 int smallpagenand;
0037 bool readonly;
0038 bool unstable;
0039 int cis_block;
0040 int cis_boffset;
0041 int cis_page_offset;
0042 void *cis_buffer;
0043
0044
0045 int cache_block;
0046 int cache_zone;
0047 unsigned char *cache_data;
0048 long unsigned int cache_data_invalid_bitmap;
0049 bool cache_clean;
0050 struct work_struct flush_work;
0051 struct timer_list timer;
0052
0053
0054 int heads;
0055 int sectors;
0056 int cylinders;
0057
0058 struct attribute_group *disk_attributes;
0059 };
0060
0061 struct chs_entry {
0062 unsigned long size;
0063 unsigned short cyl;
0064 unsigned char head;
0065 unsigned char sec;
0066 };
0067
0068
0069 #define SM_FTL_PARTN_BITS 3
0070
0071 #define sm_printk(format, ...) \
0072 printk(KERN_WARNING "sm_ftl" ": " format "\n", ## __VA_ARGS__)
0073
0074 #define dbg(format, ...) \
0075 if (debug) \
0076 printk(KERN_DEBUG "sm_ftl" ": " format "\n", ## __VA_ARGS__)
0077
0078 #define dbg_verbose(format, ...) \
0079 if (debug > 1) \
0080 printk(KERN_DEBUG "sm_ftl" ": " format "\n", ## __VA_ARGS__)
0081
0082
0083 static int sm_erase_block(struct sm_ftl *ftl, int zone_num, uint16_t block,
0084 int put_free);
0085 static void sm_mark_block_bad(struct sm_ftl *ftl, int zone_num, int block);
0086
0087 static int sm_recheck_media(struct sm_ftl *ftl);