diff options
56 files changed, 2698 insertions, 257 deletions
diff --git a/arch/ppc/platforms/ev64360.c b/arch/ppc/platforms/ev64360.c index 90ed375c9b90..f87e06f6bab9 100644 --- a/arch/ppc/platforms/ev64360.c +++ b/arch/ppc/platforms/ev64360.c | |||
@@ -358,13 +358,12 @@ ev64360_setup_mtd(void) | |||
358 | 358 | ||
359 | ptbl_entries = 3; | 359 | ptbl_entries = 3; |
360 | 360 | ||
361 | if ((ptbl = kmalloc(ptbl_entries * sizeof(struct mtd_partition), | 361 | if ((ptbl = kzalloc(ptbl_entries * sizeof(struct mtd_partition), |
362 | GFP_KERNEL)) == NULL) { | 362 | GFP_KERNEL)) == NULL) { |
363 | 363 | ||
364 | printk(KERN_WARNING "Can't alloc MTD partition table\n"); | 364 | printk(KERN_WARNING "Can't alloc MTD partition table\n"); |
365 | return -ENOMEM; | 365 | return -ENOMEM; |
366 | } | 366 | } |
367 | memset(ptbl, 0, ptbl_entries * sizeof(struct mtd_partition)); | ||
368 | 367 | ||
369 | ptbl[0].name = "reserved"; | 368 | ptbl[0].name = "reserved"; |
370 | ptbl[0].offset = 0; | 369 | ptbl[0].offset = 0; |
diff --git a/drivers/mtd/afs.c b/drivers/mtd/afs.c index 6a45be04564b..52d51eb91c16 100644 --- a/drivers/mtd/afs.c +++ b/drivers/mtd/afs.c | |||
@@ -207,11 +207,10 @@ static int parse_afs_partitions(struct mtd_info *mtd, | |||
207 | if (!sz) | 207 | if (!sz) |
208 | return ret; | 208 | return ret; |
209 | 209 | ||
210 | parts = kmalloc(sz, GFP_KERNEL); | 210 | parts = kzalloc(sz, GFP_KERNEL); |
211 | if (!parts) | 211 | if (!parts) |
212 | return -ENOMEM; | 212 | return -ENOMEM; |
213 | 213 | ||
214 | memset(parts, 0, sz); | ||
215 | str = (char *)(parts + idx); | 214 | str = (char *)(parts + idx); |
216 | 215 | ||
217 | /* | 216 | /* |
diff --git a/drivers/mtd/chips/amd_flash.c b/drivers/mtd/chips/amd_flash.c index 16eaca69fb5a..e7999f15d85a 100644 --- a/drivers/mtd/chips/amd_flash.c +++ b/drivers/mtd/chips/amd_flash.c | |||
@@ -643,13 +643,12 @@ static struct mtd_info *amd_flash_probe(struct map_info *map) | |||
643 | int reg_idx; | 643 | int reg_idx; |
644 | int offset; | 644 | int offset; |
645 | 645 | ||
646 | mtd = (struct mtd_info*)kmalloc(sizeof(*mtd), GFP_KERNEL); | 646 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
647 | if (!mtd) { | 647 | if (!mtd) { |
648 | printk(KERN_WARNING | 648 | printk(KERN_WARNING |
649 | "%s: kmalloc failed for info structure\n", map->name); | 649 | "%s: kmalloc failed for info structure\n", map->name); |
650 | return NULL; | 650 | return NULL; |
651 | } | 651 | } |
652 | memset(mtd, 0, sizeof(*mtd)); | ||
653 | mtd->priv = map; | 652 | mtd->priv = map; |
654 | 653 | ||
655 | memset(&temp, 0, sizeof(temp)); | 654 | memset(&temp, 0, sizeof(temp)); |
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index e24973636e61..11de54535526 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c | |||
@@ -337,12 +337,11 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary) | |||
337 | struct mtd_info *mtd; | 337 | struct mtd_info *mtd; |
338 | int i; | 338 | int i; |
339 | 339 | ||
340 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 340 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
341 | if (!mtd) { | 341 | if (!mtd) { |
342 | printk(KERN_ERR "Failed to allocate memory for MTD device\n"); | 342 | printk(KERN_ERR "Failed to allocate memory for MTD device\n"); |
343 | return NULL; | 343 | return NULL; |
344 | } | 344 | } |
345 | memset(mtd, 0, sizeof(*mtd)); | ||
346 | mtd->priv = map; | 345 | mtd->priv = map; |
347 | mtd->type = MTD_NORFLASH; | 346 | mtd->type = MTD_NORFLASH; |
348 | 347 | ||
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index ca0882b5819f..e3acd398fb37 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c | |||
@@ -257,12 +257,11 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary) | |||
257 | struct mtd_info *mtd; | 257 | struct mtd_info *mtd; |
258 | int i; | 258 | int i; |
259 | 259 | ||
260 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 260 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
261 | if (!mtd) { | 261 | if (!mtd) { |
262 | printk(KERN_WARNING "Failed to allocate memory for MTD device\n"); | 262 | printk(KERN_WARNING "Failed to allocate memory for MTD device\n"); |
263 | return NULL; | 263 | return NULL; |
264 | } | 264 | } |
265 | memset(mtd, 0, sizeof(*mtd)); | ||
266 | mtd->priv = map; | 265 | mtd->priv = map; |
267 | mtd->type = MTD_NORFLASH; | 266 | mtd->type = MTD_NORFLASH; |
268 | 267 | ||
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c index fae70a5db540..d56849f5f107 100644 --- a/drivers/mtd/chips/cfi_cmdset_0020.c +++ b/drivers/mtd/chips/cfi_cmdset_0020.c | |||
@@ -172,7 +172,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map) | |||
172 | int i,j; | 172 | int i,j; |
173 | unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave; | 173 | unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave; |
174 | 174 | ||
175 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 175 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
176 | //printk(KERN_DEBUG "number of CFI chips: %d\n", cfi->numchips); | 176 | //printk(KERN_DEBUG "number of CFI chips: %d\n", cfi->numchips); |
177 | 177 | ||
178 | if (!mtd) { | 178 | if (!mtd) { |
@@ -181,7 +181,6 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map) | |||
181 | return NULL; | 181 | return NULL; |
182 | } | 182 | } |
183 | 183 | ||
184 | memset(mtd, 0, sizeof(*mtd)); | ||
185 | mtd->priv = map; | 184 | mtd->priv = map; |
186 | mtd->type = MTD_NORFLASH; | 185 | mtd->type = MTD_NORFLASH; |
187 | mtd->size = devsize * cfi->numchips; | 186 | mtd->size = devsize * cfi->numchips; |
diff --git a/drivers/mtd/chips/gen_probe.c b/drivers/mtd/chips/gen_probe.c index cdb0f590b40c..77843d560ae4 100644 --- a/drivers/mtd/chips/gen_probe.c +++ b/drivers/mtd/chips/gen_probe.c | |||
@@ -113,13 +113,12 @@ static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chi | |||
113 | } | 113 | } |
114 | 114 | ||
115 | mapsize = (max_chips + BITS_PER_LONG-1) / BITS_PER_LONG; | 115 | mapsize = (max_chips + BITS_PER_LONG-1) / BITS_PER_LONG; |
116 | chip_map = kmalloc(mapsize, GFP_KERNEL); | 116 | chip_map = kzalloc(mapsize, GFP_KERNEL); |
117 | if (!chip_map) { | 117 | if (!chip_map) { |
118 | printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name); | 118 | printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name); |
119 | kfree(cfi.cfiq); | 119 | kfree(cfi.cfiq); |
120 | return NULL; | 120 | return NULL; |
121 | } | 121 | } |
122 | memset (chip_map, 0, mapsize); | ||
123 | 122 | ||
124 | set_bit(0, chip_map); /* Mark first chip valid */ | 123 | set_bit(0, chip_map); /* Mark first chip valid */ |
125 | 124 | ||
diff --git a/drivers/mtd/chips/jedec.c b/drivers/mtd/chips/jedec.c index 2c3f019197c1..14e57b2bf842 100644 --- a/drivers/mtd/chips/jedec.c +++ b/drivers/mtd/chips/jedec.c | |||
@@ -116,11 +116,10 @@ static struct mtd_info *jedec_probe(struct map_info *map) | |||
116 | char Part[200]; | 116 | char Part[200]; |
117 | memset(&priv,0,sizeof(priv)); | 117 | memset(&priv,0,sizeof(priv)); |
118 | 118 | ||
119 | MTD = kmalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL); | 119 | MTD = kzalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL); |
120 | if (!MTD) | 120 | if (!MTD) |
121 | return NULL; | 121 | return NULL; |
122 | 122 | ||
123 | memset(MTD, 0, sizeof(struct mtd_info) + sizeof(struct jedec_private)); | ||
124 | priv = (struct jedec_private *)&MTD[1]; | 123 | priv = (struct jedec_private *)&MTD[1]; |
125 | 124 | ||
126 | my_bank_size = map->size; | 125 | my_bank_size = map->size; |
diff --git a/drivers/mtd/chips/map_absent.c b/drivers/mtd/chips/map_absent.c index ac01a949b687..fc478c0f93f5 100644 --- a/drivers/mtd/chips/map_absent.c +++ b/drivers/mtd/chips/map_absent.c | |||
@@ -47,13 +47,11 @@ static struct mtd_info *map_absent_probe(struct map_info *map) | |||
47 | { | 47 | { |
48 | struct mtd_info *mtd; | 48 | struct mtd_info *mtd; |
49 | 49 | ||
50 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 50 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
51 | if (!mtd) { | 51 | if (!mtd) { |
52 | return NULL; | 52 | return NULL; |
53 | } | 53 | } |
54 | 54 | ||
55 | memset(mtd, 0, sizeof(*mtd)); | ||
56 | |||
57 | map->fldrv = &map_absent_chipdrv; | 55 | map->fldrv = &map_absent_chipdrv; |
58 | mtd->priv = map; | 56 | mtd->priv = map; |
59 | mtd->name = map->name; | 57 | mtd->name = map->name; |
diff --git a/drivers/mtd/chips/map_ram.c b/drivers/mtd/chips/map_ram.c index 3a66680abfd0..5cb6d5263661 100644 --- a/drivers/mtd/chips/map_ram.c +++ b/drivers/mtd/chips/map_ram.c | |||
@@ -55,12 +55,10 @@ static struct mtd_info *map_ram_probe(struct map_info *map) | |||
55 | #endif | 55 | #endif |
56 | /* OK. It seems to be RAM. */ | 56 | /* OK. It seems to be RAM. */ |
57 | 57 | ||
58 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 58 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
59 | if (!mtd) | 59 | if (!mtd) |
60 | return NULL; | 60 | return NULL; |
61 | 61 | ||
62 | memset(mtd, 0, sizeof(*mtd)); | ||
63 | |||
64 | map->fldrv = &mapram_chipdrv; | 62 | map->fldrv = &mapram_chipdrv; |
65 | mtd->priv = map; | 63 | mtd->priv = map; |
66 | mtd->name = map->name; | 64 | mtd->name = map->name; |
diff --git a/drivers/mtd/chips/map_rom.c b/drivers/mtd/chips/map_rom.c index 1b328b1378fd..cb27f855074c 100644 --- a/drivers/mtd/chips/map_rom.c +++ b/drivers/mtd/chips/map_rom.c | |||
@@ -31,12 +31,10 @@ static struct mtd_info *map_rom_probe(struct map_info *map) | |||
31 | { | 31 | { |
32 | struct mtd_info *mtd; | 32 | struct mtd_info *mtd; |
33 | 33 | ||
34 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 34 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
35 | if (!mtd) | 35 | if (!mtd) |
36 | return NULL; | 36 | return NULL; |
37 | 37 | ||
38 | memset(mtd, 0, sizeof(*mtd)); | ||
39 | |||
40 | map->fldrv = &maprom_chipdrv; | 38 | map->fldrv = &maprom_chipdrv; |
41 | mtd->priv = map; | 39 | mtd->priv = map; |
42 | mtd->name = map->name; | 40 | mtd->name = map->name; |
diff --git a/drivers/mtd/chips/sharp.c b/drivers/mtd/chips/sharp.c index 967abbecdff9..c9cd3d21ccfa 100644 --- a/drivers/mtd/chips/sharp.c +++ b/drivers/mtd/chips/sharp.c | |||
@@ -112,18 +112,16 @@ static struct mtd_info *sharp_probe(struct map_info *map) | |||
112 | struct sharp_info *sharp = NULL; | 112 | struct sharp_info *sharp = NULL; |
113 | int width; | 113 | int width; |
114 | 114 | ||
115 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 115 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
116 | if(!mtd) | 116 | if(!mtd) |
117 | return NULL; | 117 | return NULL; |
118 | 118 | ||
119 | sharp = kmalloc(sizeof(*sharp), GFP_KERNEL); | 119 | sharp = kzalloc(sizeof(*sharp), GFP_KERNEL); |
120 | if(!sharp) { | 120 | if(!sharp) { |
121 | kfree(mtd); | 121 | kfree(mtd); |
122 | return NULL; | 122 | return NULL; |
123 | } | 123 | } |
124 | 124 | ||
125 | memset(mtd, 0, sizeof(*mtd)); | ||
126 | |||
127 | width = sharp_probe_map(map,mtd); | 125 | width = sharp_probe_map(map,mtd); |
128 | if(!width){ | 126 | if(!width){ |
129 | kfree(mtd); | 127 | kfree(mtd); |
@@ -143,7 +141,6 @@ static struct mtd_info *sharp_probe(struct map_info *map) | |||
143 | mtd->writesize = 1; | 141 | mtd->writesize = 1; |
144 | mtd->name = map->name; | 142 | mtd->name = map->name; |
145 | 143 | ||
146 | memset(sharp, 0, sizeof(*sharp)); | ||
147 | sharp->chipshift = 23; | 144 | sharp->chipshift = 23; |
148 | sharp->numchips = 1; | 145 | sharp->numchips = 1; |
149 | sharp->chips[0].start = 0; | 146 | sharp->chips[0].start = 0; |
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c index a7a7bfe33879..23fab14f1637 100644 --- a/drivers/mtd/cmdlinepart.c +++ b/drivers/mtd/cmdlinepart.c | |||
@@ -163,13 +163,12 @@ static struct mtd_partition * newpart(char *s, | |||
163 | *num_parts = this_part + 1; | 163 | *num_parts = this_part + 1; |
164 | alloc_size = *num_parts * sizeof(struct mtd_partition) + | 164 | alloc_size = *num_parts * sizeof(struct mtd_partition) + |
165 | extra_mem_size; | 165 | extra_mem_size; |
166 | parts = kmalloc(alloc_size, GFP_KERNEL); | 166 | parts = kzalloc(alloc_size, GFP_KERNEL); |
167 | if (!parts) | 167 | if (!parts) |
168 | { | 168 | { |
169 | printk(KERN_ERR ERRP "out of memory\n"); | 169 | printk(KERN_ERR ERRP "out of memory\n"); |
170 | return NULL; | 170 | return NULL; |
171 | } | 171 | } |
172 | memset(parts, 0, alloc_size); | ||
173 | extra_mem = (unsigned char *)(parts + *num_parts); | 172 | extra_mem = (unsigned char *)(parts + *num_parts); |
174 | } | 173 | } |
175 | /* enter this partition (offset will be calculated later if it is zero at this point) */ | 174 | /* enter this partition (offset will be calculated later if it is zero at this point) */ |
@@ -346,7 +345,7 @@ static int parse_cmdline_partitions(struct mtd_info *master, | |||
346 | * | 345 | * |
347 | * This function needs to be visible for bootloaders. | 346 | * This function needs to be visible for bootloaders. |
348 | */ | 347 | */ |
349 | int mtdpart_setup(char *s) | 348 | static int mtdpart_setup(char *s) |
350 | { | 349 | { |
351 | cmdline = s; | 350 | cmdline = s; |
352 | return 1; | 351 | return 1; |
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index 401c6a294baa..6d917a4daa9d 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c | |||
@@ -295,10 +295,9 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) | |||
295 | if (!devname) | 295 | if (!devname) |
296 | return NULL; | 296 | return NULL; |
297 | 297 | ||
298 | dev = kmalloc(sizeof(struct block2mtd_dev), GFP_KERNEL); | 298 | dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL); |
299 | if (!dev) | 299 | if (!dev) |
300 | return NULL; | 300 | return NULL; |
301 | memset(dev, 0, sizeof(*dev)); | ||
302 | 301 | ||
303 | /* Get a handle on the device */ | 302 | /* Get a handle on the device */ |
304 | bdev = open_bdev_excl(devname, O_RDWR, NULL); | 303 | bdev = open_bdev_excl(devname, O_RDWR, NULL); |
diff --git a/drivers/mtd/devices/ms02-nv.c b/drivers/mtd/devices/ms02-nv.c index 08dfb899b272..9cff119a2024 100644 --- a/drivers/mtd/devices/ms02-nv.c +++ b/drivers/mtd/devices/ms02-nv.c | |||
@@ -131,11 +131,10 @@ static int __init ms02nv_init_one(ulong addr) | |||
131 | int ret = -ENODEV; | 131 | int ret = -ENODEV; |
132 | 132 | ||
133 | /* The module decodes 8MiB of address space. */ | 133 | /* The module decodes 8MiB of address space. */ |
134 | mod_res = kmalloc(sizeof(*mod_res), GFP_KERNEL); | 134 | mod_res = kzalloc(sizeof(*mod_res), GFP_KERNEL); |
135 | if (!mod_res) | 135 | if (!mod_res) |
136 | return -ENOMEM; | 136 | return -ENOMEM; |
137 | 137 | ||
138 | memset(mod_res, 0, sizeof(*mod_res)); | ||
139 | mod_res->name = ms02nv_name; | 138 | mod_res->name = ms02nv_name; |
140 | mod_res->start = addr; | 139 | mod_res->start = addr; |
141 | mod_res->end = addr + MS02NV_SLOT_SIZE - 1; | 140 | mod_res->end = addr + MS02NV_SLOT_SIZE - 1; |
@@ -153,24 +152,21 @@ static int __init ms02nv_init_one(ulong addr) | |||
153 | } | 152 | } |
154 | 153 | ||
155 | ret = -ENOMEM; | 154 | ret = -ENOMEM; |
156 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 155 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
157 | if (!mtd) | 156 | if (!mtd) |
158 | goto err_out_mod_res_rel; | 157 | goto err_out_mod_res_rel; |
159 | memset(mtd, 0, sizeof(*mtd)); | 158 | mp = kzalloc(sizeof(*mp), GFP_KERNEL); |
160 | mp = kmalloc(sizeof(*mp), GFP_KERNEL); | ||
161 | if (!mp) | 159 | if (!mp) |
162 | goto err_out_mtd; | 160 | goto err_out_mtd; |
163 | memset(mp, 0, sizeof(*mp)); | ||
164 | 161 | ||
165 | mtd->priv = mp; | 162 | mtd->priv = mp; |
166 | mp->resource.module = mod_res; | 163 | mp->resource.module = mod_res; |
167 | 164 | ||
168 | /* Firmware's diagnostic NVRAM area. */ | 165 | /* Firmware's diagnostic NVRAM area. */ |
169 | diag_res = kmalloc(sizeof(*diag_res), GFP_KERNEL); | 166 | diag_res = kzalloc(sizeof(*diag_res), GFP_KERNEL); |
170 | if (!diag_res) | 167 | if (!diag_res) |
171 | goto err_out_mp; | 168 | goto err_out_mp; |
172 | 169 | ||
173 | memset(diag_res, 0, sizeof(*diag_res)); | ||
174 | diag_res->name = ms02nv_res_diag_ram; | 170 | diag_res->name = ms02nv_res_diag_ram; |
175 | diag_res->start = addr; | 171 | diag_res->start = addr; |
176 | diag_res->end = addr + MS02NV_RAM - 1; | 172 | diag_res->end = addr + MS02NV_RAM - 1; |
@@ -180,11 +176,10 @@ static int __init ms02nv_init_one(ulong addr) | |||
180 | mp->resource.diag_ram = diag_res; | 176 | mp->resource.diag_ram = diag_res; |
181 | 177 | ||
182 | /* User-available general-purpose NVRAM area. */ | 178 | /* User-available general-purpose NVRAM area. */ |
183 | user_res = kmalloc(sizeof(*user_res), GFP_KERNEL); | 179 | user_res = kzalloc(sizeof(*user_res), GFP_KERNEL); |
184 | if (!user_res) | 180 | if (!user_res) |
185 | goto err_out_diag_res; | 181 | goto err_out_diag_res; |
186 | 182 | ||
187 | memset(user_res, 0, sizeof(*user_res)); | ||
188 | user_res->name = ms02nv_res_user_ram; | 183 | user_res->name = ms02nv_res_user_ram; |
189 | user_res->start = addr + MS02NV_RAM; | 184 | user_res->start = addr + MS02NV_RAM; |
190 | user_res->end = addr + size - 1; | 185 | user_res->end = addr + size - 1; |
@@ -194,11 +189,10 @@ static int __init ms02nv_init_one(ulong addr) | |||
194 | mp->resource.user_ram = user_res; | 189 | mp->resource.user_ram = user_res; |
195 | 190 | ||
196 | /* Control and status register. */ | 191 | /* Control and status register. */ |
197 | csr_res = kmalloc(sizeof(*csr_res), GFP_KERNEL); | 192 | csr_res = kzalloc(sizeof(*csr_res), GFP_KERNEL); |
198 | if (!csr_res) | 193 | if (!csr_res) |
199 | goto err_out_user_res; | 194 | goto err_out_user_res; |
200 | 195 | ||
201 | memset(csr_res, 0, sizeof(*csr_res)); | ||
202 | csr_res->name = ms02nv_res_csr; | 196 | csr_res->name = ms02nv_res_csr; |
203 | csr_res->start = addr + MS02NV_CSR; | 197 | csr_res->start = addr + MS02NV_CSR; |
204 | csr_res->end = addr + MS02NV_CSR + 3; | 198 | csr_res->end = addr + MS02NV_CSR + 3; |
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index 6c7337f9ebbb..56cc1ca7ffd5 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c | |||
@@ -126,12 +126,10 @@ static int register_device(char *name, unsigned long start, unsigned long len) | |||
126 | struct phram_mtd_list *new; | 126 | struct phram_mtd_list *new; |
127 | int ret = -ENOMEM; | 127 | int ret = -ENOMEM; |
128 | 128 | ||
129 | new = kmalloc(sizeof(*new), GFP_KERNEL); | 129 | new = kzalloc(sizeof(*new), GFP_KERNEL); |
130 | if (!new) | 130 | if (!new) |
131 | goto out0; | 131 | goto out0; |
132 | 132 | ||
133 | memset(new, 0, sizeof(*new)); | ||
134 | |||
135 | ret = -EIO; | 133 | ret = -EIO; |
136 | new->mtd.priv = ioremap(start, len); | 134 | new->mtd.priv = ioremap(start, len); |
137 | if (!new->mtd.priv) { | 135 | if (!new->mtd.priv) { |
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c index 542a0c009006..5f49248a4856 100644 --- a/drivers/mtd/devices/slram.c +++ b/drivers/mtd/devices/slram.c | |||
@@ -168,19 +168,16 @@ static int register_device(char *name, unsigned long start, unsigned long length | |||
168 | E("slram: Cannot allocate new MTD device.\n"); | 168 | E("slram: Cannot allocate new MTD device.\n"); |
169 | return(-ENOMEM); | 169 | return(-ENOMEM); |
170 | } | 170 | } |
171 | (*curmtd)->mtdinfo = kmalloc(sizeof(struct mtd_info), GFP_KERNEL); | 171 | (*curmtd)->mtdinfo = kzalloc(sizeof(struct mtd_info), GFP_KERNEL); |
172 | (*curmtd)->next = NULL; | 172 | (*curmtd)->next = NULL; |
173 | 173 | ||
174 | if ((*curmtd)->mtdinfo) { | 174 | if ((*curmtd)->mtdinfo) { |
175 | memset((char *)(*curmtd)->mtdinfo, 0, sizeof(struct mtd_info)); | ||
176 | (*curmtd)->mtdinfo->priv = | 175 | (*curmtd)->mtdinfo->priv = |
177 | kmalloc(sizeof(slram_priv_t), GFP_KERNEL); | 176 | kzalloc(sizeof(slram_priv_t), GFP_KERNEL); |
178 | 177 | ||
179 | if (!(*curmtd)->mtdinfo->priv) { | 178 | if (!(*curmtd)->mtdinfo->priv) { |
180 | kfree((*curmtd)->mtdinfo); | 179 | kfree((*curmtd)->mtdinfo); |
181 | (*curmtd)->mtdinfo = NULL; | 180 | (*curmtd)->mtdinfo = NULL; |
182 | } else { | ||
183 | memset((*curmtd)->mtdinfo->priv,0,sizeof(slram_priv_t)); | ||
184 | } | 181 | } |
185 | } | 182 | } |
186 | 183 | ||
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index 8a878b34eca0..24235d4f1d23 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c | |||
@@ -1033,7 +1033,7 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
1033 | { | 1033 | { |
1034 | partition_t *partition; | 1034 | partition_t *partition; |
1035 | 1035 | ||
1036 | partition = kmalloc(sizeof(partition_t), GFP_KERNEL); | 1036 | partition = kzalloc(sizeof(partition_t), GFP_KERNEL); |
1037 | 1037 | ||
1038 | if (!partition) { | 1038 | if (!partition) { |
1039 | printk(KERN_WARNING "No memory to scan for FTL on %s\n", | 1039 | printk(KERN_WARNING "No memory to scan for FTL on %s\n", |
@@ -1041,8 +1041,6 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
1041 | return; | 1041 | return; |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | memset(partition, 0, sizeof(partition_t)); | ||
1045 | |||
1046 | partition->mbd.mtd = mtd; | 1044 | partition->mbd.mtd = mtd; |
1047 | 1045 | ||
1048 | if ((scan_header(partition) == 0) && | 1046 | if ((scan_header(partition) == 0) && |
@@ -1054,7 +1052,7 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
1054 | le32_to_cpu(partition->header.FormattedSize) >> 10); | 1052 | le32_to_cpu(partition->header.FormattedSize) >> 10); |
1055 | #endif | 1053 | #endif |
1056 | partition->mbd.size = le32_to_cpu(partition->header.FormattedSize) >> 9; | 1054 | partition->mbd.size = le32_to_cpu(partition->header.FormattedSize) >> 9; |
1057 | partition->mbd.blksize = SECTOR_SIZE; | 1055 | |
1058 | partition->mbd.tr = tr; | 1056 | partition->mbd.tr = tr; |
1059 | partition->mbd.devnum = -1; | 1057 | partition->mbd.devnum = -1; |
1060 | if (!add_mtd_blktrans_dev((void *)partition)) | 1058 | if (!add_mtd_blktrans_dev((void *)partition)) |
@@ -1076,6 +1074,7 @@ struct mtd_blktrans_ops ftl_tr = { | |||
1076 | .name = "ftl", | 1074 | .name = "ftl", |
1077 | .major = FTL_MAJOR, | 1075 | .major = FTL_MAJOR, |
1078 | .part_bits = PART_BITS, | 1076 | .part_bits = PART_BITS, |
1077 | .blksize = SECTOR_SIZE, | ||
1079 | .readsect = ftl_readsect, | 1078 | .readsect = ftl_readsect, |
1080 | .writesect = ftl_writesect, | 1079 | .writesect = ftl_writesect, |
1081 | .getgeo = ftl_getgeo, | 1080 | .getgeo = ftl_getgeo, |
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c index 4116535805f1..b0e396504e67 100644 --- a/drivers/mtd/inftlcore.c +++ b/drivers/mtd/inftlcore.c | |||
@@ -67,17 +67,16 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
67 | 67 | ||
68 | DEBUG(MTD_DEBUG_LEVEL3, "INFTL: add_mtd for %s\n", mtd->name); | 68 | DEBUG(MTD_DEBUG_LEVEL3, "INFTL: add_mtd for %s\n", mtd->name); |
69 | 69 | ||
70 | inftl = kmalloc(sizeof(*inftl), GFP_KERNEL); | 70 | inftl = kzalloc(sizeof(*inftl), GFP_KERNEL); |
71 | 71 | ||
72 | if (!inftl) { | 72 | if (!inftl) { |
73 | printk(KERN_WARNING "INFTL: Out of memory for data structures\n"); | 73 | printk(KERN_WARNING "INFTL: Out of memory for data structures\n"); |
74 | return; | 74 | return; |
75 | } | 75 | } |
76 | memset(inftl, 0, sizeof(*inftl)); | ||
77 | 76 | ||
78 | inftl->mbd.mtd = mtd; | 77 | inftl->mbd.mtd = mtd; |
79 | inftl->mbd.devnum = -1; | 78 | inftl->mbd.devnum = -1; |
80 | inftl->mbd.blksize = 512; | 79 | |
81 | inftl->mbd.tr = tr; | 80 | inftl->mbd.tr = tr; |
82 | 81 | ||
83 | if (INFTL_mount(inftl) < 0) { | 82 | if (INFTL_mount(inftl) < 0) { |
@@ -163,10 +162,9 @@ int inftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len, | |||
163 | ops.ooblen = len; | 162 | ops.ooblen = len; |
164 | ops.oobbuf = buf; | 163 | ops.oobbuf = buf; |
165 | ops.datbuf = NULL; | 164 | ops.datbuf = NULL; |
166 | ops.len = len; | ||
167 | 165 | ||
168 | res = mtd->read_oob(mtd, offs & ~(mtd->writesize - 1), &ops); | 166 | res = mtd->read_oob(mtd, offs & ~(mtd->writesize - 1), &ops); |
169 | *retlen = ops.retlen; | 167 | *retlen = ops.oobretlen; |
170 | return res; | 168 | return res; |
171 | } | 169 | } |
172 | 170 | ||
@@ -184,10 +182,9 @@ int inftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len, | |||
184 | ops.ooblen = len; | 182 | ops.ooblen = len; |
185 | ops.oobbuf = buf; | 183 | ops.oobbuf = buf; |
186 | ops.datbuf = NULL; | 184 | ops.datbuf = NULL; |
187 | ops.len = len; | ||
188 | 185 | ||
189 | res = mtd->write_oob(mtd, offs & ~(mtd->writesize - 1), &ops); | 186 | res = mtd->write_oob(mtd, offs & ~(mtd->writesize - 1), &ops); |
190 | *retlen = ops.retlen; | 187 | *retlen = ops.oobretlen; |
191 | return res; | 188 | return res; |
192 | } | 189 | } |
193 | 190 | ||
@@ -945,6 +942,7 @@ static struct mtd_blktrans_ops inftl_tr = { | |||
945 | .name = "inftl", | 942 | .name = "inftl", |
946 | .major = INFTL_MAJOR, | 943 | .major = INFTL_MAJOR, |
947 | .part_bits = INFTL_PARTN_BITS, | 944 | .part_bits = INFTL_PARTN_BITS, |
945 | .blksize = 512, | ||
948 | .getgeo = inftl_getgeo, | 946 | .getgeo = inftl_getgeo, |
949 | .readsect = inftl_readblock, | 947 | .readsect = inftl_readblock, |
950 | .writesect = inftl_writeblock, | 948 | .writesect = inftl_writeblock, |
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index 7514a9bee015..fa7466886fd6 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig | |||
@@ -193,6 +193,15 @@ config MTD_ESB2ROM | |||
193 | 193 | ||
194 | BE VERY CAREFUL. | 194 | BE VERY CAREFUL. |
195 | 195 | ||
196 | config MTD_CK804XROM | ||
197 | tristate "BIOS flash chip on Nvidia CK804" | ||
198 | depends on X86 && MTD_JEDECPROBE | ||
199 | help | ||
200 | Support for treating the BIOS flash chip on nvidia motherboards | ||
201 | as an MTD device - with this you can reprogram your BIOS. | ||
202 | |||
203 | BE VERY CAREFUL. | ||
204 | |||
196 | config MTD_SCB2_FLASH | 205 | config MTD_SCB2_FLASH |
197 | tristate "BIOS flash chip on Intel SCB2 boards" | 206 | tristate "BIOS flash chip on Intel SCB2 boards" |
198 | depends on X86 && MTD_JEDECPROBE | 207 | depends on X86 && MTD_JEDECPROBE |
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile index 9061432c5e1a..34505216d403 100644 --- a/drivers/mtd/maps/Makefile +++ b/drivers/mtd/maps/Makefile | |||
@@ -19,6 +19,7 @@ obj-$(CONFIG_MTD_L440GX) += l440gx.o | |||
19 | obj-$(CONFIG_MTD_AMD76XROM) += amd76xrom.o | 19 | obj-$(CONFIG_MTD_AMD76XROM) += amd76xrom.o |
20 | obj-$(CONFIG_MTD_ESB2ROM) += esb2rom.o | 20 | obj-$(CONFIG_MTD_ESB2ROM) += esb2rom.o |
21 | obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o | 21 | obj-$(CONFIG_MTD_ICHXROM) += ichxrom.o |
22 | obj-$(CONFIG_MTD_CK804XROM) += ck804xrom.o | ||
22 | obj-$(CONFIG_MTD_TSUNAMI) += tsunami_flash.o | 23 | obj-$(CONFIG_MTD_TSUNAMI) += tsunami_flash.o |
23 | obj-$(CONFIG_MTD_LUBBOCK) += lubbock-flash.o | 24 | obj-$(CONFIG_MTD_LUBBOCK) += lubbock-flash.o |
24 | obj-$(CONFIG_MTD_MAINSTONE) += mainstone-flash.o | 25 | obj-$(CONFIG_MTD_MAINSTONE) += mainstone-flash.o |
diff --git a/drivers/mtd/maps/ceiva.c b/drivers/mtd/maps/ceiva.c index 0402c21e291d..629e6e2641a8 100644 --- a/drivers/mtd/maps/ceiva.c +++ b/drivers/mtd/maps/ceiva.c | |||
@@ -122,10 +122,9 @@ static int __init clps_setup_mtd(struct clps_info *clps, int nr, struct mtd_info | |||
122 | /* | 122 | /* |
123 | * Allocate the map_info structs in one go. | 123 | * Allocate the map_info structs in one go. |
124 | */ | 124 | */ |
125 | maps = kmalloc(sizeof(struct map_info) * nr, GFP_KERNEL); | 125 | maps = kzalloc(sizeof(struct map_info) * nr, GFP_KERNEL); |
126 | if (!maps) | 126 | if (!maps) |
127 | return -ENOMEM; | 127 | return -ENOMEM; |
128 | memset(maps, 0, sizeof(struct map_info) * nr); | ||
129 | /* | 128 | /* |
130 | * Claim and then map the memory regions. | 129 | * Claim and then map the memory regions. |
131 | */ | 130 | */ |
diff --git a/drivers/mtd/maps/ck804xrom.c b/drivers/mtd/maps/ck804xrom.c new file mode 100644 index 000000000000..c222b88c3c3a --- /dev/null +++ b/drivers/mtd/maps/ck804xrom.c | |||
@@ -0,0 +1,356 @@ | |||
1 | /* | ||
2 | * ck804xrom.c | ||
3 | * | ||
4 | * Normal mappings of chips in physical memory | ||
5 | * | ||
6 | * Dave Olsen <dolsen@lnxi.com> | ||
7 | * Ryan Jackson <rjackson@lnxi.com> | ||
8 | */ | ||
9 | |||
10 | #include <linux/module.h> | ||
11 | #include <linux/types.h> | ||
12 | #include <linux/version.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <asm/io.h> | ||
16 | #include <linux/mtd/mtd.h> | ||
17 | #include <linux/mtd/map.h> | ||
18 | #include <linux/mtd/cfi.h> | ||
19 | #include <linux/mtd/flashchip.h> | ||
20 | #include <linux/pci.h> | ||
21 | #include <linux/pci_ids.h> | ||
22 | #include <linux/list.h> | ||
23 | |||
24 | |||
25 | #define MOD_NAME KBUILD_BASENAME | ||
26 | |||
27 | #define ADDRESS_NAME_LEN 18 | ||
28 | |||
29 | #define ROM_PROBE_STEP_SIZE (64*1024) | ||
30 | |||
31 | struct ck804xrom_window { | ||
32 | void __iomem *virt; | ||
33 | unsigned long phys; | ||
34 | unsigned long size; | ||
35 | struct list_head maps; | ||
36 | struct resource rsrc; | ||
37 | struct pci_dev *pdev; | ||
38 | }; | ||
39 | |||
40 | struct ck804xrom_map_info { | ||
41 | struct list_head list; | ||
42 | struct map_info map; | ||
43 | struct mtd_info *mtd; | ||
44 | struct resource rsrc; | ||
45 | char map_name[sizeof(MOD_NAME) + 2 + ADDRESS_NAME_LEN]; | ||
46 | }; | ||
47 | |||
48 | |||
49 | /* The 2 bits controlling the window size are often set to allow reading | ||
50 | * the BIOS, but too small to allow writing, since the lock registers are | ||
51 | * 4MiB lower in the address space than the data. | ||
52 | * | ||
53 | * This is intended to prevent flashing the bios, perhaps accidentally. | ||
54 | * | ||
55 | * This parameter allows the normal driver to override the BIOS settings. | ||
56 | * | ||
57 | * The bits are 6 and 7. If both bits are set, it is a 5MiB window. | ||
58 | * If only the 7 Bit is set, it is a 4MiB window. Otherwise, a | ||
59 | * 64KiB window. | ||
60 | * | ||
61 | */ | ||
62 | static uint win_size_bits = 0; | ||
63 | module_param(win_size_bits, uint, 0); | ||
64 | MODULE_PARM_DESC(win_size_bits, "ROM window size bits override for 0x88 byte, normally set by BIOS."); | ||
65 | |||
66 | static struct ck804xrom_window ck804xrom_window = { | ||
67 | .maps = LIST_HEAD_INIT(ck804xrom_window.maps), | ||
68 | }; | ||
69 | |||
70 | static void ck804xrom_cleanup(struct ck804xrom_window *window) | ||
71 | { | ||
72 | struct ck804xrom_map_info *map, *scratch; | ||
73 | u8 byte; | ||
74 | |||
75 | if (window->pdev) { | ||
76 | /* Disable writes through the rom window */ | ||
77 | pci_read_config_byte(window->pdev, 0x6d, &byte); | ||
78 | pci_write_config_byte(window->pdev, 0x6d, byte & ~1); | ||
79 | } | ||
80 | |||
81 | /* Free all of the mtd devices */ | ||
82 | list_for_each_entry_safe(map, scratch, &window->maps, list) { | ||
83 | if (map->rsrc.parent) | ||
84 | release_resource(&map->rsrc); | ||
85 | |||
86 | del_mtd_device(map->mtd); | ||
87 | map_destroy(map->mtd); | ||
88 | list_del(&map->list); | ||
89 | kfree(map); | ||
90 | } | ||
91 | if (window->rsrc.parent) | ||
92 | release_resource(&window->rsrc); | ||
93 | |||
94 | if (window->virt) { | ||
95 | iounmap(window->virt); | ||
96 | window->virt = NULL; | ||
97 | window->phys = 0; | ||
98 | window->size = 0; | ||
99 | } | ||
100 | pci_dev_put(window->pdev); | ||
101 | } | ||
102 | |||
103 | |||
104 | static int __devinit ck804xrom_init_one (struct pci_dev *pdev, | ||
105 | const struct pci_device_id *ent) | ||
106 | { | ||
107 | static char *rom_probe_types[] = { "cfi_probe", "jedec_probe", NULL }; | ||
108 | u8 byte; | ||
109 | struct ck804xrom_window *window = &ck804xrom_window; | ||
110 | struct ck804xrom_map_info *map = NULL; | ||
111 | unsigned long map_top; | ||
112 | |||
113 | /* Remember the pci dev I find the window in */ | ||
114 | window->pdev = pci_dev_get(pdev); | ||
115 | |||
116 | /* Enable the selected rom window. This is often incorrectly | ||
117 | * set up by the BIOS, and the 4MiB offset for the lock registers | ||
118 | * requires the full 5MiB of window space. | ||
119 | * | ||
120 | * This 'write, then read' approach leaves the bits for | ||
121 | * other uses of the hardware info. | ||
122 | */ | ||
123 | pci_read_config_byte(pdev, 0x88, &byte); | ||
124 | pci_write_config_byte(pdev, 0x88, byte | win_size_bits ); | ||
125 | |||
126 | |||
127 | /* Assume the rom window is properly setup, and find it's size */ | ||
128 | pci_read_config_byte(pdev, 0x88, &byte); | ||
129 | |||
130 | if ((byte & ((1<<7)|(1<<6))) == ((1<<7)|(1<<6))) | ||
131 | window->phys = 0xffb00000; /* 5MiB */ | ||
132 | else if ((byte & (1<<7)) == (1<<7)) | ||
133 | window->phys = 0xffc00000; /* 4MiB */ | ||
134 | else | ||
135 | window->phys = 0xffff0000; /* 64KiB */ | ||
136 | |||
137 | window->size = 0xffffffffUL - window->phys + 1UL; | ||
138 | |||
139 | /* | ||
140 | * Try to reserve the window mem region. If this fails then | ||
141 | * it is likely due to a fragment of the window being | ||
142 | * "reserved" by the BIOS. In the case that the | ||
143 | * request_mem_region() fails then once the rom size is | ||
144 | * discovered we will try to reserve the unreserved fragment. | ||
145 | */ | ||
146 | window->rsrc.name = MOD_NAME; | ||
147 | window->rsrc.start = window->phys; | ||
148 | window->rsrc.end = window->phys + window->size - 1; | ||
149 | window->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
150 | if (request_resource(&iomem_resource, &window->rsrc)) { | ||
151 | window->rsrc.parent = NULL; | ||
152 | printk(KERN_ERR MOD_NAME | ||
153 | " %s(): Unable to register resource" | ||
154 | " 0x%.016llx-0x%.016llx - kernel bug?\n", | ||
155 | __func__, | ||
156 | (unsigned long long)window->rsrc.start, | ||
157 | (unsigned long long)window->rsrc.end); | ||
158 | } | ||
159 | |||
160 | |||
161 | /* Enable writes through the rom window */ | ||
162 | pci_read_config_byte(pdev, 0x6d, &byte); | ||
163 | pci_write_config_byte(pdev, 0x6d, byte | 1); | ||
164 | |||
165 | /* FIXME handle registers 0x80 - 0x8C the bios region locks */ | ||
166 | |||
167 | /* For write accesses caches are useless */ | ||
168 | window->virt = ioremap_nocache(window->phys, window->size); | ||
169 | if (!window->virt) { | ||
170 | printk(KERN_ERR MOD_NAME ": ioremap(%08lx, %08lx) failed\n", | ||
171 | window->phys, window->size); | ||
172 | goto out; | ||
173 | } | ||
174 | |||
175 | /* Get the first address to look for a rom chip at */ | ||
176 | map_top = window->phys; | ||
177 | #if 1 | ||
178 | /* The probe sequence run over the firmware hub lock | ||
179 | * registers sets them to 0x7 (no access). | ||
180 | * Probe at most the last 4MiB of the address space. | ||
181 | */ | ||
182 | if (map_top < 0xffc00000) | ||
183 | map_top = 0xffc00000; | ||
184 | #endif | ||
185 | /* Loop through and look for rom chips. Since we don't know the | ||
186 | * starting address for each chip, probe every ROM_PROBE_STEP_SIZE | ||
187 | * bytes from the starting address of the window. | ||
188 | */ | ||
189 | while((map_top - 1) < 0xffffffffUL) { | ||
190 | struct cfi_private *cfi; | ||
191 | unsigned long offset; | ||
192 | int i; | ||
193 | |||
194 | if (!map) | ||
195 | map = kmalloc(sizeof(*map), GFP_KERNEL); | ||
196 | |||
197 | if (!map) { | ||
198 | printk(KERN_ERR MOD_NAME ": kmalloc failed"); | ||
199 | goto out; | ||
200 | } | ||
201 | memset(map, 0, sizeof(*map)); | ||
202 | INIT_LIST_HEAD(&map->list); | ||
203 | map->map.name = map->map_name; | ||
204 | map->map.phys = map_top; | ||
205 | offset = map_top - window->phys; | ||
206 | map->map.virt = (void __iomem *) | ||
207 | (((unsigned long)(window->virt)) + offset); | ||
208 | map->map.size = 0xffffffffUL - map_top + 1UL; | ||
209 | /* Set the name of the map to the address I am trying */ | ||
210 | sprintf(map->map_name, "%s @%08lx", | ||
211 | MOD_NAME, map->map.phys); | ||
212 | |||
213 | /* There is no generic VPP support */ | ||
214 | for(map->map.bankwidth = 32; map->map.bankwidth; | ||
215 | map->map.bankwidth >>= 1) | ||
216 | { | ||
217 | char **probe_type; | ||
218 | /* Skip bankwidths that are not supported */ | ||
219 | if (!map_bankwidth_supported(map->map.bankwidth)) | ||
220 | continue; | ||
221 | |||
222 | /* Setup the map methods */ | ||
223 | simple_map_init(&map->map); | ||
224 | |||
225 | /* Try all of the probe methods */ | ||
226 | probe_type = rom_probe_types; | ||
227 | for(; *probe_type; probe_type++) { | ||
228 | map->mtd = do_map_probe(*probe_type, &map->map); | ||
229 | if (map->mtd) | ||
230 | goto found; | ||
231 | } | ||
232 | } | ||
233 | map_top += ROM_PROBE_STEP_SIZE; | ||
234 | continue; | ||
235 | found: | ||
236 | /* Trim the size if we are larger than the map */ | ||
237 | if (map->mtd->size > map->map.size) { | ||
238 | printk(KERN_WARNING MOD_NAME | ||
239 | " rom(%u) larger than window(%lu). fixing...\n", | ||
240 | map->mtd->size, map->map.size); | ||
241 | map->mtd->size = map->map.size; | ||
242 | } | ||
243 | if (window->rsrc.parent) { | ||
244 | /* | ||
245 | * Registering the MTD device in iomem may not be possible | ||
246 | * if there is a BIOS "reserved" and BUSY range. If this | ||
247 | * fails then continue anyway. | ||
248 | */ | ||
249 | map->rsrc.name = map->map_name; | ||
250 | map->rsrc.start = map->map.phys; | ||
251 | map->rsrc.end = map->map.phys + map->mtd->size - 1; | ||
252 | map->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
253 | if (request_resource(&window->rsrc, &map->rsrc)) { | ||
254 | printk(KERN_ERR MOD_NAME | ||
255 | ": cannot reserve MTD resource\n"); | ||
256 | map->rsrc.parent = NULL; | ||
257 | } | ||
258 | } | ||
259 | |||
260 | /* Make the whole region visible in the map */ | ||
261 | map->map.virt = window->virt; | ||
262 | map->map.phys = window->phys; | ||
263 | cfi = map->map.fldrv_priv; | ||
264 | for(i = 0; i < cfi->numchips; i++) | ||
265 | cfi->chips[i].start += offset; | ||
266 | |||
267 | /* Now that the mtd devices is complete claim and export it */ | ||
268 | map->mtd->owner = THIS_MODULE; | ||
269 | if (add_mtd_device(map->mtd)) { | ||
270 | map_destroy(map->mtd); | ||
271 | map->mtd = NULL; | ||
272 | goto out; | ||
273 | } | ||
274 | |||
275 | |||
276 | /* Calculate the new value of map_top */ | ||
277 | map_top += map->mtd->size; | ||
278 | |||
279 | /* File away the map structure */ | ||
280 | list_add(&map->list, &window->maps); | ||
281 | map = NULL; | ||
282 | } | ||
283 | |||
284 | out: | ||
285 | /* Free any left over map structures */ | ||
286 | if (map) | ||
287 | kfree(map); | ||
288 | |||
289 | /* See if I have any map structures */ | ||
290 | if (list_empty(&window->maps)) { | ||
291 | ck804xrom_cleanup(window); | ||
292 | return -ENODEV; | ||
293 | } | ||
294 | return 0; | ||
295 | } | ||
296 | |||
297 | |||
298 | static void __devexit ck804xrom_remove_one (struct pci_dev *pdev) | ||
299 | { | ||
300 | struct ck804xrom_window *window = &ck804xrom_window; | ||
301 | |||
302 | ck804xrom_cleanup(window); | ||
303 | } | ||
304 | |||
305 | static struct pci_device_id ck804xrom_pci_tbl[] = { | ||
306 | { PCI_VENDOR_ID_NVIDIA, 0x0051, | ||
307 | PCI_ANY_ID, PCI_ANY_ID, }, /* nvidia ck804 */ | ||
308 | { 0, } | ||
309 | }; | ||
310 | |||
311 | MODULE_DEVICE_TABLE(pci, ck804xrom_pci_tbl); | ||
312 | |||
313 | #if 0 | ||
314 | static struct pci_driver ck804xrom_driver = { | ||
315 | .name = MOD_NAME, | ||
316 | .id_table = ck804xrom_pci_tbl, | ||
317 | .probe = ck804xrom_init_one, | ||
318 | .remove = ck804xrom_remove_one, | ||
319 | }; | ||
320 | #endif | ||
321 | |||
322 | static int __init init_ck804xrom(void) | ||
323 | { | ||
324 | struct pci_dev *pdev; | ||
325 | struct pci_device_id *id; | ||
326 | int retVal; | ||
327 | pdev = NULL; | ||
328 | |||
329 | for(id = ck804xrom_pci_tbl; id->vendor; id++) { | ||
330 | pdev = pci_find_device(id->vendor, id->device, NULL); | ||
331 | if (pdev) | ||
332 | break; | ||
333 | } | ||
334 | if (pdev) { | ||
335 | retVal = ck804xrom_init_one(pdev, &ck804xrom_pci_tbl[0]); | ||
336 | pci_dev_put(pdev); | ||
337 | return retVal; | ||
338 | } | ||
339 | return -ENXIO; | ||
340 | #if 0 | ||
341 | return pci_module_init(&ck804xrom_driver); | ||
342 | #endif | ||
343 | } | ||
344 | |||
345 | static void __exit cleanup_ck804xrom(void) | ||
346 | { | ||
347 | ck804xrom_remove_one(ck804xrom_window.pdev); | ||
348 | } | ||
349 | |||
350 | module_init(init_ck804xrom); | ||
351 | module_exit(cleanup_ck804xrom); | ||
352 | |||
353 | MODULE_LICENSE("GPL"); | ||
354 | MODULE_AUTHOR("Eric Biederman <ebiederman@lnxi.com>, Dave Olsen <dolsen@lnxi.com>"); | ||
355 | MODULE_DESCRIPTION("MTD map driver for BIOS chips on the Nvidia ck804 southbridge"); | ||
356 | |||
diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c index c8db01b3e45f..6946d802e6f6 100644 --- a/drivers/mtd/maps/integrator-flash.c +++ b/drivers/mtd/maps/integrator-flash.c | |||
@@ -75,14 +75,12 @@ static int armflash_probe(struct platform_device *dev) | |||
75 | int err; | 75 | int err; |
76 | void __iomem *base; | 76 | void __iomem *base; |
77 | 77 | ||
78 | info = kmalloc(sizeof(struct armflash_info), GFP_KERNEL); | 78 | info = kzalloc(sizeof(struct armflash_info), GFP_KERNEL); |
79 | if (!info) { | 79 | if (!info) { |
80 | err = -ENOMEM; | 80 | err = -ENOMEM; |
81 | goto out; | 81 | goto out; |
82 | } | 82 | } |
83 | 83 | ||
84 | memset(info, 0, sizeof(struct armflash_info)); | ||
85 | |||
86 | info->plat = plat; | 84 | info->plat = plat; |
87 | if (plat && plat->init) { | 85 | if (plat && plat->init) { |
88 | err = plat->init(); | 86 | err = plat->init(); |
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c index 418afffb2d80..e8d9ae535673 100644 --- a/drivers/mtd/maps/omap_nor.c +++ b/drivers/mtd/maps/omap_nor.c | |||
@@ -78,12 +78,10 @@ static int __devinit omapflash_probe(struct platform_device *pdev) | |||
78 | struct resource *res = pdev->resource; | 78 | struct resource *res = pdev->resource; |
79 | unsigned long size = res->end - res->start + 1; | 79 | unsigned long size = res->end - res->start + 1; |
80 | 80 | ||
81 | info = kmalloc(sizeof(struct omapflash_info), GFP_KERNEL); | 81 | info = kzalloc(sizeof(struct omapflash_info), GFP_KERNEL); |
82 | if (!info) | 82 | if (!info) |
83 | return -ENOMEM; | 83 | return -ENOMEM; |
84 | 84 | ||
85 | memset(info, 0, sizeof(struct omapflash_info)); | ||
86 | |||
87 | if (!request_mem_region(res->start, size, "flash")) { | 85 | if (!request_mem_region(res->start, size, "flash")) { |
88 | err = -EBUSY; | 86 | err = -EBUSY; |
89 | goto out_free_info; | 87 | goto out_free_info; |
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index 995347b1beba..eaeb56a4070a 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
@@ -735,11 +735,10 @@ static int pcmciamtd_probe(struct pcmcia_device *link) | |||
735 | struct pcmciamtd_dev *dev; | 735 | struct pcmciamtd_dev *dev; |
736 | 736 | ||
737 | /* Create new memory card device */ | 737 | /* Create new memory card device */ |
738 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); | 738 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
739 | if (!dev) return -ENOMEM; | 739 | if (!dev) return -ENOMEM; |
740 | DEBUG(1, "dev=0x%p", dev); | 740 | DEBUG(1, "dev=0x%p", dev); |
741 | 741 | ||
742 | memset(dev, 0, sizeof(*dev)); | ||
743 | dev->p_dev = link; | 742 | dev->p_dev = link; |
744 | link->priv = dev; | 743 | link->priv = dev; |
745 | 744 | ||
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c index d1717763f719..28c5ffd75233 100644 --- a/drivers/mtd/maps/physmap.c +++ b/drivers/mtd/maps/physmap.c | |||
@@ -89,15 +89,14 @@ static int physmap_flash_probe(struct platform_device *dev) | |||
89 | return -ENODEV; | 89 | return -ENODEV; |
90 | 90 | ||
91 | printk(KERN_NOTICE "physmap platform flash device: %.8llx at %.8llx\n", | 91 | printk(KERN_NOTICE "physmap platform flash device: %.8llx at %.8llx\n", |
92 | (unsigned long long)dev->resource->end - dev->resource->start + 1, | 92 | (unsigned long long)(dev->resource->end - dev->resource->start + 1), |
93 | (unsigned long long)dev->resource->start); | 93 | (unsigned long long)dev->resource->start); |
94 | 94 | ||
95 | info = kmalloc(sizeof(struct physmap_flash_info), GFP_KERNEL); | 95 | info = kzalloc(sizeof(struct physmap_flash_info), GFP_KERNEL); |
96 | if (info == NULL) { | 96 | if (info == NULL) { |
97 | err = -ENOMEM; | 97 | err = -ENOMEM; |
98 | goto err_out; | 98 | goto err_out; |
99 | } | 99 | } |
100 | memset(info, 0, sizeof(*info)); | ||
101 | 100 | ||
102 | platform_set_drvdata(dev, info); | 101 | platform_set_drvdata(dev, info); |
103 | 102 | ||
diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c index 5d3c75451ca2..2b6504ecbbd1 100644 --- a/drivers/mtd/maps/plat-ram.c +++ b/drivers/mtd/maps/plat-ram.c | |||
@@ -147,14 +147,13 @@ static int platram_probe(struct platform_device *pdev) | |||
147 | 147 | ||
148 | pdata = pdev->dev.platform_data; | 148 | pdata = pdev->dev.platform_data; |
149 | 149 | ||
150 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 150 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
151 | if (info == NULL) { | 151 | if (info == NULL) { |
152 | dev_err(&pdev->dev, "no memory for flash info\n"); | 152 | dev_err(&pdev->dev, "no memory for flash info\n"); |
153 | err = -ENOMEM; | 153 | err = -ENOMEM; |
154 | goto exit_error; | 154 | goto exit_error; |
155 | } | 155 | } |
156 | 156 | ||
157 | memset(info, 0, sizeof(*info)); | ||
158 | platform_set_drvdata(pdev, info); | 157 | platform_set_drvdata(pdev, info); |
159 | 158 | ||
160 | info->dev = &pdev->dev; | 159 | info->dev = &pdev->dev; |
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c index 950bf1c57841..f904e6bd02e0 100644 --- a/drivers/mtd/maps/sa1100-flash.c +++ b/drivers/mtd/maps/sa1100-flash.c | |||
@@ -273,14 +273,12 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat) | |||
273 | /* | 273 | /* |
274 | * Allocate the map_info structs in one go. | 274 | * Allocate the map_info structs in one go. |
275 | */ | 275 | */ |
276 | info = kmalloc(size, GFP_KERNEL); | 276 | info = kzalloc(size, GFP_KERNEL); |
277 | if (!info) { | 277 | if (!info) { |
278 | ret = -ENOMEM; | 278 | ret = -ENOMEM; |
279 | goto out; | 279 | goto out; |
280 | } | 280 | } |
281 | 281 | ||
282 | memset(info, 0, size); | ||
283 | |||
284 | if (plat->init) { | 282 | if (plat->init) { |
285 | ret = plat->init(); | 283 | ret = plat->init(); |
286 | if (ret) | 284 | if (ret) |
diff --git a/drivers/mtd/maps/tqm834x.c b/drivers/mtd/maps/tqm834x.c index 58e5912bd381..9adc970e55e6 100644 --- a/drivers/mtd/maps/tqm834x.c +++ b/drivers/mtd/maps/tqm834x.c | |||
@@ -132,20 +132,16 @@ static int __init init_tqm834x_mtd(void) | |||
132 | 132 | ||
133 | pr_debug("%s: chip probing count %d\n", __FUNCTION__, idx); | 133 | pr_debug("%s: chip probing count %d\n", __FUNCTION__, idx); |
134 | 134 | ||
135 | map_banks[idx] = | 135 | map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL); |
136 | (struct map_info *)kmalloc(sizeof(struct map_info), | ||
137 | GFP_KERNEL); | ||
138 | if (map_banks[idx] == NULL) { | 136 | if (map_banks[idx] == NULL) { |
139 | ret = -ENOMEM; | 137 | ret = -ENOMEM; |
140 | goto error_mem; | 138 | goto error_mem; |
141 | } | 139 | } |
142 | memset((void *)map_banks[idx], 0, sizeof(struct map_info)); | 140 | map_banks[idx]->name = kzalloc(16, GFP_KERNEL); |
143 | map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); | ||
144 | if (map_banks[idx]->name == NULL) { | 141 | if (map_banks[idx]->name == NULL) { |
145 | ret = -ENOMEM; | 142 | ret = -ENOMEM; |
146 | goto error_mem; | 143 | goto error_mem; |
147 | } | 144 | } |
148 | memset((void *)map_banks[idx]->name, 0, 16); | ||
149 | 145 | ||
150 | sprintf(map_banks[idx]->name, "TQM834x-%d", idx); | 146 | sprintf(map_banks[idx]->name, "TQM834x-%d", idx); |
151 | map_banks[idx]->size = flash_size; | 147 | map_banks[idx]->size = flash_size; |
diff --git a/drivers/mtd/maps/tqm8xxl.c b/drivers/mtd/maps/tqm8xxl.c index 19578ba84ee8..37e4ded9b600 100644 --- a/drivers/mtd/maps/tqm8xxl.c +++ b/drivers/mtd/maps/tqm8xxl.c | |||
@@ -134,14 +134,13 @@ int __init init_tqm_mtd(void) | |||
134 | 134 | ||
135 | printk(KERN_INFO "%s: chip probing count %d\n", __FUNCTION__, idx); | 135 | printk(KERN_INFO "%s: chip probing count %d\n", __FUNCTION__, idx); |
136 | 136 | ||
137 | map_banks[idx] = (struct map_info *)kmalloc(sizeof(struct map_info), GFP_KERNEL); | 137 | map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL); |
138 | if(map_banks[idx] == NULL) { | 138 | if(map_banks[idx] == NULL) { |
139 | ret = -ENOMEM; | 139 | ret = -ENOMEM; |
140 | /* FIXME: What if some MTD devices were probed already? */ | 140 | /* FIXME: What if some MTD devices were probed already? */ |
141 | goto error_mem; | 141 | goto error_mem; |
142 | } | 142 | } |
143 | 143 | ||
144 | memset((void *)map_banks[idx], 0, sizeof(struct map_info)); | ||
145 | map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); | 144 | map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); |
146 | 145 | ||
147 | if (!map_banks[idx]->name) { | 146 | if (!map_banks[idx]->name) { |
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 178b53b56be9..b879a66daa9e 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c | |||
@@ -42,19 +42,20 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr, | |||
42 | unsigned long block, nsect; | 42 | unsigned long block, nsect; |
43 | char *buf; | 43 | char *buf; |
44 | 44 | ||
45 | block = req->sector; | 45 | block = req->sector << 9 >> tr->blkshift; |
46 | nsect = req->current_nr_sectors; | 46 | nsect = req->current_nr_sectors << 9 >> tr->blkshift; |
47 | |||
47 | buf = req->buffer; | 48 | buf = req->buffer; |
48 | 49 | ||
49 | if (!blk_fs_request(req)) | 50 | if (!blk_fs_request(req)) |
50 | return 0; | 51 | return 0; |
51 | 52 | ||
52 | if (block + nsect > get_capacity(req->rq_disk)) | 53 | if (req->sector + req->current_nr_sectors > get_capacity(req->rq_disk)) |
53 | return 0; | 54 | return 0; |
54 | 55 | ||
55 | switch(rq_data_dir(req)) { | 56 | switch(rq_data_dir(req)) { |
56 | case READ: | 57 | case READ: |
57 | for (; nsect > 0; nsect--, block++, buf += 512) | 58 | for (; nsect > 0; nsect--, block++, buf += tr->blksize) |
58 | if (tr->readsect(dev, block, buf)) | 59 | if (tr->readsect(dev, block, buf)) |
59 | return 0; | 60 | return 0; |
60 | return 1; | 61 | return 1; |
@@ -63,7 +64,7 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr, | |||
63 | if (!tr->writesect) | 64 | if (!tr->writesect) |
64 | return 0; | 65 | return 0; |
65 | 66 | ||
66 | for (; nsect > 0; nsect--, block++, buf += 512) | 67 | for (; nsect > 0; nsect--, block++, buf += tr->blksize) |
67 | if (tr->writesect(dev, block, buf)) | 68 | if (tr->writesect(dev, block, buf)) |
68 | return 0; | 69 | return 0; |
69 | return 1; | 70 | return 1; |
@@ -297,7 +298,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) | |||
297 | 298 | ||
298 | /* 2.5 has capacity in units of 512 bytes while still | 299 | /* 2.5 has capacity in units of 512 bytes while still |
299 | having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */ | 300 | having BLOCK_SIZE_BITS set to 10. Just to keep us amused. */ |
300 | set_capacity(gd, (new->size * new->blksize) >> 9); | 301 | set_capacity(gd, (new->size * tr->blksize) >> 9); |
301 | 302 | ||
302 | gd->private_data = new; | 303 | gd->private_data = new; |
303 | new->blkcore_priv = gd; | 304 | new->blkcore_priv = gd; |
@@ -372,12 +373,10 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
372 | if (!blktrans_notifier.list.next) | 373 | if (!blktrans_notifier.list.next) |
373 | register_mtd_user(&blktrans_notifier); | 374 | register_mtd_user(&blktrans_notifier); |
374 | 375 | ||
375 | tr->blkcore_priv = kmalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL); | 376 | tr->blkcore_priv = kzalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL); |
376 | if (!tr->blkcore_priv) | 377 | if (!tr->blkcore_priv) |
377 | return -ENOMEM; | 378 | return -ENOMEM; |
378 | 379 | ||
379 | memset(tr->blkcore_priv, 0, sizeof(*tr->blkcore_priv)); | ||
380 | |||
381 | mutex_lock(&mtd_table_mutex); | 380 | mutex_lock(&mtd_table_mutex); |
382 | 381 | ||
383 | ret = register_blkdev(tr->major, tr->name); | 382 | ret = register_blkdev(tr->major, tr->name); |
@@ -401,6 +400,8 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
401 | } | 400 | } |
402 | 401 | ||
403 | tr->blkcore_priv->rq->queuedata = tr; | 402 | tr->blkcore_priv->rq->queuedata = tr; |
403 | blk_queue_hardsect_size(tr->blkcore_priv->rq, tr->blksize); | ||
404 | tr->blkshift = ffs(tr->blksize) - 1; | ||
404 | 405 | ||
405 | ret = kernel_thread(mtd_blktrans_thread, tr, CLONE_KERNEL); | 406 | ret = kernel_thread(mtd_blktrans_thread, tr, CLONE_KERNEL); |
406 | if (ret < 0) { | 407 | if (ret < 0) { |
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c index 04ed34694b14..952da30b1745 100644 --- a/drivers/mtd/mtdblock.c +++ b/drivers/mtd/mtdblock.c | |||
@@ -278,11 +278,10 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd) | |||
278 | } | 278 | } |
279 | 279 | ||
280 | /* OK, it's not open. Create cache info for it */ | 280 | /* OK, it's not open. Create cache info for it */ |
281 | mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL); | 281 | mtdblk = kzalloc(sizeof(struct mtdblk_dev), GFP_KERNEL); |
282 | if (!mtdblk) | 282 | if (!mtdblk) |
283 | return -ENOMEM; | 283 | return -ENOMEM; |
284 | 284 | ||
285 | memset(mtdblk, 0, sizeof(*mtdblk)); | ||
286 | mtdblk->count = 1; | 285 | mtdblk->count = 1; |
287 | mtdblk->mtd = mtd; | 286 | mtdblk->mtd = mtd; |
288 | 287 | ||
@@ -339,16 +338,14 @@ static int mtdblock_flush(struct mtd_blktrans_dev *dev) | |||
339 | 338 | ||
340 | static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | 339 | static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) |
341 | { | 340 | { |
342 | struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL); | 341 | struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
343 | 342 | ||
344 | if (!dev) | 343 | if (!dev) |
345 | return; | 344 | return; |
346 | 345 | ||
347 | memset(dev, 0, sizeof(*dev)); | ||
348 | |||
349 | dev->mtd = mtd; | 346 | dev->mtd = mtd; |
350 | dev->devnum = mtd->index; | 347 | dev->devnum = mtd->index; |
351 | dev->blksize = 512; | 348 | |
352 | dev->size = mtd->size >> 9; | 349 | dev->size = mtd->size >> 9; |
353 | dev->tr = tr; | 350 | dev->tr = tr; |
354 | 351 | ||
@@ -368,6 +365,7 @@ static struct mtd_blktrans_ops mtdblock_tr = { | |||
368 | .name = "mtdblock", | 365 | .name = "mtdblock", |
369 | .major = 31, | 366 | .major = 31, |
370 | .part_bits = 0, | 367 | .part_bits = 0, |
368 | .blksize = 512, | ||
371 | .open = mtdblock_open, | 369 | .open = mtdblock_open, |
372 | .flush = mtdblock_flush, | 370 | .flush = mtdblock_flush, |
373 | .release = mtdblock_release, | 371 | .release = mtdblock_release, |
diff --git a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c index 29563ed258a4..f79dbb49b1a2 100644 --- a/drivers/mtd/mtdblock_ro.c +++ b/drivers/mtd/mtdblock_ro.c | |||
@@ -33,16 +33,14 @@ static int mtdblock_writesect(struct mtd_blktrans_dev *dev, | |||
33 | 33 | ||
34 | static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | 34 | static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) |
35 | { | 35 | { |
36 | struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL); | 36 | struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
37 | 37 | ||
38 | if (!dev) | 38 | if (!dev) |
39 | return; | 39 | return; |
40 | 40 | ||
41 | memset(dev, 0, sizeof(*dev)); | ||
42 | |||
43 | dev->mtd = mtd; | 41 | dev->mtd = mtd; |
44 | dev->devnum = mtd->index; | 42 | dev->devnum = mtd->index; |
45 | dev->blksize = 512; | 43 | |
46 | dev->size = mtd->size >> 9; | 44 | dev->size = mtd->size >> 9; |
47 | dev->tr = tr; | 45 | dev->tr = tr; |
48 | dev->readonly = 1; | 46 | dev->readonly = 1; |
@@ -60,6 +58,7 @@ static struct mtd_blktrans_ops mtdblock_tr = { | |||
60 | .name = "mtdblock", | 58 | .name = "mtdblock", |
61 | .major = 31, | 59 | .major = 31, |
62 | .part_bits = 0, | 60 | .part_bits = 0, |
61 | .blksize = 512, | ||
63 | .readsect = mtdblock_readsect, | 62 | .readsect = mtdblock_readsect, |
64 | .writesect = mtdblock_writesect, | 63 | .writesect = mtdblock_writesect, |
65 | .add_mtd = mtdblock_add_mtd, | 64 | .add_mtd = mtdblock_add_mtd, |
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 866c8e0d57e4..7c4adc641328 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -431,7 +431,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
431 | if(!(file->f_mode & 2)) | 431 | if(!(file->f_mode & 2)) |
432 | return -EPERM; | 432 | return -EPERM; |
433 | 433 | ||
434 | erase=kmalloc(sizeof(struct erase_info),GFP_KERNEL); | 434 | erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL); |
435 | if (!erase) | 435 | if (!erase) |
436 | ret = -ENOMEM; | 436 | ret = -ENOMEM; |
437 | else { | 437 | else { |
@@ -440,7 +440,6 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
440 | 440 | ||
441 | init_waitqueue_head(&waitq); | 441 | init_waitqueue_head(&waitq); |
442 | 442 | ||
443 | memset (erase,0,sizeof(struct erase_info)); | ||
444 | if (copy_from_user(&erase->addr, argp, | 443 | if (copy_from_user(&erase->addr, argp, |
445 | sizeof(struct erase_info_user))) { | 444 | sizeof(struct erase_info_user))) { |
446 | kfree(erase); | 445 | kfree(erase); |
@@ -499,13 +498,12 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
499 | if (ret) | 498 | if (ret) |
500 | return ret; | 499 | return ret; |
501 | 500 | ||
502 | ops.len = buf.length; | ||
503 | ops.ooblen = buf.length; | 501 | ops.ooblen = buf.length; |
504 | ops.ooboffs = buf.start & (mtd->oobsize - 1); | 502 | ops.ooboffs = buf.start & (mtd->oobsize - 1); |
505 | ops.datbuf = NULL; | 503 | ops.datbuf = NULL; |
506 | ops.mode = MTD_OOB_PLACE; | 504 | ops.mode = MTD_OOB_PLACE; |
507 | 505 | ||
508 | if (ops.ooboffs && ops.len > (mtd->oobsize - ops.ooboffs)) | 506 | if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) |
509 | return -EINVAL; | 507 | return -EINVAL; |
510 | 508 | ||
511 | ops.oobbuf = kmalloc(buf.length, GFP_KERNEL); | 509 | ops.oobbuf = kmalloc(buf.length, GFP_KERNEL); |
@@ -520,7 +518,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
520 | buf.start &= ~(mtd->oobsize - 1); | 518 | buf.start &= ~(mtd->oobsize - 1); |
521 | ret = mtd->write_oob(mtd, buf.start, &ops); | 519 | ret = mtd->write_oob(mtd, buf.start, &ops); |
522 | 520 | ||
523 | if (copy_to_user(argp + sizeof(uint32_t), &ops.retlen, | 521 | if (copy_to_user(argp + sizeof(uint32_t), &ops.oobretlen, |
524 | sizeof(uint32_t))) | 522 | sizeof(uint32_t))) |
525 | ret = -EFAULT; | 523 | ret = -EFAULT; |
526 | 524 | ||
@@ -548,7 +546,6 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
548 | if (ret) | 546 | if (ret) |
549 | return ret; | 547 | return ret; |
550 | 548 | ||
551 | ops.len = buf.length; | ||
552 | ops.ooblen = buf.length; | 549 | ops.ooblen = buf.length; |
553 | ops.ooboffs = buf.start & (mtd->oobsize - 1); | 550 | ops.ooboffs = buf.start & (mtd->oobsize - 1); |
554 | ops.datbuf = NULL; | 551 | ops.datbuf = NULL; |
@@ -564,10 +561,10 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
564 | buf.start &= ~(mtd->oobsize - 1); | 561 | buf.start &= ~(mtd->oobsize - 1); |
565 | ret = mtd->read_oob(mtd, buf.start, &ops); | 562 | ret = mtd->read_oob(mtd, buf.start, &ops); |
566 | 563 | ||
567 | if (put_user(ops.retlen, (uint32_t __user *)argp)) | 564 | if (put_user(ops.oobretlen, (uint32_t __user *)argp)) |
568 | ret = -EFAULT; | 565 | ret = -EFAULT; |
569 | else if (ops.retlen && copy_to_user(buf.ptr, ops.oobbuf, | 566 | else if (ops.oobretlen && copy_to_user(buf.ptr, ops.oobbuf, |
570 | ops.retlen)) | 567 | ops.oobretlen)) |
571 | ret = -EFAULT; | 568 | ret = -EFAULT; |
572 | 569 | ||
573 | kfree(ops.oobbuf); | 570 | kfree(ops.oobbuf); |
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 1fea631b5852..ec51483b1c51 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
@@ -247,7 +247,7 @@ concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) | |||
247 | struct mtd_oob_ops devops = *ops; | 247 | struct mtd_oob_ops devops = *ops; |
248 | int i, err, ret = 0; | 248 | int i, err, ret = 0; |
249 | 249 | ||
250 | ops->retlen = 0; | 250 | ops->retlen = ops->oobretlen = 0; |
251 | 251 | ||
252 | for (i = 0; i < concat->num_subdev; i++) { | 252 | for (i = 0; i < concat->num_subdev; i++) { |
253 | struct mtd_info *subdev = concat->subdev[i]; | 253 | struct mtd_info *subdev = concat->subdev[i]; |
@@ -263,6 +263,7 @@ concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) | |||
263 | 263 | ||
264 | err = subdev->read_oob(subdev, from, &devops); | 264 | err = subdev->read_oob(subdev, from, &devops); |
265 | ops->retlen += devops.retlen; | 265 | ops->retlen += devops.retlen; |
266 | ops->oobretlen += devops.oobretlen; | ||
266 | 267 | ||
267 | /* Save information about bitflips! */ | 268 | /* Save information about bitflips! */ |
268 | if (unlikely(err)) { | 269 | if (unlikely(err)) { |
@@ -278,14 +279,18 @@ concat_read_oob(struct mtd_info *mtd, loff_t from, struct mtd_oob_ops *ops) | |||
278 | return err; | 279 | return err; |
279 | } | 280 | } |
280 | 281 | ||
281 | devops.len = ops->len - ops->retlen; | 282 | if (devops.datbuf) { |
282 | if (!devops.len) | 283 | devops.len = ops->len - ops->retlen; |
283 | return ret; | 284 | if (!devops.len) |
284 | 285 | return ret; | |
285 | if (devops.datbuf) | ||
286 | devops.datbuf += devops.retlen; | 286 | devops.datbuf += devops.retlen; |
287 | if (devops.oobbuf) | 287 | } |
288 | devops.oobbuf += devops.ooblen; | 288 | if (devops.oobbuf) { |
289 | devops.ooblen = ops->ooblen - ops->oobretlen; | ||
290 | if (!devops.ooblen) | ||
291 | return ret; | ||
292 | devops.oobbuf += ops->oobretlen; | ||
293 | } | ||
289 | 294 | ||
290 | from = 0; | 295 | from = 0; |
291 | } | 296 | } |
@@ -321,14 +326,18 @@ concat_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) | |||
321 | if (err) | 326 | if (err) |
322 | return err; | 327 | return err; |
323 | 328 | ||
324 | devops.len = ops->len - ops->retlen; | 329 | if (devops.datbuf) { |
325 | if (!devops.len) | 330 | devops.len = ops->len - ops->retlen; |
326 | return 0; | 331 | if (!devops.len) |
327 | 332 | return 0; | |
328 | if (devops.datbuf) | ||
329 | devops.datbuf += devops.retlen; | 333 | devops.datbuf += devops.retlen; |
330 | if (devops.oobbuf) | 334 | } |
331 | devops.oobbuf += devops.ooblen; | 335 | if (devops.oobbuf) { |
336 | devops.ooblen = ops->ooblen - ops->oobretlen; | ||
337 | if (!devops.ooblen) | ||
338 | return 0; | ||
339 | devops.oobbuf += devops.oobretlen; | ||
340 | } | ||
332 | to = 0; | 341 | to = 0; |
333 | } | 342 | } |
334 | return -EINVAL; | 343 | return -EINVAL; |
@@ -699,14 +708,13 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
699 | 708 | ||
700 | /* allocate the device structure */ | 709 | /* allocate the device structure */ |
701 | size = SIZEOF_STRUCT_MTD_CONCAT(num_devs); | 710 | size = SIZEOF_STRUCT_MTD_CONCAT(num_devs); |
702 | concat = kmalloc(size, GFP_KERNEL); | 711 | concat = kzalloc(size, GFP_KERNEL); |
703 | if (!concat) { | 712 | if (!concat) { |
704 | printk | 713 | printk |
705 | ("memory allocation error while creating concatenated device \"%s\"\n", | 714 | ("memory allocation error while creating concatenated device \"%s\"\n", |
706 | name); | 715 | name); |
707 | return NULL; | 716 | return NULL; |
708 | } | 717 | } |
709 | memset(concat, 0, size); | ||
710 | concat->subdev = (struct mtd_info **) (concat + 1); | 718 | concat->subdev = (struct mtd_info **) (concat + 1); |
711 | 719 | ||
712 | /* | 720 | /* |
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 06a930372b7a..89692f898ef4 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
@@ -94,7 +94,7 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from, | |||
94 | 94 | ||
95 | if (from >= mtd->size) | 95 | if (from >= mtd->size) |
96 | return -EINVAL; | 96 | return -EINVAL; |
97 | if (from + ops->len > mtd->size) | 97 | if (ops->datbuf && from + ops->len > mtd->size) |
98 | return -EINVAL; | 98 | return -EINVAL; |
99 | res = part->master->read_oob(part->master, from + part->offset, ops); | 99 | res = part->master->read_oob(part->master, from + part->offset, ops); |
100 | 100 | ||
@@ -161,7 +161,7 @@ static int part_write_oob(struct mtd_info *mtd, loff_t to, | |||
161 | 161 | ||
162 | if (to >= mtd->size) | 162 | if (to >= mtd->size) |
163 | return -EINVAL; | 163 | return -EINVAL; |
164 | if (to + ops->len > mtd->size) | 164 | if (ops->datbuf && to + ops->len > mtd->size) |
165 | return -EINVAL; | 165 | return -EINVAL; |
166 | return part->master->write_oob(part->master, to + part->offset, ops); | 166 | return part->master->write_oob(part->master, to + part->offset, ops); |
167 | } | 167 | } |
@@ -323,14 +323,13 @@ int add_mtd_partitions(struct mtd_info *master, | |||
323 | for (i = 0; i < nbparts; i++) { | 323 | for (i = 0; i < nbparts; i++) { |
324 | 324 | ||
325 | /* allocate the partition structure */ | 325 | /* allocate the partition structure */ |
326 | slave = kmalloc (sizeof(*slave), GFP_KERNEL); | 326 | slave = kzalloc (sizeof(*slave), GFP_KERNEL); |
327 | if (!slave) { | 327 | if (!slave) { |
328 | printk ("memory allocation error while creating partitions for \"%s\"\n", | 328 | printk ("memory allocation error while creating partitions for \"%s\"\n", |
329 | master->name); | 329 | master->name); |
330 | del_mtd_partitions(master); | 330 | del_mtd_partitions(master); |
331 | return -ENOMEM; | 331 | return -ENOMEM; |
332 | } | 332 | } |
333 | memset(slave, 0, sizeof(*slave)); | ||
334 | list_add(&slave->list, &mtd_partitions); | 333 | list_add(&slave->list, &mtd_partitions); |
335 | 334 | ||
336 | /* set up the MTD object for this partition */ | 335 | /* set up the MTD object for this partition */ |
diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig index b4b1656735bd..06627757f500 100644 --- a/drivers/mtd/nand/Kconfig +++ b/drivers/mtd/nand/Kconfig | |||
@@ -90,6 +90,7 @@ config MTD_NAND_RTC_FROM4 | |||
90 | depends on MTD_NAND && SH_SOLUTION_ENGINE | 90 | depends on MTD_NAND && SH_SOLUTION_ENGINE |
91 | select REED_SOLOMON | 91 | select REED_SOLOMON |
92 | select REED_SOLOMON_DEC8 | 92 | select REED_SOLOMON_DEC8 |
93 | select BITREVERSE | ||
93 | help | 94 | help |
94 | This enables the driver for the Renesas Technology AG-AND | 95 | This enables the driver for the Renesas Technology AG-AND |
95 | flash interface board (FROM_BOARD4) | 96 | flash interface board (FROM_BOARD4) |
@@ -219,6 +220,13 @@ config MTD_NAND_SHARPSL | |||
219 | tristate "Support for NAND Flash on Sharp SL Series (C7xx + others)" | 220 | tristate "Support for NAND Flash on Sharp SL Series (C7xx + others)" |
220 | depends on MTD_NAND && ARCH_PXA | 221 | depends on MTD_NAND && ARCH_PXA |
221 | 222 | ||
223 | config MTD_NAND_CAFE | ||
224 | tristate "NAND support for OLPC CAFÉ chip" | ||
225 | depends on PCI | ||
226 | help | ||
227 | Use NAND flash attached to the CAFÉ chip designed for the $100 | ||
228 | laptop. | ||
229 | |||
222 | config MTD_NAND_CS553X | 230 | config MTD_NAND_CS553X |
223 | tristate "NAND support for CS5535/CS5536 (AMD Geode companion chip)" | 231 | tristate "NAND support for CS5535/CS5536 (AMD Geode companion chip)" |
224 | depends on MTD_NAND && X86_32 && (X86_PC || X86_GENERICARCH) | 232 | depends on MTD_NAND && X86_32 && (X86_PC || X86_GENERICARCH) |
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile index 27c9f0a1ef83..f7a53f0b7017 100644 --- a/drivers/mtd/nand/Makefile +++ b/drivers/mtd/nand/Makefile | |||
@@ -6,6 +6,7 @@ | |||
6 | obj-$(CONFIG_MTD_NAND) += nand.o nand_ecc.o | 6 | obj-$(CONFIG_MTD_NAND) += nand.o nand_ecc.o |
7 | obj-$(CONFIG_MTD_NAND_IDS) += nand_ids.o | 7 | obj-$(CONFIG_MTD_NAND_IDS) += nand_ids.o |
8 | 8 | ||
9 | obj-$(CONFIG_MTD_NAND_CAFE) += cafe_nand.o | ||
9 | obj-$(CONFIG_MTD_NAND_SPIA) += spia.o | 10 | obj-$(CONFIG_MTD_NAND_SPIA) += spia.o |
10 | obj-$(CONFIG_MTD_NAND_AMS_DELTA) += ams-delta.o | 11 | obj-$(CONFIG_MTD_NAND_AMS_DELTA) += ams-delta.o |
11 | obj-$(CONFIG_MTD_NAND_TOTO) += toto.o | 12 | obj-$(CONFIG_MTD_NAND_TOTO) += toto.o |
@@ -24,4 +25,5 @@ obj-$(CONFIG_MTD_NAND_CS553X) += cs553x_nand.o | |||
24 | obj-$(CONFIG_MTD_NAND_NDFC) += ndfc.o | 25 | obj-$(CONFIG_MTD_NAND_NDFC) += ndfc.o |
25 | obj-$(CONFIG_MTD_NAND_AT91) += at91_nand.o | 26 | obj-$(CONFIG_MTD_NAND_AT91) += at91_nand.o |
26 | 27 | ||
27 | nand-objs = nand_base.o nand_bbt.o | 28 | nand-objs := nand_base.o nand_bbt.o |
29 | cafe_nand-objs := cafe.o cafe_ecc.o | ||
diff --git a/drivers/mtd/nand/cafe.c b/drivers/mtd/nand/cafe.c new file mode 100644 index 000000000000..fad304bf7b7e --- /dev/null +++ b/drivers/mtd/nand/cafe.c | |||
@@ -0,0 +1,771 @@ | |||
1 | /* | ||
2 | * Driver for One Laptop Per Child ‘CAFÉ’ controller, aka Marvell 88ALP01 | ||
3 | * | ||
4 | * Copyright © 2006 Red Hat, Inc. | ||
5 | * Copyright © 2006 David Woodhouse <dwmw2@infradead.org> | ||
6 | */ | ||
7 | |||
8 | #define DEBUG | ||
9 | |||
10 | #include <linux/device.h> | ||
11 | #undef DEBUG | ||
12 | #include <linux/mtd/mtd.h> | ||
13 | #include <linux/mtd/nand.h> | ||
14 | #include <linux/pci.h> | ||
15 | #include <linux/delay.h> | ||
16 | #include <linux/interrupt.h> | ||
17 | #include <asm/io.h> | ||
18 | |||
19 | #define CAFE_NAND_CTRL1 0x00 | ||
20 | #define CAFE_NAND_CTRL2 0x04 | ||
21 | #define CAFE_NAND_CTRL3 0x08 | ||
22 | #define CAFE_NAND_STATUS 0x0c | ||
23 | #define CAFE_NAND_IRQ 0x10 | ||
24 | #define CAFE_NAND_IRQ_MASK 0x14 | ||
25 | #define CAFE_NAND_DATA_LEN 0x18 | ||
26 | #define CAFE_NAND_ADDR1 0x1c | ||
27 | #define CAFE_NAND_ADDR2 0x20 | ||
28 | #define CAFE_NAND_TIMING1 0x24 | ||
29 | #define CAFE_NAND_TIMING2 0x28 | ||
30 | #define CAFE_NAND_TIMING3 0x2c | ||
31 | #define CAFE_NAND_NONMEM 0x30 | ||
32 | #define CAFE_NAND_ECC_RESULT 0x3C | ||
33 | #define CAFE_NAND_DMA_CTRL 0x40 | ||
34 | #define CAFE_NAND_DMA_ADDR0 0x44 | ||
35 | #define CAFE_NAND_DMA_ADDR1 0x48 | ||
36 | #define CAFE_NAND_ECC_SYN01 0x50 | ||
37 | #define CAFE_NAND_ECC_SYN23 0x54 | ||
38 | #define CAFE_NAND_ECC_SYN45 0x58 | ||
39 | #define CAFE_NAND_ECC_SYN67 0x5c | ||
40 | #define CAFE_NAND_READ_DATA 0x1000 | ||
41 | #define CAFE_NAND_WRITE_DATA 0x2000 | ||
42 | |||
43 | #define CAFE_GLOBAL_CTRL 0x3004 | ||
44 | #define CAFE_GLOBAL_IRQ 0x3008 | ||
45 | #define CAFE_GLOBAL_IRQ_MASK 0x300c | ||
46 | #define CAFE_NAND_RESET 0x3034 | ||
47 | |||
48 | int cafe_correct_ecc(unsigned char *buf, | ||
49 | unsigned short *chk_syndrome_list); | ||
50 | |||
51 | struct cafe_priv { | ||
52 | struct nand_chip nand; | ||
53 | struct pci_dev *pdev; | ||
54 | void __iomem *mmio; | ||
55 | uint32_t ctl1; | ||
56 | uint32_t ctl2; | ||
57 | int datalen; | ||
58 | int nr_data; | ||
59 | int data_pos; | ||
60 | int page_addr; | ||
61 | dma_addr_t dmaaddr; | ||
62 | unsigned char *dmabuf; | ||
63 | |||
64 | }; | ||
65 | |||
66 | static int usedma = 1; | ||
67 | module_param(usedma, int, 0644); | ||
68 | |||
69 | static int skipbbt = 0; | ||
70 | module_param(skipbbt, int, 0644); | ||
71 | |||
72 | static int debug = 0; | ||
73 | module_param(debug, int, 0644); | ||
74 | |||
75 | static int regdebug = 0; | ||
76 | module_param(regdebug, int, 0644); | ||
77 | |||
78 | static int checkecc = 1; | ||
79 | module_param(checkecc, int, 0644); | ||
80 | |||
81 | static int slowtiming = 0; | ||
82 | module_param(slowtiming, int, 0644); | ||
83 | |||
84 | /* Hrm. Why isn't this already conditional on something in the struct device? */ | ||
85 | #define cafe_dev_dbg(dev, args...) do { if (debug) dev_dbg(dev, ##args); } while(0) | ||
86 | |||
87 | /* Make it easier to switch to PIO if we need to */ | ||
88 | #define cafe_readl(cafe, addr) readl((cafe)->mmio + CAFE_##addr) | ||
89 | #define cafe_writel(cafe, datum, addr) writel(datum, (cafe)->mmio + CAFE_##addr) | ||
90 | |||
91 | static int cafe_device_ready(struct mtd_info *mtd) | ||
92 | { | ||
93 | struct cafe_priv *cafe = mtd->priv; | ||
94 | int result = !!(cafe_readl(cafe, NAND_STATUS) | 0x40000000); | ||
95 | uint32_t irqs = cafe_readl(cafe, NAND_IRQ); | ||
96 | |||
97 | cafe_writel(cafe, irqs, NAND_IRQ); | ||
98 | |||
99 | cafe_dev_dbg(&cafe->pdev->dev, "NAND device is%s ready, IRQ %x (%x) (%x,%x)\n", | ||
100 | result?"":" not", irqs, cafe_readl(cafe, NAND_IRQ), | ||
101 | cafe_readl(cafe, GLOBAL_IRQ), cafe_readl(cafe, GLOBAL_IRQ_MASK)); | ||
102 | |||
103 | return result; | ||
104 | } | ||
105 | |||
106 | |||
107 | static void cafe_write_buf(struct mtd_info *mtd, const uint8_t *buf, int len) | ||
108 | { | ||
109 | struct cafe_priv *cafe = mtd->priv; | ||
110 | |||
111 | if (usedma) | ||
112 | memcpy(cafe->dmabuf + cafe->datalen, buf, len); | ||
113 | else | ||
114 | memcpy_toio(cafe->mmio + CAFE_NAND_WRITE_DATA + cafe->datalen, buf, len); | ||
115 | |||
116 | cafe->datalen += len; | ||
117 | |||
118 | cafe_dev_dbg(&cafe->pdev->dev, "Copy 0x%x bytes to write buffer. datalen 0x%x\n", | ||
119 | len, cafe->datalen); | ||
120 | } | ||
121 | |||
122 | static void cafe_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) | ||
123 | { | ||
124 | struct cafe_priv *cafe = mtd->priv; | ||
125 | |||
126 | if (usedma) | ||
127 | memcpy(buf, cafe->dmabuf + cafe->datalen, len); | ||
128 | else | ||
129 | memcpy_fromio(buf, cafe->mmio + CAFE_NAND_READ_DATA + cafe->datalen, len); | ||
130 | |||
131 | cafe_dev_dbg(&cafe->pdev->dev, "Copy 0x%x bytes from position 0x%x in read buffer.\n", | ||
132 | len, cafe->datalen); | ||
133 | cafe->datalen += len; | ||
134 | } | ||
135 | |||
136 | static uint8_t cafe_read_byte(struct mtd_info *mtd) | ||
137 | { | ||
138 | struct cafe_priv *cafe = mtd->priv; | ||
139 | uint8_t d; | ||
140 | |||
141 | cafe_read_buf(mtd, &d, 1); | ||
142 | cafe_dev_dbg(&cafe->pdev->dev, "Read %02x\n", d); | ||
143 | |||
144 | return d; | ||
145 | } | ||
146 | |||
147 | static void cafe_nand_cmdfunc(struct mtd_info *mtd, unsigned command, | ||
148 | int column, int page_addr) | ||
149 | { | ||
150 | struct cafe_priv *cafe = mtd->priv; | ||
151 | int adrbytes = 0; | ||
152 | uint32_t ctl1; | ||
153 | uint32_t doneint = 0x80000000; | ||
154 | |||
155 | cafe_dev_dbg(&cafe->pdev->dev, "cmdfunc %02x, 0x%x, 0x%x\n", | ||
156 | command, column, page_addr); | ||
157 | |||
158 | if (command == NAND_CMD_ERASE2 || command == NAND_CMD_PAGEPROG) { | ||
159 | /* Second half of a command we already calculated */ | ||
160 | cafe_writel(cafe, cafe->ctl2 | 0x100 | command, NAND_CTRL2); | ||
161 | ctl1 = cafe->ctl1; | ||
162 | cafe->ctl2 &= ~(1<<30); | ||
163 | cafe_dev_dbg(&cafe->pdev->dev, "Continue command, ctl1 %08x, #data %d\n", | ||
164 | cafe->ctl1, cafe->nr_data); | ||
165 | goto do_command; | ||
166 | } | ||
167 | /* Reset ECC engine */ | ||
168 | cafe_writel(cafe, 0, NAND_CTRL2); | ||
169 | |||
170 | /* Emulate NAND_CMD_READOOB on large-page chips */ | ||
171 | if (mtd->writesize > 512 && | ||
172 | command == NAND_CMD_READOOB) { | ||
173 | column += mtd->writesize; | ||
174 | command = NAND_CMD_READ0; | ||
175 | } | ||
176 | |||
177 | /* FIXME: Do we need to send read command before sending data | ||
178 | for small-page chips, to position the buffer correctly? */ | ||
179 | |||
180 | if (column != -1) { | ||
181 | cafe_writel(cafe, column, NAND_ADDR1); | ||
182 | adrbytes = 2; | ||
183 | if (page_addr != -1) | ||
184 | goto write_adr2; | ||
185 | } else if (page_addr != -1) { | ||
186 | cafe_writel(cafe, page_addr & 0xffff, NAND_ADDR1); | ||
187 | page_addr >>= 16; | ||
188 | write_adr2: | ||
189 | cafe_writel(cafe, page_addr, NAND_ADDR2); | ||
190 | adrbytes += 2; | ||
191 | if (mtd->size > mtd->writesize << 16) | ||
192 | adrbytes++; | ||
193 | } | ||
194 | |||
195 | cafe->data_pos = cafe->datalen = 0; | ||
196 | |||
197 | /* Set command valid bit */ | ||
198 | ctl1 = 0x80000000 | command; | ||
199 | |||
200 | /* Set RD or WR bits as appropriate */ | ||
201 | if (command == NAND_CMD_READID || command == NAND_CMD_STATUS) { | ||
202 | ctl1 |= (1<<26); /* rd */ | ||
203 | /* Always 5 bytes, for now */ | ||
204 | cafe->datalen = 4; | ||
205 | /* And one address cycle -- even for STATUS, since the controller doesn't work without */ | ||
206 | adrbytes = 1; | ||
207 | } else if (command == NAND_CMD_READ0 || command == NAND_CMD_READ1 || | ||
208 | command == NAND_CMD_READOOB || command == NAND_CMD_RNDOUT) { | ||
209 | ctl1 |= 1<<26; /* rd */ | ||
210 | /* For now, assume just read to end of page */ | ||
211 | cafe->datalen = mtd->writesize + mtd->oobsize - column; | ||
212 | } else if (command == NAND_CMD_SEQIN) | ||
213 | ctl1 |= 1<<25; /* wr */ | ||
214 | |||
215 | /* Set number of address bytes */ | ||
216 | if (adrbytes) | ||
217 | ctl1 |= ((adrbytes-1)|8) << 27; | ||
218 | |||
219 | if (command == NAND_CMD_SEQIN || command == NAND_CMD_ERASE1) { | ||
220 | /* Ignore the first command of a pair; the hardware | ||
221 | deals with them both at once, later */ | ||
222 | cafe->ctl1 = ctl1; | ||
223 | cafe_dev_dbg(&cafe->pdev->dev, "Setup for delayed command, ctl1 %08x, dlen %x\n", | ||
224 | cafe->ctl1, cafe->datalen); | ||
225 | return; | ||
226 | } | ||
227 | /* RNDOUT and READ0 commands need a following byte */ | ||
228 | if (command == NAND_CMD_RNDOUT) | ||
229 | cafe_writel(cafe, cafe->ctl2 | 0x100 | NAND_CMD_RNDOUTSTART, NAND_CTRL2); | ||
230 | else if (command == NAND_CMD_READ0 && mtd->writesize > 512) | ||
231 | cafe_writel(cafe, cafe->ctl2 | 0x100 | NAND_CMD_READSTART, NAND_CTRL2); | ||
232 | |||
233 | do_command: | ||
234 | cafe_dev_dbg(&cafe->pdev->dev, "dlen %x, ctl1 %x, ctl2 %x\n", | ||
235 | cafe->datalen, ctl1, cafe_readl(cafe, NAND_CTRL2)); | ||
236 | |||
237 | /* NB: The datasheet lies -- we really should be subtracting 1 here */ | ||
238 | cafe_writel(cafe, cafe->datalen, NAND_DATA_LEN); | ||
239 | cafe_writel(cafe, 0x90000000, NAND_IRQ); | ||
240 | if (usedma && (ctl1 & (3<<25))) { | ||
241 | uint32_t dmactl = 0xc0000000 + cafe->datalen; | ||
242 | /* If WR or RD bits set, set up DMA */ | ||
243 | if (ctl1 & (1<<26)) { | ||
244 | /* It's a read */ | ||
245 | dmactl |= (1<<29); | ||
246 | /* ... so it's done when the DMA is done, not just | ||
247 | the command. */ | ||
248 | doneint = 0x10000000; | ||
249 | } | ||
250 | cafe_writel(cafe, dmactl, NAND_DMA_CTRL); | ||
251 | } | ||
252 | cafe->datalen = 0; | ||
253 | |||
254 | if (unlikely(regdebug)) { | ||
255 | int i; | ||
256 | printk("About to write command %08x to register 0\n", ctl1); | ||
257 | for (i=4; i< 0x5c; i+=4) | ||
258 | printk("Register %x: %08x\n", i, readl(cafe->mmio + i)); | ||
259 | } | ||
260 | |||
261 | cafe_writel(cafe, ctl1, NAND_CTRL1); | ||
262 | /* Apply this short delay always to ensure that we do wait tWB in | ||
263 | * any case on any machine. */ | ||
264 | ndelay(100); | ||
265 | |||
266 | if (1) { | ||
267 | int c = 500000; | ||
268 | uint32_t irqs; | ||
269 | |||
270 | while (c--) { | ||
271 | irqs = cafe_readl(cafe, NAND_IRQ); | ||
272 | if (irqs & doneint) | ||
273 | break; | ||
274 | udelay(1); | ||
275 | if (!(c % 100000)) | ||
276 | cafe_dev_dbg(&cafe->pdev->dev, "Wait for ready, IRQ %x\n", irqs); | ||
277 | cpu_relax(); | ||
278 | } | ||
279 | cafe_writel(cafe, doneint, NAND_IRQ); | ||
280 | cafe_dev_dbg(&cafe->pdev->dev, "Command %x completed after %d usec, irqs %x (%x)\n", | ||
281 | command, 500000-c, irqs, cafe_readl(cafe, NAND_IRQ)); | ||
282 | } | ||
283 | |||
284 | WARN_ON(cafe->ctl2 & (1<<30)); | ||
285 | |||
286 | switch (command) { | ||
287 | |||
288 | case NAND_CMD_CACHEDPROG: | ||
289 | case NAND_CMD_PAGEPROG: | ||
290 | case NAND_CMD_ERASE1: | ||
291 | case NAND_CMD_ERASE2: | ||
292 | case NAND_CMD_SEQIN: | ||
293 | case NAND_CMD_RNDIN: | ||
294 | case NAND_CMD_STATUS: | ||
295 | case NAND_CMD_DEPLETE1: | ||
296 | case NAND_CMD_RNDOUT: | ||
297 | case NAND_CMD_STATUS_ERROR: | ||
298 | case NAND_CMD_STATUS_ERROR0: | ||
299 | case NAND_CMD_STATUS_ERROR1: | ||
300 | case NAND_CMD_STATUS_ERROR2: | ||
301 | case NAND_CMD_STATUS_ERROR3: | ||
302 | cafe_writel(cafe, cafe->ctl2, NAND_CTRL2); | ||
303 | return; | ||
304 | } | ||
305 | nand_wait_ready(mtd); | ||
306 | cafe_writel(cafe, cafe->ctl2, NAND_CTRL2); | ||
307 | } | ||
308 | |||
309 | static void cafe_select_chip(struct mtd_info *mtd, int chipnr) | ||
310 | { | ||
311 | //struct cafe_priv *cafe = mtd->priv; | ||
312 | // cafe_dev_dbg(&cafe->pdev->dev, "select_chip %d\n", chipnr); | ||
313 | } | ||
314 | |||
315 | static int cafe_nand_interrupt(int irq, void *id, struct pt_regs *regs) | ||
316 | { | ||
317 | struct mtd_info *mtd = id; | ||
318 | struct cafe_priv *cafe = mtd->priv; | ||
319 | uint32_t irqs = cafe_readl(cafe, NAND_IRQ); | ||
320 | cafe_writel(cafe, irqs & ~0x90000000, NAND_IRQ); | ||
321 | if (!irqs) | ||
322 | return IRQ_NONE; | ||
323 | |||
324 | cafe_dev_dbg(&cafe->pdev->dev, "irq, bits %x (%x)\n", irqs, cafe_readl(cafe, NAND_IRQ)); | ||
325 | return IRQ_HANDLED; | ||
326 | } | ||
327 | |||
328 | static void cafe_nand_bug(struct mtd_info *mtd) | ||
329 | { | ||
330 | BUG(); | ||
331 | } | ||
332 | |||
333 | static int cafe_nand_write_oob(struct mtd_info *mtd, | ||
334 | struct nand_chip *chip, int page) | ||
335 | { | ||
336 | int status = 0; | ||
337 | |||
338 | chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize, page); | ||
339 | chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); | ||
340 | chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); | ||
341 | status = chip->waitfunc(mtd, chip); | ||
342 | |||
343 | return status & NAND_STATUS_FAIL ? -EIO : 0; | ||
344 | } | ||
345 | |||
346 | /* Don't use -- use nand_read_oob_std for now */ | ||
347 | static int cafe_nand_read_oob(struct mtd_info *mtd, struct nand_chip *chip, | ||
348 | int page, int sndcmd) | ||
349 | { | ||
350 | chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); | ||
351 | chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); | ||
352 | return 1; | ||
353 | } | ||
354 | /** | ||
355 | * cafe_nand_read_page_syndrome - {REPLACABLE] hardware ecc syndrom based page read | ||
356 | * @mtd: mtd info structure | ||
357 | * @chip: nand chip info structure | ||
358 | * @buf: buffer to store read data | ||
359 | * | ||
360 | * The hw generator calculates the error syndrome automatically. Therefor | ||
361 | * we need a special oob layout and handling. | ||
362 | */ | ||
363 | static int cafe_nand_read_page(struct mtd_info *mtd, struct nand_chip *chip, | ||
364 | uint8_t *buf) | ||
365 | { | ||
366 | struct cafe_priv *cafe = mtd->priv; | ||
367 | |||
368 | cafe_dev_dbg(&cafe->pdev->dev, "ECC result %08x SYN1,2 %08x\n", | ||
369 | cafe_readl(cafe, NAND_ECC_RESULT), | ||
370 | cafe_readl(cafe, NAND_ECC_SYN01)); | ||
371 | |||
372 | chip->read_buf(mtd, buf, mtd->writesize); | ||
373 | chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); | ||
374 | |||
375 | if (checkecc && cafe_readl(cafe, NAND_ECC_RESULT) & (1<<18)) { | ||
376 | unsigned short syn[8]; | ||
377 | int i; | ||
378 | |||
379 | for (i=0; i<8; i+=2) { | ||
380 | uint32_t tmp = cafe_readl(cafe, NAND_ECC_SYN01 + (i*2)); | ||
381 | syn[i] = tmp & 0xfff; | ||
382 | syn[i+1] = (tmp >> 16) & 0xfff; | ||
383 | } | ||
384 | |||
385 | if ((i = cafe_correct_ecc(buf, syn)) < 0) { | ||
386 | dev_dbg(&cafe->pdev->dev, "Failed to correct ECC at %08x\n", | ||
387 | cafe_readl(cafe, NAND_ADDR2) * 2048); | ||
388 | for (i=0; i< 0x5c; i+=4) | ||
389 | printk("Register %x: %08x\n", i, readl(cafe->mmio + i)); | ||
390 | mtd->ecc_stats.failed++; | ||
391 | } else { | ||
392 | dev_dbg(&cafe->pdev->dev, "Corrected %d symbol errors\n", i); | ||
393 | mtd->ecc_stats.corrected += i; | ||
394 | } | ||
395 | } | ||
396 | |||
397 | |||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | static struct nand_ecclayout cafe_oobinfo_2048 = { | ||
402 | .eccbytes = 14, | ||
403 | .eccpos = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, | ||
404 | .oobfree = {{14, 50}} | ||
405 | }; | ||
406 | |||
407 | /* Ick. The BBT code really ought to be able to work this bit out | ||
408 | for itself from the above, at least for the 2KiB case */ | ||
409 | static uint8_t cafe_bbt_pattern_2048[] = { 'B', 'b', 't', '0' }; | ||
410 | static uint8_t cafe_mirror_pattern_2048[] = { '1', 't', 'b', 'B' }; | ||
411 | |||
412 | static uint8_t cafe_bbt_pattern_512[] = { 0xBB }; | ||
413 | static uint8_t cafe_mirror_pattern_512[] = { 0xBC }; | ||
414 | |||
415 | |||
416 | static struct nand_bbt_descr cafe_bbt_main_descr_2048 = { | ||
417 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | ||
418 | | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, | ||
419 | .offs = 14, | ||
420 | .len = 4, | ||
421 | .veroffs = 18, | ||
422 | .maxblocks = 4, | ||
423 | .pattern = cafe_bbt_pattern_2048 | ||
424 | }; | ||
425 | |||
426 | static struct nand_bbt_descr cafe_bbt_mirror_descr_2048 = { | ||
427 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | ||
428 | | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, | ||
429 | .offs = 14, | ||
430 | .len = 4, | ||
431 | .veroffs = 18, | ||
432 | .maxblocks = 4, | ||
433 | .pattern = cafe_mirror_pattern_2048 | ||
434 | }; | ||
435 | |||
436 | static struct nand_ecclayout cafe_oobinfo_512 = { | ||
437 | .eccbytes = 14, | ||
438 | .eccpos = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, | ||
439 | .oobfree = {{14, 2}} | ||
440 | }; | ||
441 | |||
442 | static struct nand_bbt_descr cafe_bbt_main_descr_512 = { | ||
443 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | ||
444 | | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, | ||
445 | .offs = 14, | ||
446 | .len = 1, | ||
447 | .veroffs = 15, | ||
448 | .maxblocks = 4, | ||
449 | .pattern = cafe_bbt_pattern_512 | ||
450 | }; | ||
451 | |||
452 | static struct nand_bbt_descr cafe_bbt_mirror_descr_512 = { | ||
453 | .options = NAND_BBT_LASTBLOCK | NAND_BBT_CREATE | NAND_BBT_WRITE | ||
454 | | NAND_BBT_2BIT | NAND_BBT_VERSION | NAND_BBT_PERCHIP, | ||
455 | .offs = 14, | ||
456 | .len = 1, | ||
457 | .veroffs = 15, | ||
458 | .maxblocks = 4, | ||
459 | .pattern = cafe_mirror_pattern_512 | ||
460 | }; | ||
461 | |||
462 | |||
463 | static void cafe_nand_write_page_lowlevel(struct mtd_info *mtd, | ||
464 | struct nand_chip *chip, const uint8_t *buf) | ||
465 | { | ||
466 | struct cafe_priv *cafe = mtd->priv; | ||
467 | |||
468 | chip->write_buf(mtd, buf, mtd->writesize); | ||
469 | chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); | ||
470 | |||
471 | /* Set up ECC autogeneration */ | ||
472 | cafe->ctl2 |= (1<<30); | ||
473 | } | ||
474 | |||
475 | static int cafe_nand_write_page(struct mtd_info *mtd, struct nand_chip *chip, | ||
476 | const uint8_t *buf, int page, int cached, int raw) | ||
477 | { | ||
478 | int status; | ||
479 | |||
480 | chip->cmdfunc(mtd, NAND_CMD_SEQIN, 0x00, page); | ||
481 | |||
482 | if (unlikely(raw)) | ||
483 | chip->ecc.write_page_raw(mtd, chip, buf); | ||
484 | else | ||
485 | chip->ecc.write_page(mtd, chip, buf); | ||
486 | |||
487 | /* | ||
488 | * Cached progamming disabled for now, Not sure if its worth the | ||
489 | * trouble. The speed gain is not very impressive. (2.3->2.6Mib/s) | ||
490 | */ | ||
491 | cached = 0; | ||
492 | |||
493 | if (!cached || !(chip->options & NAND_CACHEPRG)) { | ||
494 | |||
495 | chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1); | ||
496 | status = chip->waitfunc(mtd, chip); | ||
497 | /* | ||
498 | * See if operation failed and additional status checks are | ||
499 | * available | ||
500 | */ | ||
501 | if ((status & NAND_STATUS_FAIL) && (chip->errstat)) | ||
502 | status = chip->errstat(mtd, chip, FL_WRITING, status, | ||
503 | page); | ||
504 | |||
505 | if (status & NAND_STATUS_FAIL) | ||
506 | return -EIO; | ||
507 | } else { | ||
508 | chip->cmdfunc(mtd, NAND_CMD_CACHEDPROG, -1, -1); | ||
509 | status = chip->waitfunc(mtd, chip); | ||
510 | } | ||
511 | |||
512 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE | ||
513 | /* Send command to read back the data */ | ||
514 | chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); | ||
515 | |||
516 | if (chip->verify_buf(mtd, buf, mtd->writesize)) | ||
517 | return -EIO; | ||
518 | #endif | ||
519 | return 0; | ||
520 | } | ||
521 | |||
522 | static int cafe_nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) | ||
523 | { | ||
524 | return 0; | ||
525 | } | ||
526 | |||
527 | static int __devinit cafe_nand_probe(struct pci_dev *pdev, | ||
528 | const struct pci_device_id *ent) | ||
529 | { | ||
530 | struct mtd_info *mtd; | ||
531 | struct cafe_priv *cafe; | ||
532 | uint32_t ctrl; | ||
533 | int err = 0; | ||
534 | |||
535 | err = pci_enable_device(pdev); | ||
536 | if (err) | ||
537 | return err; | ||
538 | |||
539 | pci_set_master(pdev); | ||
540 | |||
541 | mtd = kzalloc(sizeof(*mtd) + sizeof(struct cafe_priv), GFP_KERNEL); | ||
542 | if (!mtd) { | ||
543 | dev_warn(&pdev->dev, "failed to alloc mtd_info\n"); | ||
544 | return -ENOMEM; | ||
545 | } | ||
546 | cafe = (void *)(&mtd[1]); | ||
547 | |||
548 | mtd->priv = cafe; | ||
549 | mtd->owner = THIS_MODULE; | ||
550 | |||
551 | cafe->pdev = pdev; | ||
552 | cafe->mmio = pci_iomap(pdev, 0, 0); | ||
553 | if (!cafe->mmio) { | ||
554 | dev_warn(&pdev->dev, "failed to iomap\n"); | ||
555 | err = -ENOMEM; | ||
556 | goto out_free_mtd; | ||
557 | } | ||
558 | cafe->dmabuf = dma_alloc_coherent(&cafe->pdev->dev, 2112 + sizeof(struct nand_buffers), | ||
559 | &cafe->dmaaddr, GFP_KERNEL); | ||
560 | if (!cafe->dmabuf) { | ||
561 | err = -ENOMEM; | ||
562 | goto out_ior; | ||
563 | } | ||
564 | cafe->nand.buffers = (void *)cafe->dmabuf + 2112; | ||
565 | |||
566 | cafe->nand.cmdfunc = cafe_nand_cmdfunc; | ||
567 | cafe->nand.dev_ready = cafe_device_ready; | ||
568 | cafe->nand.read_byte = cafe_read_byte; | ||
569 | cafe->nand.read_buf = cafe_read_buf; | ||
570 | cafe->nand.write_buf = cafe_write_buf; | ||
571 | cafe->nand.select_chip = cafe_select_chip; | ||
572 | |||
573 | cafe->nand.chip_delay = 0; | ||
574 | |||
575 | /* Enable the following for a flash based bad block table */ | ||
576 | cafe->nand.options = NAND_USE_FLASH_BBT | NAND_NO_AUTOINCR | NAND_OWN_BUFFERS; | ||
577 | |||
578 | if (skipbbt) { | ||
579 | cafe->nand.options |= NAND_SKIP_BBTSCAN; | ||
580 | cafe->nand.block_bad = cafe_nand_block_bad; | ||
581 | } | ||
582 | |||
583 | /* Start off by resetting the NAND controller completely */ | ||
584 | cafe_writel(cafe, 1, NAND_RESET); | ||
585 | cafe_writel(cafe, 0, NAND_RESET); | ||
586 | |||
587 | cafe_writel(cafe, 0xffffffff, NAND_IRQ_MASK); | ||
588 | |||
589 | /* Timings from Marvell's test code (not verified or calculated by us) */ | ||
590 | if (!slowtiming) { | ||
591 | cafe_writel(cafe, 0x01010a0a, NAND_TIMING1); | ||
592 | cafe_writel(cafe, 0x24121212, NAND_TIMING2); | ||
593 | cafe_writel(cafe, 0x11000000, NAND_TIMING3); | ||
594 | } else { | ||
595 | cafe_writel(cafe, 0xffffffff, NAND_TIMING1); | ||
596 | cafe_writel(cafe, 0xffffffff, NAND_TIMING2); | ||
597 | cafe_writel(cafe, 0xffffffff, NAND_TIMING3); | ||
598 | } | ||
599 | cafe_writel(cafe, 0xffffffff, NAND_IRQ_MASK); | ||
600 | err = request_irq(pdev->irq, &cafe_nand_interrupt, SA_SHIRQ, "CAFE NAND", mtd); | ||
601 | if (err) { | ||
602 | dev_warn(&pdev->dev, "Could not register IRQ %d\n", pdev->irq); | ||
603 | |||
604 | goto out_free_dma; | ||
605 | } | ||
606 | #if 1 | ||
607 | /* Disable master reset, enable NAND clock */ | ||
608 | ctrl = cafe_readl(cafe, GLOBAL_CTRL); | ||
609 | ctrl &= 0xffffeff0; | ||
610 | ctrl |= 0x00007000; | ||
611 | cafe_writel(cafe, ctrl | 0x05, GLOBAL_CTRL); | ||
612 | cafe_writel(cafe, ctrl | 0x0a, GLOBAL_CTRL); | ||
613 | cafe_writel(cafe, 0, NAND_DMA_CTRL); | ||
614 | |||
615 | cafe_writel(cafe, 0x7006, GLOBAL_CTRL); | ||
616 | cafe_writel(cafe, 0x700a, GLOBAL_CTRL); | ||
617 | |||
618 | /* Set up DMA address */ | ||
619 | cafe_writel(cafe, cafe->dmaaddr & 0xffffffff, NAND_DMA_ADDR0); | ||
620 | if (sizeof(cafe->dmaaddr) > 4) | ||
621 | /* Shift in two parts to shut the compiler up */ | ||
622 | cafe_writel(cafe, (cafe->dmaaddr >> 16) >> 16, NAND_DMA_ADDR1); | ||
623 | else | ||
624 | cafe_writel(cafe, 0, NAND_DMA_ADDR1); | ||
625 | |||
626 | cafe_dev_dbg(&cafe->pdev->dev, "Set DMA address to %x (virt %p)\n", | ||
627 | cafe_readl(cafe, NAND_DMA_ADDR0), cafe->dmabuf); | ||
628 | |||
629 | /* Enable NAND IRQ in global IRQ mask register */ | ||
630 | cafe_writel(cafe, 0x80000007, GLOBAL_IRQ_MASK); | ||
631 | cafe_dev_dbg(&cafe->pdev->dev, "Control %x, IRQ mask %x\n", | ||
632 | cafe_readl(cafe, GLOBAL_CTRL), cafe_readl(cafe, GLOBAL_IRQ_MASK)); | ||
633 | #endif | ||
634 | #if 1 | ||
635 | mtd->writesize=2048; | ||
636 | mtd->oobsize = 0x40; | ||
637 | memset(cafe->dmabuf, 0x5a, 2112); | ||
638 | cafe->nand.cmdfunc(mtd, NAND_CMD_READID, 0, -1); | ||
639 | cafe->nand.read_byte(mtd); | ||
640 | cafe->nand.read_byte(mtd); | ||
641 | cafe->nand.read_byte(mtd); | ||
642 | cafe->nand.read_byte(mtd); | ||
643 | cafe->nand.read_byte(mtd); | ||
644 | #endif | ||
645 | #if 0 | ||
646 | cafe->nand.cmdfunc(mtd, NAND_CMD_READ0, 0, 0); | ||
647 | // nand_wait_ready(mtd); | ||
648 | cafe->nand.read_byte(mtd); | ||
649 | cafe->nand.read_byte(mtd); | ||
650 | cafe->nand.read_byte(mtd); | ||
651 | cafe->nand.read_byte(mtd); | ||
652 | #endif | ||
653 | #if 0 | ||
654 | writel(0x84600070, cafe->mmio); | ||
655 | udelay(10); | ||
656 | cafe_dev_dbg(&cafe->pdev->dev, "Status %x\n", cafe_readl(cafe, NAND_NONMEM)); | ||
657 | #endif | ||
658 | /* Scan to find existance of the device */ | ||
659 | if (nand_scan_ident(mtd, 1)) { | ||
660 | err = -ENXIO; | ||
661 | goto out_irq; | ||
662 | } | ||
663 | |||
664 | cafe->ctl2 = 1<<27; /* Reed-Solomon ECC */ | ||
665 | if (mtd->writesize == 2048) | ||
666 | cafe->ctl2 |= 1<<29; /* 2KiB page size */ | ||
667 | |||
668 | /* Set up ECC according to the type of chip we found */ | ||
669 | if (mtd->writesize == 2048) { | ||
670 | cafe->nand.ecc.layout = &cafe_oobinfo_2048; | ||
671 | cafe->nand.bbt_td = &cafe_bbt_main_descr_2048; | ||
672 | cafe->nand.bbt_md = &cafe_bbt_mirror_descr_2048; | ||
673 | } else if (mtd->writesize == 512) { | ||
674 | cafe->nand.ecc.layout = &cafe_oobinfo_512; | ||
675 | cafe->nand.bbt_td = &cafe_bbt_main_descr_512; | ||
676 | cafe->nand.bbt_md = &cafe_bbt_mirror_descr_512; | ||
677 | } else { | ||
678 | printk(KERN_WARNING "Unexpected NAND flash writesize %d. Aborting\n", | ||
679 | mtd->writesize); | ||
680 | goto out_irq; | ||
681 | } | ||
682 | cafe->nand.ecc.mode = NAND_ECC_HW_SYNDROME; | ||
683 | cafe->nand.ecc.size = mtd->writesize; | ||
684 | cafe->nand.ecc.bytes = 14; | ||
685 | cafe->nand.ecc.hwctl = (void *)cafe_nand_bug; | ||
686 | cafe->nand.ecc.calculate = (void *)cafe_nand_bug; | ||
687 | cafe->nand.ecc.correct = (void *)cafe_nand_bug; | ||
688 | cafe->nand.write_page = cafe_nand_write_page; | ||
689 | cafe->nand.ecc.write_page = cafe_nand_write_page_lowlevel; | ||
690 | cafe->nand.ecc.write_oob = cafe_nand_write_oob; | ||
691 | cafe->nand.ecc.read_page = cafe_nand_read_page; | ||
692 | cafe->nand.ecc.read_oob = cafe_nand_read_oob; | ||
693 | |||
694 | err = nand_scan_tail(mtd); | ||
695 | if (err) | ||
696 | goto out_irq; | ||
697 | |||
698 | pci_set_drvdata(pdev, mtd); | ||
699 | add_mtd_device(mtd); | ||
700 | goto out; | ||
701 | |||
702 | out_irq: | ||
703 | /* Disable NAND IRQ in global IRQ mask register */ | ||
704 | cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK); | ||
705 | free_irq(pdev->irq, mtd); | ||
706 | out_free_dma: | ||
707 | dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr); | ||
708 | out_ior: | ||
709 | pci_iounmap(pdev, cafe->mmio); | ||
710 | out_free_mtd: | ||
711 | kfree(mtd); | ||
712 | out: | ||
713 | return err; | ||
714 | } | ||
715 | |||
716 | static void __devexit cafe_nand_remove(struct pci_dev *pdev) | ||
717 | { | ||
718 | struct mtd_info *mtd = pci_get_drvdata(pdev); | ||
719 | struct cafe_priv *cafe = mtd->priv; | ||
720 | |||
721 | del_mtd_device(mtd); | ||
722 | /* Disable NAND IRQ in global IRQ mask register */ | ||
723 | cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK); | ||
724 | free_irq(pdev->irq, mtd); | ||
725 | nand_release(mtd); | ||
726 | pci_iounmap(pdev, cafe->mmio); | ||
727 | dma_free_coherent(&cafe->pdev->dev, 2112, cafe->dmabuf, cafe->dmaaddr); | ||
728 | kfree(mtd); | ||
729 | } | ||
730 | |||
731 | static struct pci_device_id cafe_nand_tbl[] = { | ||
732 | { 0x11ab, 0x4100, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_MEMORY_FLASH << 8, 0xFFFF0 } | ||
733 | }; | ||
734 | |||
735 | MODULE_DEVICE_TABLE(pci, cafe_nand_tbl); | ||
736 | |||
737 | static struct pci_driver cafe_nand_pci_driver = { | ||
738 | .name = "CAFÉ NAND", | ||
739 | .id_table = cafe_nand_tbl, | ||
740 | .probe = cafe_nand_probe, | ||
741 | .remove = __devexit_p(cafe_nand_remove), | ||
742 | #ifdef CONFIG_PMx | ||
743 | .suspend = cafe_nand_suspend, | ||
744 | .resume = cafe_nand_resume, | ||
745 | #endif | ||
746 | }; | ||
747 | |||
748 | static int cafe_nand_init(void) | ||
749 | { | ||
750 | return pci_register_driver(&cafe_nand_pci_driver); | ||
751 | } | ||
752 | |||
753 | static void cafe_nand_exit(void) | ||
754 | { | ||
755 | pci_unregister_driver(&cafe_nand_pci_driver); | ||
756 | } | ||
757 | module_init(cafe_nand_init); | ||
758 | module_exit(cafe_nand_exit); | ||
759 | |||
760 | MODULE_LICENSE("GPL"); | ||
761 | MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>"); | ||
762 | MODULE_DESCRIPTION("NAND flash driver for OLPC CAFE chip"); | ||
763 | |||
764 | /* Correct ECC for 2048 bytes of 0xff: | ||
765 | 41 a0 71 65 54 27 f3 93 ec a9 be ed 0b a1 */ | ||
766 | |||
767 | /* dwmw2's B-test board, in case of completely screwing it: | ||
768 | Bad eraseblock 2394 at 0x12b40000 | ||
769 | Bad eraseblock 2627 at 0x14860000 | ||
770 | Bad eraseblock 3349 at 0x1a2a0000 | ||
771 | */ | ||
diff --git a/drivers/mtd/nand/cafe_ecc.c b/drivers/mtd/nand/cafe_ecc.c new file mode 100644 index 000000000000..2d29265cc904 --- /dev/null +++ b/drivers/mtd/nand/cafe_ecc.c | |||
@@ -0,0 +1,1381 @@ | |||
1 | /* Error correction for CAFÉ NAND controller | ||
2 | * | ||
3 | * © 2006 Marvell, Inc. | ||
4 | * Author: Tom Chiou | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms of the GNU General Public License as published by the Free | ||
8 | * Software Foundation; either version 2 of the License, or (at your option) | ||
9 | * any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
14 | * more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along with | ||
17 | * this program; if not, write to the Free Software Foundation, Inc., 59 | ||
18 | * Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #include <linux/kernel.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/errno.h> | ||
24 | |||
25 | static unsigned short gf4096_mul(unsigned short, unsigned short); | ||
26 | static unsigned short gf64_mul(unsigned short, unsigned short); | ||
27 | static unsigned short gf4096_inv(unsigned short); | ||
28 | static unsigned short err_pos(unsigned short); | ||
29 | static void find_4bit_err_coefs(unsigned short, unsigned short, unsigned short, | ||
30 | unsigned short, unsigned short, unsigned short, | ||
31 | unsigned short, unsigned short, unsigned short *); | ||
32 | static void zero_4x5_col3(unsigned short[4][5]); | ||
33 | static void zero_4x5_col2(unsigned short[4][5]); | ||
34 | static void zero_4x5_col1(unsigned short[4][5]); | ||
35 | static void swap_4x5_rows(unsigned short[4][5], int, int, int); | ||
36 | static void swap_2x3_rows(unsigned short m[2][3]); | ||
37 | static void solve_4x5(unsigned short m[4][5], unsigned short *, int *); | ||
38 | static void sort_coefs(int *, unsigned short *, int); | ||
39 | static void find_4bit_err_pats(unsigned short, unsigned short, unsigned short, | ||
40 | unsigned short, unsigned short, unsigned short, | ||
41 | unsigned short, unsigned short, unsigned short *); | ||
42 | static void find_3bit_err_coefs(unsigned short, unsigned short, unsigned short, | ||
43 | unsigned short, unsigned short, unsigned short, | ||
44 | unsigned short *); | ||
45 | static void zero_3x4_col2(unsigned short[3][4]); | ||
46 | static void zero_3x4_col1(unsigned short[3][4]); | ||
47 | static void swap_3x4_rows(unsigned short[3][4], int, int, int); | ||
48 | static void solve_3x4(unsigned short[3][4], unsigned short *, int *); | ||
49 | static void find_3bit_err_pats(unsigned short, unsigned short, unsigned short, | ||
50 | unsigned short, unsigned short, unsigned short, | ||
51 | unsigned short *); | ||
52 | |||
53 | static void find_2bit_err_pats(unsigned short, unsigned short, unsigned short, | ||
54 | unsigned short, unsigned short *); | ||
55 | static void find_2x2_soln(unsigned short, unsigned short, unsigned short, | ||
56 | unsigned short, unsigned short, unsigned short, | ||
57 | unsigned short *); | ||
58 | static void solve_2x3(unsigned short[2][3], unsigned short *); | ||
59 | static int chk_no_err_only(unsigned short *, unsigned short *); | ||
60 | static int chk_1_err_only(unsigned short *, unsigned short *); | ||
61 | static int chk_2_err_only(unsigned short *, unsigned short *); | ||
62 | static int chk_3_err_only(unsigned short *, unsigned short *); | ||
63 | static int chk_4_err_only(unsigned short *, unsigned short *); | ||
64 | |||
65 | static unsigned short gf64_mul(unsigned short a, unsigned short b) | ||
66 | { | ||
67 | unsigned short tmp1, tmp2, tmp3, tmp4, tmp5; | ||
68 | unsigned short c_bit0, c_bit1, c_bit2, c_bit3, c_bit4, c_bit5, c; | ||
69 | |||
70 | tmp1 = ((a) ^ (a >> 5)); | ||
71 | tmp2 = ((a >> 4) ^ (a >> 5)); | ||
72 | tmp3 = ((a >> 3) ^ (a >> 4)); | ||
73 | tmp4 = ((a >> 2) ^ (a >> 3)); | ||
74 | tmp5 = ((a >> 1) ^ (a >> 2)); | ||
75 | |||
76 | c_bit0 = ((a & b) ^ ((a >> 5) & (b >> 1)) ^ ((a >> 4) & (b >> 2)) ^ | ||
77 | ((a >> 3) & (b >> 3)) ^ ((a >> 2) & (b >> 4)) ^ ((a >> 1) & (b >> 5))) & 0x1; | ||
78 | |||
79 | c_bit1 = (((a >> 1) & b) ^ (tmp1 & (b >> 1)) ^ (tmp2 & (b >> 2)) ^ | ||
80 | (tmp3 & (b >> 3)) ^ (tmp4 & (b >> 4)) ^ (tmp5 & (b >> 5))) & 0x1; | ||
81 | |||
82 | c_bit2 = (((a >> 2) & b) ^ ((a >> 1) & (b >> 1)) ^ (tmp1 & (b >> 2)) ^ | ||
83 | (tmp2 & (b >> 3)) ^ (tmp3 & (b >> 4)) ^ (tmp4 & (b >> 5))) & 0x1; | ||
84 | |||
85 | c_bit3 = (((a >> 3) & b) ^ ((a >> 2) & (b >> 1)) ^ ((a >> 1) & (b >> 2)) ^ | ||
86 | (tmp1 & (b >> 3)) ^ (tmp2 & (b >> 4)) ^ (tmp3 & (b >> 5))) & 0x1; | ||
87 | |||
88 | c_bit4 = (((a >> 4) & b) ^ ((a >> 3) & (b >> 1)) ^ ((a >> 2) & (b >> 2)) ^ | ||
89 | ((a >> 1) & (b >> 3)) ^ (tmp1 & (b >> 4)) ^ (tmp2 & (b >> 5))) & 0x1; | ||
90 | |||
91 | c_bit5 = (((a >> 5) & b) ^ ((a >> 4) & (b >> 1)) ^ ((a >> 3) & (b >> 2)) ^ | ||
92 | ((a >> 2) & (b >> 3)) ^ ((a >> 1) & (b >> 4)) ^ (tmp1 & (b >> 5))) & 0x1; | ||
93 | |||
94 | c = c_bit0 | (c_bit1 << 1) | (c_bit2 << 2) | (c_bit3 << 3) | (c_bit4 << 4) | (c_bit5 << 5); | ||
95 | |||
96 | return c; | ||
97 | } | ||
98 | |||
99 | static unsigned short gf4096_mul(unsigned short a, unsigned short b) | ||
100 | { | ||
101 | unsigned short ah, al, bh, bl, alxah, blxbh, ablh, albl, ahbh, ahbhB, c; | ||
102 | |||
103 | ah = (a >> 6) & 0x3f; | ||
104 | al = a & 0x3f; | ||
105 | bh = (b >> 6) & 0x3f; | ||
106 | bl = b & 0x3f; | ||
107 | alxah = al ^ ah; | ||
108 | blxbh = bl ^ bh; | ||
109 | |||
110 | ablh = gf64_mul(alxah, blxbh); | ||
111 | albl = gf64_mul(al, bl); | ||
112 | ahbh = gf64_mul(ah, bh); | ||
113 | |||
114 | ahbhB = ((ahbh & 0x1) << 5) | | ||
115 | ((ahbh & 0x20) >> 1) | | ||
116 | ((ahbh & 0x10) >> 1) | ((ahbh & 0x8) >> 1) | ((ahbh & 0x4) >> 1) | (((ahbh >> 1) ^ ahbh) & 0x1); | ||
117 | |||
118 | c = ((ablh ^ albl) << 6) | (ahbhB ^ albl); | ||
119 | return c; | ||
120 | } | ||
121 | |||
122 | static void find_2bit_err_pats(unsigned short s0, unsigned short s1, unsigned short r0, unsigned short r1, unsigned short *pats) | ||
123 | { | ||
124 | find_2x2_soln(0x1, 0x1, r0, r1, s0, s1, pats); | ||
125 | } | ||
126 | |||
127 | static void find_3bit_err_coefs(unsigned short s0, unsigned short s1, | ||
128 | unsigned short s2, unsigned short s3, unsigned short s4, unsigned short s5, unsigned short *coefs) | ||
129 | { | ||
130 | unsigned short m[3][4]; | ||
131 | int row_order[3]; | ||
132 | |||
133 | row_order[0] = 0; | ||
134 | row_order[1] = 1; | ||
135 | row_order[2] = 2; | ||
136 | m[0][0] = s2; | ||
137 | m[0][1] = s1; | ||
138 | m[0][2] = s0; | ||
139 | m[0][3] = s3; | ||
140 | m[1][0] = s3; | ||
141 | m[1][1] = s2; | ||
142 | m[1][2] = s1; | ||
143 | m[1][3] = s4; | ||
144 | m[2][0] = s4; | ||
145 | m[2][1] = s3; | ||
146 | m[2][2] = s2; | ||
147 | m[2][3] = s5; | ||
148 | |||
149 | if (m[0][2] != 0x0) { | ||
150 | zero_3x4_col2(m); | ||
151 | } else if (m[1][2] != 0x0) { | ||
152 | swap_3x4_rows(m, 0, 1, 4); | ||
153 | zero_3x4_col2(m); | ||
154 | } else if (m[2][2] != 0x0) { | ||
155 | swap_3x4_rows(m, 0, 2, 4); | ||
156 | zero_3x4_col2(m); | ||
157 | } else { | ||
158 | printk(KERN_ERR "Error: find_3bit_err_coefs, s0,s1,s2 all zeros!\n"); | ||
159 | } | ||
160 | |||
161 | if (m[1][1] != 0x0) { | ||
162 | zero_3x4_col1(m); | ||
163 | } else if (m[2][1] != 0x0) { | ||
164 | swap_3x4_rows(m, 1, 2, 4); | ||
165 | zero_3x4_col1(m); | ||
166 | } else { | ||
167 | printk(KERN_ERR "Error: find_3bit_err_coefs, cannot resolve col 1!\n"); | ||
168 | } | ||
169 | |||
170 | /* solve coefs */ | ||
171 | solve_3x4(m, coefs, row_order); | ||
172 | } | ||
173 | |||
174 | static void zero_3x4_col2(unsigned short m[3][4]) | ||
175 | { | ||
176 | unsigned short minv1, minv2; | ||
177 | |||
178 | minv1 = gf4096_mul(m[1][2], gf4096_inv(m[0][2])); | ||
179 | minv2 = gf4096_mul(m[2][2], gf4096_inv(m[0][2])); | ||
180 | m[1][0] = m[1][0] ^ gf4096_mul(m[0][0], minv1); | ||
181 | m[1][1] = m[1][1] ^ gf4096_mul(m[0][1], minv1); | ||
182 | m[1][3] = m[1][3] ^ gf4096_mul(m[0][3], minv1); | ||
183 | m[2][0] = m[2][0] ^ gf4096_mul(m[0][0], minv2); | ||
184 | m[2][1] = m[2][1] ^ gf4096_mul(m[0][1], minv2); | ||
185 | m[2][3] = m[2][3] ^ gf4096_mul(m[0][3], minv2); | ||
186 | } | ||
187 | |||
188 | static void zero_3x4_col1(unsigned short m[3][4]) | ||
189 | { | ||
190 | unsigned short minv; | ||
191 | minv = gf4096_mul(m[2][1], gf4096_inv(m[1][1])); | ||
192 | m[2][0] = m[2][0] ^ gf4096_mul(m[1][0], minv); | ||
193 | m[2][3] = m[2][3] ^ gf4096_mul(m[1][3], minv); | ||
194 | } | ||
195 | |||
196 | static void swap_3x4_rows(unsigned short m[3][4], int i, int j, int col_width) | ||
197 | { | ||
198 | unsigned short tmp0; | ||
199 | int cnt; | ||
200 | for (cnt = 0; cnt < col_width; cnt++) { | ||
201 | tmp0 = m[i][cnt]; | ||
202 | m[i][cnt] = m[j][cnt]; | ||
203 | m[j][cnt] = tmp0; | ||
204 | } | ||
205 | } | ||
206 | |||
207 | static void solve_3x4(unsigned short m[3][4], unsigned short *coefs, int *row_order) | ||
208 | { | ||
209 | unsigned short tmp[3]; | ||
210 | tmp[0] = gf4096_mul(m[2][3], gf4096_inv(m[2][0])); | ||
211 | tmp[1] = gf4096_mul((gf4096_mul(tmp[0], m[1][0]) ^ m[1][3]), gf4096_inv(m[1][1])); | ||
212 | tmp[2] = gf4096_mul((gf4096_mul(tmp[0], m[0][0]) ^ gf4096_mul(tmp[1], m[0][1]) ^ m[0][3]), gf4096_inv(m[0][2])); | ||
213 | sort_coefs(row_order, tmp, 3); | ||
214 | coefs[0] = tmp[0]; | ||
215 | coefs[1] = tmp[1]; | ||
216 | coefs[2] = tmp[2]; | ||
217 | } | ||
218 | |||
219 | static void find_3bit_err_pats(unsigned short s0, unsigned short s1, | ||
220 | unsigned short s2, unsigned short r0, | ||
221 | unsigned short r1, unsigned short r2, | ||
222 | unsigned short *pats) | ||
223 | { | ||
224 | find_2x2_soln(r0 ^ r2, r1 ^ r2, | ||
225 | gf4096_mul(r0, r0 ^ r2), gf4096_mul(r1, r1 ^ r2), | ||
226 | gf4096_mul(s0, r2) ^ s1, gf4096_mul(s1, r2) ^ s2, pats); | ||
227 | pats[2] = s0 ^ pats[0] ^ pats[1]; | ||
228 | } | ||
229 | |||
230 | static void find_4bit_err_coefs(unsigned short s0, unsigned short s1, | ||
231 | unsigned short s2, unsigned short s3, | ||
232 | unsigned short s4, unsigned short s5, | ||
233 | unsigned short s6, unsigned short s7, | ||
234 | unsigned short *coefs) | ||
235 | { | ||
236 | unsigned short m[4][5]; | ||
237 | int row_order[4]; | ||
238 | |||
239 | row_order[0] = 0; | ||
240 | row_order[1] = 1; | ||
241 | row_order[2] = 2; | ||
242 | row_order[3] = 3; | ||
243 | |||
244 | m[0][0] = s3; | ||
245 | m[0][1] = s2; | ||
246 | m[0][2] = s1; | ||
247 | m[0][3] = s0; | ||
248 | m[0][4] = s4; | ||
249 | m[1][0] = s4; | ||
250 | m[1][1] = s3; | ||
251 | m[1][2] = s2; | ||
252 | m[1][3] = s1; | ||
253 | m[1][4] = s5; | ||
254 | m[2][0] = s5; | ||
255 | m[2][1] = s4; | ||
256 | m[2][2] = s3; | ||
257 | m[2][3] = s2; | ||
258 | m[2][4] = s6; | ||
259 | m[3][0] = s6; | ||
260 | m[3][1] = s5; | ||
261 | m[3][2] = s4; | ||
262 | m[3][3] = s3; | ||
263 | m[3][4] = s7; | ||
264 | |||
265 | if (m[0][3] != 0x0) { | ||
266 | zero_4x5_col3(m); | ||
267 | } else if (m[1][3] != 0x0) { | ||
268 | swap_4x5_rows(m, 0, 1, 5); | ||
269 | zero_4x5_col3(m); | ||
270 | } else if (m[2][3] != 0x0) { | ||
271 | swap_4x5_rows(m, 0, 2, 5); | ||
272 | zero_4x5_col3(m); | ||
273 | } else if (m[3][3] != 0x0) { | ||
274 | swap_4x5_rows(m, 0, 3, 5); | ||
275 | zero_4x5_col3(m); | ||
276 | } else { | ||
277 | printk(KERN_ERR "Error: find_4bit_err_coefs, s0,s1,s2,s3 all zeros!\n"); | ||
278 | } | ||
279 | |||
280 | if (m[1][2] != 0x0) { | ||
281 | zero_4x5_col2(m); | ||
282 | } else if (m[2][2] != 0x0) { | ||
283 | swap_4x5_rows(m, 1, 2, 5); | ||
284 | zero_4x5_col2(m); | ||
285 | } else if (m[3][2] != 0x0) { | ||
286 | swap_4x5_rows(m, 1, 3, 5); | ||
287 | zero_4x5_col2(m); | ||
288 | } else { | ||
289 | printk(KERN_ERR "Error: find_4bit_err_coefs, cannot resolve col 2!\n"); | ||
290 | } | ||
291 | |||
292 | if (m[2][1] != 0x0) { | ||
293 | zero_4x5_col1(m); | ||
294 | } else if (m[3][1] != 0x0) { | ||
295 | swap_4x5_rows(m, 2, 3, 5); | ||
296 | zero_4x5_col1(m); | ||
297 | } else { | ||
298 | printk(KERN_ERR "Error: find_4bit_err_coefs, cannot resolve col 1!\n"); | ||
299 | } | ||
300 | |||
301 | solve_4x5(m, coefs, row_order); | ||
302 | } | ||
303 | |||
304 | static void zero_4x5_col3(unsigned short m[4][5]) | ||
305 | { | ||
306 | unsigned short minv1, minv2, minv3; | ||
307 | |||
308 | minv1 = gf4096_mul(m[1][3], gf4096_inv(m[0][3])); | ||
309 | minv2 = gf4096_mul(m[2][3], gf4096_inv(m[0][3])); | ||
310 | minv3 = gf4096_mul(m[3][3], gf4096_inv(m[0][3])); | ||
311 | |||
312 | m[1][0] = m[1][0] ^ gf4096_mul(m[0][0], minv1); | ||
313 | m[1][1] = m[1][1] ^ gf4096_mul(m[0][1], minv1); | ||
314 | m[1][2] = m[1][2] ^ gf4096_mul(m[0][2], minv1); | ||
315 | m[1][4] = m[1][4] ^ gf4096_mul(m[0][4], minv1); | ||
316 | m[2][0] = m[2][0] ^ gf4096_mul(m[0][0], minv2); | ||
317 | m[2][1] = m[2][1] ^ gf4096_mul(m[0][1], minv2); | ||
318 | m[2][2] = m[2][2] ^ gf4096_mul(m[0][2], minv2); | ||
319 | m[2][4] = m[2][4] ^ gf4096_mul(m[0][4], minv2); | ||
320 | m[3][0] = m[3][0] ^ gf4096_mul(m[0][0], minv3); | ||
321 | m[3][1] = m[3][1] ^ gf4096_mul(m[0][1], minv3); | ||
322 | m[3][2] = m[3][2] ^ gf4096_mul(m[0][2], minv3); | ||
323 | m[3][4] = m[3][4] ^ gf4096_mul(m[0][4], minv3); | ||
324 | } | ||
325 | |||
326 | static void zero_4x5_col2(unsigned short m[4][5]) | ||
327 | { | ||
328 | unsigned short minv2, minv3; | ||
329 | |||
330 | minv2 = gf4096_mul(m[2][2], gf4096_inv(m[1][2])); | ||
331 | minv3 = gf4096_mul(m[3][2], gf4096_inv(m[1][2])); | ||
332 | |||
333 | m[2][0] = m[2][0] ^ gf4096_mul(m[1][0], minv2); | ||
334 | m[2][1] = m[2][1] ^ gf4096_mul(m[1][1], minv2); | ||
335 | m[2][4] = m[2][4] ^ gf4096_mul(m[1][4], minv2); | ||
336 | m[3][0] = m[3][0] ^ gf4096_mul(m[1][0], minv3); | ||
337 | m[3][1] = m[3][1] ^ gf4096_mul(m[1][1], minv3); | ||
338 | m[3][4] = m[3][4] ^ gf4096_mul(m[1][4], minv3); | ||
339 | } | ||
340 | |||
341 | static void zero_4x5_col1(unsigned short m[4][5]) | ||
342 | { | ||
343 | unsigned short minv; | ||
344 | |||
345 | minv = gf4096_mul(m[3][1], gf4096_inv(m[2][1])); | ||
346 | |||
347 | m[3][0] = m[3][0] ^ gf4096_mul(m[2][0], minv); | ||
348 | m[3][4] = m[3][4] ^ gf4096_mul(m[2][4], minv); | ||
349 | } | ||
350 | |||
351 | static void swap_4x5_rows(unsigned short m[4][5], int i, int j, int col_width) | ||
352 | { | ||
353 | unsigned short tmp0; | ||
354 | int cnt; | ||
355 | |||
356 | for (cnt = 0; cnt < col_width; cnt++) { | ||
357 | tmp0 = m[i][cnt]; | ||
358 | m[i][cnt] = m[j][cnt]; | ||
359 | m[j][cnt] = tmp0; | ||
360 | } | ||
361 | } | ||
362 | |||
363 | static void solve_4x5(unsigned short m[4][5], unsigned short *coefs, int *row_order) | ||
364 | { | ||
365 | unsigned short tmp[4]; | ||
366 | |||
367 | tmp[0] = gf4096_mul(m[3][4], gf4096_inv(m[3][0])); | ||
368 | tmp[1] = gf4096_mul((gf4096_mul(tmp[0], m[2][0]) ^ m[2][4]), gf4096_inv(m[2][1])); | ||
369 | tmp[2] = gf4096_mul((gf4096_mul(tmp[0], m[1][0]) ^ gf4096_mul(tmp[1], m[1][1]) ^ m[1][4]), gf4096_inv(m[1][2])); | ||
370 | tmp[3] = gf4096_mul((gf4096_mul(tmp[0], m[0][0]) ^ | ||
371 | gf4096_mul(tmp[1], m[0][1]) ^ gf4096_mul(tmp[2], m[0][2]) ^ m[0][4]), gf4096_inv(m[0][3])); | ||
372 | sort_coefs(row_order, tmp, 4); | ||
373 | coefs[0] = tmp[0]; | ||
374 | coefs[1] = tmp[1]; | ||
375 | coefs[2] = tmp[2]; | ||
376 | coefs[3] = tmp[3]; | ||
377 | } | ||
378 | |||
379 | static void sort_coefs(int *order, unsigned short *soln, int len) | ||
380 | { | ||
381 | int cnt, start_cnt, least_ord, least_cnt; | ||
382 | unsigned short tmp0; | ||
383 | for (start_cnt = 0; start_cnt < len; start_cnt++) { | ||
384 | for (cnt = start_cnt; cnt < len; cnt++) { | ||
385 | if (cnt == start_cnt) { | ||
386 | least_ord = order[cnt]; | ||
387 | least_cnt = start_cnt; | ||
388 | } else { | ||
389 | if (least_ord > order[cnt]) { | ||
390 | least_ord = order[cnt]; | ||
391 | least_cnt = cnt; | ||
392 | } | ||
393 | } | ||
394 | } | ||
395 | if (least_cnt != start_cnt) { | ||
396 | tmp0 = order[least_cnt]; | ||
397 | order[least_cnt] = order[start_cnt]; | ||
398 | order[start_cnt] = tmp0; | ||
399 | tmp0 = soln[least_cnt]; | ||
400 | soln[least_cnt] = soln[start_cnt]; | ||
401 | soln[start_cnt] = tmp0; | ||
402 | } | ||
403 | } | ||
404 | } | ||
405 | |||
406 | static void find_4bit_err_pats(unsigned short s0, unsigned short s1, | ||
407 | unsigned short s2, unsigned short s3, | ||
408 | unsigned short z1, unsigned short z2, | ||
409 | unsigned short z3, unsigned short z4, | ||
410 | unsigned short *pats) | ||
411 | { | ||
412 | unsigned short z4_z1, z3z4_z3z3, z4_z2, s0z4_s1, z1z4_z1z1, | ||
413 | z4_z3, z2z4_z2z2, s1z4_s2, z3z3z4_z3z3z3, z1z1z4_z1z1z1, z2z2z4_z2z2z2, s2z4_s3; | ||
414 | unsigned short tmp0, tmp1, tmp2, tmp3; | ||
415 | |||
416 | z4_z1 = z4 ^ z1; | ||
417 | z3z4_z3z3 = gf4096_mul(z3, z4) ^ gf4096_mul(z3, z3); | ||
418 | z4_z2 = z4 ^ z2; | ||
419 | s0z4_s1 = gf4096_mul(s0, z4) ^ s1; | ||
420 | z1z4_z1z1 = gf4096_mul(z1, z4) ^ gf4096_mul(z1, z1); | ||
421 | z4_z3 = z4 ^ z3; | ||
422 | z2z4_z2z2 = gf4096_mul(z2, z4) ^ gf4096_mul(z2, z2); | ||
423 | s1z4_s2 = gf4096_mul(s1, z4) ^ s2; | ||
424 | z3z3z4_z3z3z3 = gf4096_mul(gf4096_mul(z3, z3), z4) ^ gf4096_mul(gf4096_mul(z3, z3), z3); | ||
425 | z1z1z4_z1z1z1 = gf4096_mul(gf4096_mul(z1, z1), z4) ^ gf4096_mul(gf4096_mul(z1, z1), z1); | ||
426 | z2z2z4_z2z2z2 = gf4096_mul(gf4096_mul(z2, z2), z4) ^ gf4096_mul(gf4096_mul(z2, z2), z2); | ||
427 | s2z4_s3 = gf4096_mul(s2, z4) ^ s3; | ||
428 | |||
429 | //find err pat 0,1 | ||
430 | find_2x2_soln(gf4096_mul(z4_z1, z3z4_z3z3) ^ | ||
431 | gf4096_mul(z1z4_z1z1, z4_z3), gf4096_mul(z4_z2, | ||
432 | z3z4_z3z3) ^ | ||
433 | gf4096_mul(z2z4_z2z2, z4_z3), gf4096_mul(z1z4_z1z1, | ||
434 | z3z3z4_z3z3z3) ^ | ||
435 | gf4096_mul(z1z1z4_z1z1z1, z3z4_z3z3), | ||
436 | gf4096_mul(z2z4_z2z2, | ||
437 | z3z3z4_z3z3z3) ^ gf4096_mul(z2z2z4_z2z2z2, | ||
438 | z3z4_z3z3), | ||
439 | gf4096_mul(s0z4_s1, z3z4_z3z3) ^ gf4096_mul(s1z4_s2, | ||
440 | z4_z3), | ||
441 | gf4096_mul(s1z4_s2, z3z3z4_z3z3z3) ^ gf4096_mul(s2z4_s3, z3z4_z3z3), pats); | ||
442 | tmp0 = pats[0]; | ||
443 | tmp1 = pats[1]; | ||
444 | tmp2 = pats[0] ^ pats[1] ^ s0; | ||
445 | tmp3 = gf4096_mul(pats[0], z1) ^ gf4096_mul(pats[1], z2) ^ s1; | ||
446 | |||
447 | //find err pat 2,3 | ||
448 | find_2x2_soln(0x1, 0x1, z3, z4, tmp2, tmp3, pats); | ||
449 | pats[2] = pats[0]; | ||
450 | pats[3] = pats[1]; | ||
451 | pats[0] = tmp0; | ||
452 | pats[1] = tmp1; | ||
453 | } | ||
454 | |||
455 | static void find_2x2_soln(unsigned short c00, unsigned short c01, | ||
456 | unsigned short c10, unsigned short c11, | ||
457 | unsigned short lval0, unsigned short lval1, | ||
458 | unsigned short *soln) | ||
459 | { | ||
460 | unsigned short m[2][3]; | ||
461 | m[0][0] = c00; | ||
462 | m[0][1] = c01; | ||
463 | m[0][2] = lval0; | ||
464 | m[1][0] = c10; | ||
465 | m[1][1] = c11; | ||
466 | m[1][2] = lval1; | ||
467 | |||
468 | if (m[0][1] != 0x0) { | ||
469 | /* */ | ||
470 | } else if (m[1][1] != 0x0) { | ||
471 | swap_2x3_rows(m); | ||
472 | } else { | ||
473 | printk(KERN_ERR "Warning: find_2bit_err_coefs, s0,s1 all zeros!\n"); | ||
474 | } | ||
475 | |||
476 | solve_2x3(m, soln); | ||
477 | } | ||
478 | |||
479 | static void swap_2x3_rows(unsigned short m[2][3]) | ||
480 | { | ||
481 | unsigned short tmp0; | ||
482 | int cnt; | ||
483 | |||
484 | for (cnt = 0; cnt < 3; cnt++) { | ||
485 | tmp0 = m[0][cnt]; | ||
486 | m[0][cnt] = m[1][cnt]; | ||
487 | m[1][cnt] = tmp0; | ||
488 | } | ||
489 | } | ||
490 | |||
491 | static void solve_2x3(unsigned short m[2][3], unsigned short *coefs) | ||
492 | { | ||
493 | unsigned short minv; | ||
494 | |||
495 | minv = gf4096_mul(m[1][1], gf4096_inv(m[0][1])); | ||
496 | m[1][0] = m[1][0] ^ gf4096_mul(m[0][0], minv); | ||
497 | m[1][2] = m[1][2] ^ gf4096_mul(m[0][2], minv); | ||
498 | coefs[0] = gf4096_mul(m[1][2], gf4096_inv(m[1][0])); | ||
499 | coefs[1] = gf4096_mul((gf4096_mul(coefs[0], m[0][0]) ^ m[0][2]), gf4096_inv(m[0][1])); | ||
500 | } | ||
501 | |||
502 | static unsigned char gf64_inv[64] = { | ||
503 | 0, 1, 33, 62, 49, 43, 31, 44, 57, 37, 52, 28, 46, 40, 22, 25, | ||
504 | 61, 54, 51, 39, 26, 35, 14, 24, 23, 15, 20, 34, 11, 53, 45, 6, | ||
505 | 63, 2, 27, 21, 56, 9, 50, 19, 13, 47, 48, 5, 7, 30, 12, 41, | ||
506 | 42, 4, 38, 18, 10, 29, 17, 60, 36, 8, 59, 58, 55, 16, 3, 32 | ||
507 | }; | ||
508 | |||
509 | static unsigned short gf4096_inv(unsigned short din) | ||
510 | { | ||
511 | unsigned short alahxal, ah2B, deno, inv, bl, bh; | ||
512 | unsigned short ah, al, ahxal; | ||
513 | unsigned short dout; | ||
514 | |||
515 | ah = (din >> 6) & 0x3f; | ||
516 | al = din & 0x3f; | ||
517 | ahxal = ah ^ al; | ||
518 | ah2B = (((ah ^ (ah >> 3)) & 0x1) << 5) | | ||
519 | ((ah >> 1) & 0x10) | | ||
520 | ((((ah >> 5) ^ (ah >> 2)) & 0x1) << 3) | | ||
521 | ((ah >> 2) & 0x4) | ((((ah >> 4) ^ (ah >> 1)) & 0x1) << 1) | (ah & 0x1); | ||
522 | alahxal = gf64_mul(ahxal, al); | ||
523 | deno = alahxal ^ ah2B; | ||
524 | inv = gf64_inv[deno]; | ||
525 | bl = gf64_mul(inv, ahxal); | ||
526 | bh = gf64_mul(inv, ah); | ||
527 | dout = ((bh & 0x3f) << 6) | (bl & 0x3f); | ||
528 | return (((bh & 0x3f) << 6) | (bl & 0x3f)); | ||
529 | } | ||
530 | |||
531 | static unsigned short err_pos_lut[4096] = { | ||
532 | 0xfff, 0x000, 0x451, 0xfff, 0xfff, 0x3cf, 0xfff, 0x041, | ||
533 | 0xfff, 0xfff, 0xfff, 0xfff, 0x28a, 0xfff, 0x492, 0xfff, | ||
534 | 0x145, 0xfff, 0xfff, 0x514, 0xfff, 0x082, 0xfff, 0xfff, | ||
535 | 0xfff, 0x249, 0x38e, 0x410, 0xfff, 0x104, 0x208, 0x1c7, | ||
536 | 0xfff, 0xfff, 0xfff, 0xfff, 0x2cb, 0xfff, 0xfff, 0xfff, | ||
537 | 0x0c3, 0x34d, 0x4d3, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
538 | 0xfff, 0xfff, 0xfff, 0x186, 0xfff, 0xfff, 0xfff, 0xfff, | ||
539 | 0xfff, 0x30c, 0x555, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
540 | 0xfff, 0xfff, 0xfff, 0x166, 0xfff, 0xfff, 0xfff, 0xfff, | ||
541 | 0x385, 0x14e, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4e1, | ||
542 | 0xfff, 0xfff, 0xfff, 0xfff, 0x538, 0xfff, 0x16d, 0xfff, | ||
543 | 0xfff, 0xfff, 0x45b, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
544 | 0xfff, 0xfff, 0xfff, 0x29c, 0x2cc, 0x30b, 0x2b3, 0xfff, | ||
545 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x0b3, 0xfff, 0x2f7, | ||
546 | 0xfff, 0x32b, 0xfff, 0xfff, 0xfff, 0xfff, 0x0a7, 0xfff, | ||
547 | 0xfff, 0x2da, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
548 | 0xfff, 0x07e, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
549 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x11c, 0xfff, 0xfff, | ||
550 | 0xfff, 0xfff, 0xfff, 0x22f, 0xfff, 0x1f4, 0xfff, 0xfff, | ||
551 | 0x2b0, 0x504, 0xfff, 0x114, 0xfff, 0xfff, 0xfff, 0x21d, | ||
552 | 0xfff, 0xfff, 0xfff, 0xfff, 0x00d, 0x3c4, 0x340, 0x10f, | ||
553 | 0xfff, 0xfff, 0x266, 0x02e, 0xfff, 0xfff, 0xfff, 0x4f8, | ||
554 | 0x337, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
555 | 0xfff, 0xfff, 0xfff, 0x07b, 0x168, 0xfff, 0xfff, 0x0fe, | ||
556 | 0xfff, 0xfff, 0x51a, 0xfff, 0x458, 0xfff, 0x36d, 0xfff, | ||
557 | 0xfff, 0xfff, 0xfff, 0x073, 0x37d, 0x415, 0x550, 0xfff, | ||
558 | 0xfff, 0xfff, 0x23b, 0x4b4, 0xfff, 0xfff, 0xfff, 0x1a1, | ||
559 | 0xfff, 0xfff, 0x3aa, 0xfff, 0x117, 0x04d, 0x341, 0xfff, | ||
560 | 0xfff, 0xfff, 0xfff, 0x518, 0x03e, 0x0f2, 0xfff, 0xfff, | ||
561 | 0xfff, 0xfff, 0xfff, 0x363, 0xfff, 0x0b9, 0xfff, 0xfff, | ||
562 | 0x241, 0xfff, 0xfff, 0x049, 0xfff, 0xfff, 0xfff, 0xfff, | ||
563 | 0x15f, 0x52d, 0xfff, 0xfff, 0xfff, 0x29e, 0xfff, 0xfff, | ||
564 | 0xfff, 0xfff, 0x4cf, 0x0fc, 0xfff, 0x36f, 0x3d3, 0xfff, | ||
565 | 0x228, 0xfff, 0xfff, 0x45e, 0xfff, 0xfff, 0xfff, 0xfff, | ||
566 | 0x238, 0xfff, 0xfff, 0xfff, 0xfff, 0x47f, 0xfff, 0xfff, | ||
567 | 0x43a, 0x265, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x3e8, | ||
568 | 0xfff, 0xfff, 0x01a, 0xfff, 0xfff, 0xfff, 0xfff, 0x21e, | ||
569 | 0x1fc, 0x40b, 0xfff, 0xfff, 0xfff, 0x2d0, 0x159, 0xfff, | ||
570 | 0xfff, 0x313, 0xfff, 0xfff, 0x05c, 0x4cc, 0xfff, 0xfff, | ||
571 | 0x0f6, 0x3d5, 0xfff, 0xfff, 0xfff, 0x54f, 0xfff, 0xfff, | ||
572 | 0xfff, 0x172, 0x1e4, 0x07c, 0xfff, 0xfff, 0xfff, 0xfff, | ||
573 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x53c, 0x1ad, 0x535, | ||
574 | 0x19b, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
575 | 0xfff, 0xfff, 0x092, 0xfff, 0x2be, 0xfff, 0xfff, 0x482, | ||
576 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x0e6, 0xfff, 0xfff, | ||
577 | 0xfff, 0xfff, 0xfff, 0x476, 0xfff, 0x51d, 0xfff, 0xfff, | ||
578 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
579 | 0xfff, 0xfff, 0x342, 0x2b5, 0x22e, 0x09a, 0xfff, 0x08d, | ||
580 | 0x44f, 0x3ed, 0xfff, 0xfff, 0xfff, 0xfff, 0x3d1, 0xfff, | ||
581 | 0xfff, 0x543, 0xfff, 0x48f, 0xfff, 0x3d2, 0xfff, 0x0d5, | ||
582 | 0x113, 0x0ec, 0x427, 0xfff, 0xfff, 0xfff, 0x4c4, 0xfff, | ||
583 | 0xfff, 0x50a, 0xfff, 0x144, 0xfff, 0x105, 0x39f, 0x294, | ||
584 | 0x164, 0xfff, 0x31a, 0xfff, 0xfff, 0x49a, 0xfff, 0x130, | ||
585 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
586 | 0x1be, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
587 | 0xfff, 0xfff, 0x49e, 0x371, 0xfff, 0xfff, 0xfff, 0xfff, | ||
588 | 0xfff, 0xfff, 0xfff, 0xfff, 0x0e8, 0x49c, 0x0f4, 0xfff, | ||
589 | 0x338, 0x1a7, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
590 | 0xfff, 0x36c, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
591 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
592 | 0xfff, 0x1ae, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
593 | 0xfff, 0x31b, 0xfff, 0xfff, 0x2dd, 0x522, 0xfff, 0xfff, | ||
594 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x2f4, | ||
595 | 0x3c6, 0x30d, 0xfff, 0xfff, 0xfff, 0xfff, 0x34c, 0x18f, | ||
596 | 0x30a, 0xfff, 0x01f, 0x079, 0xfff, 0xfff, 0x54d, 0x46b, | ||
597 | 0x28c, 0x37f, 0xfff, 0xfff, 0xfff, 0xfff, 0x355, 0xfff, | ||
598 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x14f, 0xfff, 0xfff, | ||
599 | 0xfff, 0xfff, 0xfff, 0x359, 0x3fe, 0x3c5, 0xfff, 0xfff, | ||
600 | 0xfff, 0xfff, 0x423, 0xfff, 0xfff, 0x34a, 0x22c, 0xfff, | ||
601 | 0x25a, 0xfff, 0xfff, 0x4ad, 0xfff, 0x28d, 0xfff, 0xfff, | ||
602 | 0xfff, 0xfff, 0xfff, 0x547, 0xfff, 0xfff, 0xfff, 0xfff, | ||
603 | 0x2e2, 0xfff, 0xfff, 0x1d5, 0xfff, 0x2a8, 0xfff, 0xfff, | ||
604 | 0x03f, 0xfff, 0xfff, 0xfff, 0xfff, 0x3eb, 0x0fa, 0xfff, | ||
605 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x55b, 0xfff, | ||
606 | 0x08e, 0xfff, 0x3ae, 0xfff, 0x3a4, 0xfff, 0x282, 0x158, | ||
607 | 0xfff, 0x382, 0xfff, 0xfff, 0x499, 0xfff, 0xfff, 0x08a, | ||
608 | 0xfff, 0xfff, 0xfff, 0x456, 0x3be, 0xfff, 0x1e2, 0xfff, | ||
609 | 0xfff, 0xfff, 0xfff, 0xfff, 0x559, 0xfff, 0x1a0, 0xfff, | ||
610 | 0xfff, 0x0b4, 0xfff, 0xfff, 0xfff, 0x2df, 0xfff, 0xfff, | ||
611 | 0xfff, 0x07f, 0x4f5, 0xfff, 0xfff, 0x27c, 0x133, 0x017, | ||
612 | 0xfff, 0x3fd, 0xfff, 0xfff, 0xfff, 0x44d, 0x4cd, 0x17a, | ||
613 | 0x0d7, 0x537, 0xfff, 0xfff, 0x353, 0xfff, 0xfff, 0x351, | ||
614 | 0x366, 0xfff, 0x44a, 0xfff, 0x1a6, 0xfff, 0xfff, 0xfff, | ||
615 | 0x291, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x1e3, | ||
616 | 0xfff, 0xfff, 0xfff, 0xfff, 0x389, 0xfff, 0x07a, 0xfff, | ||
617 | 0x1b6, 0x2ed, 0xfff, 0xfff, 0xfff, 0xfff, 0x24e, 0x074, | ||
618 | 0xfff, 0xfff, 0x3dc, 0xfff, 0x4e3, 0xfff, 0xfff, 0xfff, | ||
619 | 0xfff, 0x4eb, 0xfff, 0xfff, 0x3b8, 0x4de, 0xfff, 0x19c, | ||
620 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x262, | ||
621 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x076, 0x4e8, 0x3da, | ||
622 | 0xfff, 0x531, 0xfff, 0xfff, 0x14a, 0xfff, 0x0a2, 0x433, | ||
623 | 0x3df, 0x1e9, 0xfff, 0xfff, 0xfff, 0xfff, 0x3e7, 0x285, | ||
624 | 0x2d8, 0xfff, 0xfff, 0xfff, 0x349, 0x18d, 0x098, 0xfff, | ||
625 | 0x0df, 0x4bf, 0xfff, 0xfff, 0x0b2, 0xfff, 0x346, 0x24d, | ||
626 | 0xfff, 0xfff, 0xfff, 0x24f, 0x4fa, 0x2f9, 0xfff, 0xfff, | ||
627 | 0x3c9, 0xfff, 0x2b4, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
628 | 0xfff, 0x056, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
629 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
630 | 0xfff, 0x179, 0xfff, 0x0e9, 0x3f0, 0x33d, 0xfff, 0xfff, | ||
631 | 0xfff, 0xfff, 0xfff, 0x1fd, 0xfff, 0xfff, 0x526, 0xfff, | ||
632 | 0xfff, 0xfff, 0x53d, 0xfff, 0xfff, 0xfff, 0x170, 0x331, | ||
633 | 0xfff, 0x068, 0xfff, 0xfff, 0xfff, 0x3f7, 0xfff, 0x3d8, | ||
634 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
635 | 0xfff, 0x09f, 0x556, 0xfff, 0xfff, 0x02d, 0xfff, 0xfff, | ||
636 | 0x553, 0xfff, 0xfff, 0xfff, 0x1f0, 0xfff, 0xfff, 0x4d6, | ||
637 | 0x41e, 0xfff, 0xfff, 0xfff, 0xfff, 0x4d5, 0xfff, 0xfff, | ||
638 | 0xfff, 0xfff, 0xfff, 0x248, 0xfff, 0xfff, 0xfff, 0x0a3, | ||
639 | 0xfff, 0x217, 0xfff, 0xfff, 0xfff, 0x4f1, 0x209, 0xfff, | ||
640 | 0xfff, 0x475, 0x234, 0x52b, 0x398, 0xfff, 0x08b, 0xfff, | ||
641 | 0xfff, 0xfff, 0xfff, 0x2c2, 0xfff, 0xfff, 0xfff, 0xfff, | ||
642 | 0xfff, 0xfff, 0x268, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
643 | 0xfff, 0x4a3, 0xfff, 0x0aa, 0xfff, 0x1d9, 0xfff, 0xfff, | ||
644 | 0xfff, 0xfff, 0x155, 0xfff, 0xfff, 0xfff, 0xfff, 0x0bf, | ||
645 | 0x539, 0xfff, 0xfff, 0x2f1, 0x545, 0xfff, 0xfff, 0xfff, | ||
646 | 0xfff, 0xfff, 0xfff, 0x2a7, 0x06f, 0xfff, 0x378, 0xfff, | ||
647 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x25e, 0xfff, | ||
648 | 0xfff, 0xfff, 0xfff, 0x15d, 0x02a, 0xfff, 0xfff, 0x0bc, | ||
649 | 0x235, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
650 | 0x150, 0xfff, 0x1a9, 0xfff, 0xfff, 0xfff, 0xfff, 0x381, | ||
651 | 0xfff, 0x04e, 0x270, 0x13f, 0xfff, 0xfff, 0x405, 0xfff, | ||
652 | 0x3cd, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
653 | 0xfff, 0x2ef, 0xfff, 0x06a, 0xfff, 0xfff, 0xfff, 0x34f, | ||
654 | 0x212, 0xfff, 0xfff, 0x0e2, 0xfff, 0x083, 0x298, 0xfff, | ||
655 | 0xfff, 0xfff, 0x0c2, 0xfff, 0xfff, 0x52e, 0xfff, 0x488, | ||
656 | 0xfff, 0xfff, 0xfff, 0x36b, 0xfff, 0xfff, 0xfff, 0x442, | ||
657 | 0x091, 0xfff, 0x41c, 0xfff, 0xfff, 0x3a5, 0xfff, 0x4e6, | ||
658 | 0xfff, 0xfff, 0x40d, 0x31d, 0xfff, 0xfff, 0xfff, 0x4c1, | ||
659 | 0x053, 0xfff, 0x418, 0x13c, 0xfff, 0x350, 0xfff, 0x0ae, | ||
660 | 0xfff, 0xfff, 0x41f, 0xfff, 0x470, 0xfff, 0x4ca, 0xfff, | ||
661 | 0xfff, 0xfff, 0x02b, 0x450, 0xfff, 0x1f8, 0xfff, 0xfff, | ||
662 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x293, 0xfff, | ||
663 | 0xfff, 0xfff, 0xfff, 0x411, 0xfff, 0xfff, 0xfff, 0xfff, | ||
664 | 0xfff, 0xfff, 0xfff, 0xfff, 0x0b8, 0xfff, 0xfff, 0xfff, | ||
665 | 0x3e1, 0xfff, 0xfff, 0xfff, 0xfff, 0x43c, 0xfff, 0x2b2, | ||
666 | 0x2ab, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x1ec, | ||
667 | 0xfff, 0xfff, 0xfff, 0x3f8, 0x034, 0xfff, 0xfff, 0xfff, | ||
668 | 0xfff, 0xfff, 0xfff, 0x11a, 0xfff, 0x541, 0x45c, 0x134, | ||
669 | 0x1cc, 0xfff, 0xfff, 0xfff, 0x469, 0xfff, 0xfff, 0x44b, | ||
670 | 0x161, 0xfff, 0xfff, 0xfff, 0x055, 0xfff, 0xfff, 0xfff, | ||
671 | 0xfff, 0x307, 0xfff, 0xfff, 0xfff, 0xfff, 0x2d1, 0xfff, | ||
672 | 0xfff, 0xfff, 0x124, 0x37b, 0x26b, 0x336, 0xfff, 0xfff, | ||
673 | 0x2e4, 0x3cb, 0xfff, 0xfff, 0x0f8, 0x3c8, 0xfff, 0xfff, | ||
674 | 0xfff, 0x461, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4b5, | ||
675 | 0x2cf, 0xfff, 0xfff, 0xfff, 0x20f, 0xfff, 0x35a, 0xfff, | ||
676 | 0x490, 0xfff, 0x185, 0xfff, 0xfff, 0xfff, 0xfff, 0x42e, | ||
677 | 0xfff, 0xfff, 0xfff, 0xfff, 0x54b, 0xfff, 0xfff, 0xfff, | ||
678 | 0x146, 0xfff, 0x412, 0xfff, 0xfff, 0xfff, 0x1ff, 0xfff, | ||
679 | 0xfff, 0x3e0, 0xfff, 0xfff, 0xfff, 0xfff, 0x2d5, 0xfff, | ||
680 | 0x4df, 0x505, 0xfff, 0x413, 0xfff, 0x1a5, 0xfff, 0x3b2, | ||
681 | 0xfff, 0xfff, 0xfff, 0x35b, 0xfff, 0x116, 0xfff, 0xfff, | ||
682 | 0x171, 0x4d0, 0xfff, 0x154, 0x12d, 0xfff, 0xfff, 0xfff, | ||
683 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x468, 0x4db, 0xfff, | ||
684 | 0xfff, 0x1df, 0xfff, 0xfff, 0xfff, 0xfff, 0x05a, 0xfff, | ||
685 | 0x0f1, 0x403, 0xfff, 0x22b, 0x2e0, 0xfff, 0xfff, 0xfff, | ||
686 | 0x2b7, 0x373, 0xfff, 0xfff, 0xfff, 0xfff, 0x13e, 0xfff, | ||
687 | 0xfff, 0xfff, 0x0d0, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
688 | 0x329, 0x1d2, 0x3fa, 0x047, 0xfff, 0x2f2, 0xfff, 0xfff, | ||
689 | 0x141, 0x0ac, 0x1d7, 0xfff, 0x07d, 0xfff, 0xfff, 0xfff, | ||
690 | 0x1c1, 0xfff, 0x487, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
691 | 0xfff, 0xfff, 0xfff, 0x045, 0xfff, 0xfff, 0xfff, 0xfff, | ||
692 | 0x288, 0x0cd, 0xfff, 0xfff, 0xfff, 0xfff, 0x226, 0x1d8, | ||
693 | 0xfff, 0x153, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4cb, | ||
694 | 0x528, 0xfff, 0xfff, 0xfff, 0x20a, 0x343, 0x3a1, 0xfff, | ||
695 | 0xfff, 0xfff, 0x2d7, 0x2d3, 0x1aa, 0x4c5, 0xfff, 0xfff, | ||
696 | 0xfff, 0x42b, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
697 | 0xfff, 0xfff, 0xfff, 0xfff, 0x3e9, 0xfff, 0x20b, 0x260, | ||
698 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x37c, 0x2fd, | ||
699 | 0xfff, 0xfff, 0x2c8, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
700 | 0xfff, 0x31e, 0xfff, 0x335, 0xfff, 0xfff, 0xfff, 0xfff, | ||
701 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
702 | 0xfff, 0xfff, 0x135, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
703 | 0xfff, 0xfff, 0x35c, 0x4dd, 0x129, 0xfff, 0xfff, 0xfff, | ||
704 | 0xfff, 0xfff, 0x1ef, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
705 | 0xfff, 0x34e, 0xfff, 0xfff, 0xfff, 0xfff, 0x407, 0xfff, | ||
706 | 0xfff, 0xfff, 0xfff, 0xfff, 0x3ad, 0xfff, 0xfff, 0xfff, | ||
707 | 0x379, 0xfff, 0xfff, 0x1d0, 0x38d, 0xfff, 0xfff, 0x1e8, | ||
708 | 0x184, 0x3c1, 0x1c4, 0xfff, 0x1f9, 0xfff, 0xfff, 0x424, | ||
709 | 0xfff, 0xfff, 0xfff, 0xfff, 0x1d3, 0x0d4, 0xfff, 0x4e9, | ||
710 | 0xfff, 0xfff, 0xfff, 0x530, 0x107, 0xfff, 0x106, 0x04f, | ||
711 | 0xfff, 0xfff, 0x4c7, 0x503, 0xfff, 0xfff, 0xfff, 0xfff, | ||
712 | 0xfff, 0x15c, 0xfff, 0x23f, 0xfff, 0xfff, 0xfff, 0xfff, | ||
713 | 0xfff, 0xfff, 0xfff, 0xfff, 0x4f3, 0xfff, 0xfff, 0x3c7, | ||
714 | 0xfff, 0x278, 0xfff, 0xfff, 0x0a6, 0xfff, 0xfff, 0xfff, | ||
715 | 0x122, 0x1cf, 0xfff, 0x327, 0xfff, 0x2e5, 0xfff, 0x29d, | ||
716 | 0xfff, 0xfff, 0x3f1, 0xfff, 0xfff, 0x48d, 0xfff, 0xfff, | ||
717 | 0xfff, 0xfff, 0x054, 0xfff, 0xfff, 0xfff, 0xfff, 0x178, | ||
718 | 0x27e, 0x4e0, 0x352, 0x02f, 0x09c, 0xfff, 0x2a0, 0xfff, | ||
719 | 0xfff, 0x46a, 0x457, 0xfff, 0xfff, 0x501, 0xfff, 0x2ba, | ||
720 | 0xfff, 0xfff, 0xfff, 0x54e, 0x2e7, 0xfff, 0xfff, 0xfff, | ||
721 | 0xfff, 0xfff, 0x551, 0xfff, 0xfff, 0x1db, 0x2aa, 0xfff, | ||
722 | 0xfff, 0x4bc, 0xfff, 0xfff, 0x395, 0xfff, 0x0de, 0xfff, | ||
723 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x455, 0xfff, 0x17e, | ||
724 | 0xfff, 0x221, 0x4a7, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
725 | 0x388, 0xfff, 0xfff, 0xfff, 0x308, 0xfff, 0xfff, 0xfff, | ||
726 | 0x20e, 0x4b9, 0xfff, 0x273, 0x20c, 0x09e, 0xfff, 0x057, | ||
727 | 0xfff, 0xfff, 0xfff, 0xfff, 0x3f2, 0xfff, 0x1a8, 0x3a6, | ||
728 | 0x14c, 0xfff, 0xfff, 0x071, 0xfff, 0xfff, 0x53a, 0xfff, | ||
729 | 0xfff, 0xfff, 0xfff, 0x109, 0xfff, 0xfff, 0x399, 0xfff, | ||
730 | 0x061, 0x4f0, 0x39e, 0x244, 0xfff, 0x035, 0xfff, 0xfff, | ||
731 | 0x305, 0x47e, 0x297, 0xfff, 0xfff, 0x2b8, 0xfff, 0xfff, | ||
732 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x1bc, 0xfff, 0x2fc, | ||
733 | 0xfff, 0xfff, 0x554, 0xfff, 0xfff, 0xfff, 0xfff, 0x3b6, | ||
734 | 0xfff, 0xfff, 0xfff, 0x515, 0x397, 0xfff, 0xfff, 0x12f, | ||
735 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4e5, | ||
736 | 0xfff, 0x4fc, 0xfff, 0xfff, 0x05e, 0xfff, 0xfff, 0xfff, | ||
737 | 0xfff, 0xfff, 0x0a8, 0x3af, 0x015, 0xfff, 0xfff, 0xfff, | ||
738 | 0xfff, 0x138, 0xfff, 0xfff, 0xfff, 0x540, 0xfff, 0xfff, | ||
739 | 0xfff, 0x027, 0x523, 0x2f0, 0xfff, 0xfff, 0xfff, 0xfff, | ||
740 | 0xfff, 0xfff, 0x16c, 0xfff, 0x27d, 0xfff, 0xfff, 0xfff, | ||
741 | 0xfff, 0x04c, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4dc, | ||
742 | 0xfff, 0xfff, 0x059, 0x301, 0xfff, 0xfff, 0xfff, 0xfff, | ||
743 | 0xfff, 0xfff, 0xfff, 0x1a3, 0xfff, 0x15a, 0xfff, 0xfff, | ||
744 | 0x0a5, 0xfff, 0x435, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
745 | 0xfff, 0x051, 0xfff, 0xfff, 0x131, 0xfff, 0x4f4, 0xfff, | ||
746 | 0xfff, 0xfff, 0xfff, 0x441, 0xfff, 0x4fb, 0xfff, 0x03b, | ||
747 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x1ed, 0x274, | ||
748 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x0d3, 0x55e, 0x1b3, | ||
749 | 0xfff, 0x0bd, 0xfff, 0xfff, 0xfff, 0xfff, 0x225, 0xfff, | ||
750 | 0xfff, 0xfff, 0xfff, 0xfff, 0x4b7, 0xfff, 0xfff, 0x2ff, | ||
751 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4c3, 0xfff, | ||
752 | 0x383, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x2f6, | ||
753 | 0xfff, 0xfff, 0x1ee, 0xfff, 0x03d, 0xfff, 0xfff, 0xfff, | ||
754 | 0xfff, 0xfff, 0x26f, 0x1dc, 0xfff, 0x0db, 0xfff, 0xfff, | ||
755 | 0xfff, 0xfff, 0xfff, 0x0ce, 0xfff, 0xfff, 0x127, 0x03a, | ||
756 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x311, 0xfff, | ||
757 | 0xfff, 0x13d, 0x09d, 0x47b, 0x2a6, 0x50d, 0x510, 0x19a, | ||
758 | 0xfff, 0x354, 0x414, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
759 | 0xfff, 0xfff, 0x44c, 0x3b0, 0xfff, 0x23d, 0x429, 0xfff, | ||
760 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
761 | 0x4c0, 0x416, 0xfff, 0x05b, 0xfff, 0xfff, 0x137, 0xfff, | ||
762 | 0x25f, 0x49f, 0xfff, 0x279, 0x013, 0xfff, 0xfff, 0xfff, | ||
763 | 0x269, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
764 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x3d0, 0xfff, 0xfff, | ||
765 | 0xfff, 0xfff, 0xfff, 0xfff, 0x077, 0xfff, 0xfff, 0x3fb, | ||
766 | 0xfff, 0xfff, 0xfff, 0xfff, 0x271, 0x3a0, 0xfff, 0xfff, | ||
767 | 0x40f, 0xfff, 0xfff, 0x3de, 0xfff, 0xfff, 0xfff, 0xfff, | ||
768 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x1ab, 0x26a, | ||
769 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x489, 0xfff, 0xfff, | ||
770 | 0x252, 0xfff, 0xfff, 0xfff, 0xfff, 0x1b7, 0x42f, 0xfff, | ||
771 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x3b7, | ||
772 | 0xfff, 0x2bb, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
773 | 0xfff, 0xfff, 0xfff, 0x0f7, 0x01d, 0xfff, 0x067, 0xfff, | ||
774 | 0xfff, 0xfff, 0xfff, 0x4e2, 0xfff, 0xfff, 0x4bb, 0xfff, | ||
775 | 0xfff, 0xfff, 0x17b, 0xfff, 0x0ee, 0xfff, 0xfff, 0xfff, | ||
776 | 0xfff, 0xfff, 0x36e, 0xfff, 0xfff, 0xfff, 0x533, 0xfff, | ||
777 | 0xfff, 0xfff, 0x4d4, 0x356, 0xfff, 0xfff, 0x375, 0xfff, | ||
778 | 0xfff, 0xfff, 0xfff, 0x4a4, 0x513, 0xfff, 0xfff, 0xfff, | ||
779 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4ff, 0xfff, 0x2af, | ||
780 | 0xfff, 0xfff, 0x026, 0xfff, 0x0ad, 0xfff, 0xfff, 0xfff, | ||
781 | 0xfff, 0x26e, 0xfff, 0xfff, 0xfff, 0xfff, 0x493, 0xfff, | ||
782 | 0x463, 0x4d2, 0x4be, 0xfff, 0xfff, 0xfff, 0xfff, 0x4f2, | ||
783 | 0x0b6, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
784 | 0xfff, 0x32d, 0x315, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
785 | 0xfff, 0x13a, 0x4a1, 0xfff, 0x27a, 0xfff, 0xfff, 0xfff, | ||
786 | 0x47a, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
787 | 0x334, 0xfff, 0xfff, 0xfff, 0xfff, 0x54c, 0xfff, 0xfff, | ||
788 | 0xfff, 0x0c9, 0x007, 0xfff, 0xfff, 0x12e, 0xfff, 0x0ff, | ||
789 | 0xfff, 0xfff, 0x3f5, 0x509, 0xfff, 0xfff, 0xfff, 0xfff, | ||
790 | 0x1c3, 0x2ad, 0xfff, 0xfff, 0x47c, 0x261, 0xfff, 0xfff, | ||
791 | 0xfff, 0xfff, 0xfff, 0x152, 0xfff, 0xfff, 0xfff, 0x339, | ||
792 | 0xfff, 0x243, 0x1c0, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
793 | 0x063, 0xfff, 0xfff, 0x254, 0xfff, 0xfff, 0x173, 0xfff, | ||
794 | 0x0c7, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
795 | 0xfff, 0x362, 0x259, 0x485, 0x374, 0x0dc, 0x3ab, 0xfff, | ||
796 | 0x1c5, 0x534, 0x544, 0xfff, 0xfff, 0x508, 0xfff, 0x402, | ||
797 | 0x408, 0xfff, 0x0e7, 0xfff, 0xfff, 0x00a, 0x205, 0xfff, | ||
798 | 0xfff, 0x2b9, 0xfff, 0xfff, 0xfff, 0x465, 0xfff, 0xfff, | ||
799 | 0xfff, 0xfff, 0xfff, 0xfff, 0x23a, 0xfff, 0xfff, 0xfff, | ||
800 | 0xfff, 0x147, 0x19d, 0x115, 0x214, 0xfff, 0x090, 0x368, | ||
801 | 0xfff, 0x210, 0xfff, 0xfff, 0x280, 0x52a, 0x163, 0x148, | ||
802 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x326, 0xfff, 0xfff, | ||
803 | 0xfff, 0xfff, 0xfff, 0x2de, 0xfff, 0xfff, 0xfff, 0xfff, | ||
804 | 0x206, 0x2c1, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
805 | 0x189, 0xfff, 0xfff, 0xfff, 0xfff, 0x367, 0xfff, 0x1a4, | ||
806 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x443, 0xfff, 0x27b, | ||
807 | 0xfff, 0xfff, 0x251, 0x549, 0xfff, 0xfff, 0xfff, 0xfff, | ||
808 | 0xfff, 0xfff, 0x188, 0x04b, 0xfff, 0xfff, 0xfff, 0x31f, | ||
809 | 0x4a6, 0xfff, 0x246, 0x1de, 0x156, 0xfff, 0xfff, 0xfff, | ||
810 | 0x3a9, 0xfff, 0xfff, 0xfff, 0x2fa, 0xfff, 0x128, 0x0d1, | ||
811 | 0x449, 0x255, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
812 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
813 | 0xfff, 0xfff, 0xfff, 0xfff, 0x258, 0xfff, 0xfff, 0xfff, | ||
814 | 0x532, 0xfff, 0xfff, 0xfff, 0x303, 0x517, 0xfff, 0xfff, | ||
815 | 0x2a9, 0x24a, 0xfff, 0xfff, 0x231, 0xfff, 0xfff, 0xfff, | ||
816 | 0xfff, 0xfff, 0x4b6, 0x516, 0xfff, 0xfff, 0x0e4, 0x0eb, | ||
817 | 0xfff, 0x4e4, 0xfff, 0x275, 0xfff, 0xfff, 0x031, 0xfff, | ||
818 | 0xfff, 0xfff, 0xfff, 0xfff, 0x025, 0x21a, 0xfff, 0x0cc, | ||
819 | 0x45f, 0x3d9, 0x289, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
820 | 0xfff, 0xfff, 0x23e, 0xfff, 0xfff, 0xfff, 0x438, 0x097, | ||
821 | 0x419, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
822 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
823 | 0xfff, 0xfff, 0x0a9, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
824 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
825 | 0x37e, 0x0e0, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x431, | ||
826 | 0x372, 0xfff, 0xfff, 0xfff, 0x1ba, 0x06e, 0xfff, 0x1b1, | ||
827 | 0xfff, 0xfff, 0x12a, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
828 | 0xfff, 0xfff, 0x193, 0xfff, 0xfff, 0xfff, 0xfff, 0x10a, | ||
829 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x048, 0x1b4, | ||
830 | 0xfff, 0xfff, 0xfff, 0xfff, 0x295, 0x140, 0x108, 0xfff, | ||
831 | 0xfff, 0xfff, 0xfff, 0x16f, 0xfff, 0x0a4, 0x37a, 0xfff, | ||
832 | 0x29a, 0xfff, 0x284, 0xfff, 0xfff, 0xfff, 0xfff, 0x4c6, | ||
833 | 0x2a2, 0x3a3, 0xfff, 0x201, 0xfff, 0xfff, 0xfff, 0x4bd, | ||
834 | 0x005, 0x54a, 0x3b5, 0x204, 0x2ee, 0x11d, 0x436, 0xfff, | ||
835 | 0xfff, 0xfff, 0xfff, 0xfff, 0x3ec, 0xfff, 0xfff, 0xfff, | ||
836 | 0xfff, 0xfff, 0xfff, 0xfff, 0x11f, 0x498, 0x21c, 0xfff, | ||
837 | 0xfff, 0xfff, 0x3d6, 0xfff, 0x4ab, 0xfff, 0x432, 0x2eb, | ||
838 | 0x542, 0x4fd, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
839 | 0xfff, 0xfff, 0xfff, 0x4ce, 0xfff, 0xfff, 0x2fb, 0xfff, | ||
840 | 0xfff, 0x2e1, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
841 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x1b9, 0x037, 0x0dd, | ||
842 | 0xfff, 0xfff, 0xfff, 0x2bf, 0x521, 0x496, 0x095, 0xfff, | ||
843 | 0xfff, 0x328, 0x070, 0x1bf, 0xfff, 0x393, 0xfff, 0xfff, | ||
844 | 0x102, 0xfff, 0xfff, 0x21b, 0xfff, 0x142, 0x263, 0x519, | ||
845 | 0xfff, 0x2a5, 0x177, 0xfff, 0x14d, 0x471, 0x4ae, 0xfff, | ||
846 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
847 | 0x1f6, 0xfff, 0x481, 0xfff, 0xfff, 0xfff, 0x151, 0xfff, | ||
848 | 0xfff, 0xfff, 0x085, 0x33f, 0xfff, 0xfff, 0xfff, 0x084, | ||
849 | 0xfff, 0xfff, 0xfff, 0x345, 0x3a2, 0xfff, 0xfff, 0x0a0, | ||
850 | 0x0da, 0x024, 0xfff, 0xfff, 0xfff, 0x1bd, 0xfff, 0x55c, | ||
851 | 0x467, 0x445, 0xfff, 0xfff, 0xfff, 0x052, 0xfff, 0xfff, | ||
852 | 0xfff, 0xfff, 0x51e, 0xfff, 0xfff, 0x39d, 0xfff, 0x35f, | ||
853 | 0xfff, 0x376, 0x3ee, 0xfff, 0xfff, 0xfff, 0xfff, 0x448, | ||
854 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x16a, | ||
855 | 0xfff, 0x036, 0x38f, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
856 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x211, | ||
857 | 0xfff, 0xfff, 0xfff, 0x230, 0xfff, 0xfff, 0x3ba, 0xfff, | ||
858 | 0xfff, 0xfff, 0x3ce, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
859 | 0xfff, 0xfff, 0xfff, 0x229, 0xfff, 0x176, 0xfff, 0xfff, | ||
860 | 0xfff, 0xfff, 0xfff, 0x00b, 0xfff, 0x162, 0x018, 0xfff, | ||
861 | 0xfff, 0x233, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
862 | 0x400, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
863 | 0xfff, 0xfff, 0xfff, 0x12b, 0xfff, 0xfff, 0xfff, 0xfff, | ||
864 | 0xfff, 0x3f4, 0xfff, 0x0f0, 0xfff, 0x1ac, 0xfff, 0xfff, | ||
865 | 0x119, 0xfff, 0x2c0, 0xfff, 0xfff, 0xfff, 0x49b, 0xfff, | ||
866 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x23c, 0xfff, | ||
867 | 0x4b3, 0x010, 0x064, 0xfff, 0xfff, 0x4ba, 0xfff, 0xfff, | ||
868 | 0xfff, 0xfff, 0xfff, 0x3c2, 0xfff, 0xfff, 0xfff, 0xfff, | ||
869 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x006, 0x196, 0xfff, | ||
870 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x100, 0x191, 0xfff, | ||
871 | 0x1ea, 0x29f, 0xfff, 0xfff, 0xfff, 0x276, 0xfff, 0xfff, | ||
872 | 0x2b1, 0x3b9, 0xfff, 0x03c, 0xfff, 0xfff, 0xfff, 0x180, | ||
873 | 0xfff, 0x08f, 0xfff, 0xfff, 0x19e, 0x019, 0xfff, 0x0b0, | ||
874 | 0x0fd, 0x332, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
875 | 0xfff, 0x06b, 0x2e8, 0xfff, 0x446, 0xfff, 0xfff, 0x004, | ||
876 | 0x247, 0x197, 0xfff, 0x112, 0x169, 0x292, 0xfff, 0x302, | ||
877 | 0xfff, 0xfff, 0x33b, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
878 | 0xfff, 0xfff, 0xfff, 0x287, 0x21f, 0xfff, 0x3ea, 0xfff, | ||
879 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x4e7, 0xfff, 0xfff, | ||
880 | 0xfff, 0xfff, 0xfff, 0x3a8, 0xfff, 0xfff, 0x2bc, 0xfff, | ||
881 | 0x484, 0x296, 0xfff, 0x1c9, 0x08c, 0x1e5, 0x48a, 0xfff, | ||
882 | 0x360, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
883 | 0x1ca, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
884 | 0xfff, 0xfff, 0xfff, 0x10d, 0xfff, 0xfff, 0xfff, 0xfff, | ||
885 | 0xfff, 0xfff, 0x066, 0x2ea, 0x28b, 0x25b, 0xfff, 0x072, | ||
886 | 0xfff, 0xfff, 0xfff, 0xfff, 0x2b6, 0xfff, 0xfff, 0x272, | ||
887 | 0xfff, 0xfff, 0x525, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
888 | 0x2ca, 0xfff, 0xfff, 0xfff, 0x299, 0xfff, 0xfff, 0xfff, | ||
889 | 0x558, 0x41a, 0xfff, 0x4f7, 0x557, 0xfff, 0x4a0, 0x344, | ||
890 | 0x12c, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x125, | ||
891 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
892 | 0x40e, 0xfff, 0xfff, 0x502, 0xfff, 0x103, 0x3e6, 0xfff, | ||
893 | 0x527, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
894 | 0xfff, 0xfff, 0xfff, 0x45d, 0xfff, 0xfff, 0xfff, 0xfff, | ||
895 | 0x44e, 0xfff, 0xfff, 0xfff, 0xfff, 0x0d2, 0x4c9, 0x35e, | ||
896 | 0x459, 0x2d9, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x17d, | ||
897 | 0x0c4, 0xfff, 0xfff, 0xfff, 0x3ac, 0x390, 0x094, 0xfff, | ||
898 | 0x483, 0x0ab, 0xfff, 0x253, 0xfff, 0x391, 0xfff, 0xfff, | ||
899 | 0xfff, 0xfff, 0x123, 0x0ef, 0xfff, 0xfff, 0xfff, 0x330, | ||
900 | 0x38c, 0xfff, 0xfff, 0x2ae, 0xfff, 0xfff, 0xfff, 0x042, | ||
901 | 0x012, 0x06d, 0xfff, 0xfff, 0xfff, 0x32a, 0x3db, 0x364, | ||
902 | 0x2dc, 0xfff, 0x30f, 0x3d7, 0x4a5, 0x050, 0xfff, 0xfff, | ||
903 | 0x029, 0xfff, 0xfff, 0xfff, 0xfff, 0x1d1, 0xfff, 0xfff, | ||
904 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x480, 0xfff, | ||
905 | 0x4ed, 0x081, 0x0a1, 0xfff, 0xfff, 0xfff, 0x30e, 0x52f, | ||
906 | 0x257, 0xfff, 0xfff, 0x447, 0xfff, 0xfff, 0xfff, 0xfff, | ||
907 | 0xfff, 0xfff, 0xfff, 0x401, 0x3cc, 0xfff, 0xfff, 0x0fb, | ||
908 | 0x2c9, 0x42a, 0x314, 0x33e, 0x3bd, 0x318, 0xfff, 0x10e, | ||
909 | 0x2a1, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x24c, | ||
910 | 0x506, 0xfff, 0x267, 0xfff, 0xfff, 0x219, 0xfff, 0x1eb, | ||
911 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
912 | 0x309, 0x3e2, 0x46c, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
913 | 0x384, 0xfff, 0xfff, 0xfff, 0xfff, 0x50c, 0xfff, 0x24b, | ||
914 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x038, | ||
915 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x194, | ||
916 | 0x143, 0x3e3, 0xfff, 0xfff, 0xfff, 0x4c2, 0xfff, 0xfff, | ||
917 | 0x0e1, 0x25c, 0xfff, 0x237, 0xfff, 0x1fe, 0xfff, 0xfff, | ||
918 | 0xfff, 0x065, 0x2a4, 0xfff, 0x386, 0x55a, 0x11b, 0xfff, | ||
919 | 0xfff, 0x192, 0xfff, 0x183, 0x00e, 0xfff, 0xfff, 0xfff, | ||
920 | 0xfff, 0xfff, 0xfff, 0x4b2, 0x18e, 0xfff, 0xfff, 0xfff, | ||
921 | 0xfff, 0x486, 0x4ef, 0x0c6, 0x380, 0xfff, 0x4a8, 0xfff, | ||
922 | 0x0c5, 0xfff, 0xfff, 0xfff, 0xfff, 0x093, 0x1b8, 0xfff, | ||
923 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x2e6, | ||
924 | 0xfff, 0x0f3, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
925 | 0x28e, 0xfff, 0x53b, 0x420, 0x22a, 0x33a, 0xfff, 0x387, | ||
926 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x2a3, 0xfff, 0xfff, | ||
927 | 0xfff, 0x428, 0x500, 0xfff, 0xfff, 0x120, 0x2c6, 0x290, | ||
928 | 0x2f5, 0x0e3, 0xfff, 0x0b7, 0xfff, 0x319, 0x474, 0xfff, | ||
929 | 0xfff, 0xfff, 0x529, 0x014, 0xfff, 0x41b, 0x40a, 0x18b, | ||
930 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x0d9, | ||
931 | 0xfff, 0x38a, 0xfff, 0xfff, 0xfff, 0xfff, 0x1ce, 0xfff, | ||
932 | 0xfff, 0xfff, 0xfff, 0xfff, 0x3b1, 0xfff, 0xfff, 0x05d, | ||
933 | 0x2c4, 0xfff, 0xfff, 0x4af, 0xfff, 0x030, 0xfff, 0xfff, | ||
934 | 0x203, 0xfff, 0x277, 0x256, 0xfff, 0xfff, 0xfff, 0x4f9, | ||
935 | 0xfff, 0x2c7, 0xfff, 0x466, 0x016, 0x1cd, 0xfff, 0x167, | ||
936 | 0xfff, 0xfff, 0x0c8, 0xfff, 0x43d, 0xfff, 0xfff, 0x020, | ||
937 | 0xfff, 0xfff, 0x232, 0x1cb, 0x1e0, 0xfff, 0xfff, 0x347, | ||
938 | 0xfff, 0x478, 0xfff, 0x365, 0xfff, 0xfff, 0xfff, 0xfff, | ||
939 | 0x358, 0xfff, 0x10b, 0xfff, 0x35d, 0xfff, 0xfff, 0xfff, | ||
940 | 0xfff, 0xfff, 0x452, 0x22d, 0xfff, 0xfff, 0x47d, 0xfff, | ||
941 | 0x2f3, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x460, 0xfff, | ||
942 | 0xfff, 0xfff, 0x50b, 0xfff, 0xfff, 0xfff, 0x2ec, 0xfff, | ||
943 | 0xfff, 0xfff, 0xfff, 0xfff, 0x4b1, 0x422, 0xfff, 0xfff, | ||
944 | 0xfff, 0x2d4, 0xfff, 0x239, 0xfff, 0xfff, 0xfff, 0x439, | ||
945 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
946 | 0xfff, 0x491, 0x075, 0xfff, 0xfff, 0xfff, 0x06c, 0xfff, | ||
947 | 0xfff, 0x0f9, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
948 | 0xfff, 0x139, 0xfff, 0x4f6, 0xfff, 0xfff, 0x409, 0xfff, | ||
949 | 0xfff, 0x15b, 0xfff, 0xfff, 0x348, 0xfff, 0xfff, 0xfff, | ||
950 | 0xfff, 0x4a2, 0x49d, 0xfff, 0x033, 0x175, 0xfff, 0x039, | ||
951 | 0xfff, 0x312, 0x40c, 0xfff, 0xfff, 0x325, 0xfff, 0xfff, | ||
952 | 0xfff, 0xfff, 0xfff, 0xfff, 0x4aa, 0xfff, 0xfff, 0xfff, | ||
953 | 0xfff, 0xfff, 0xfff, 0x165, 0x3bc, 0x48c, 0x310, 0x096, | ||
954 | 0xfff, 0xfff, 0x250, 0x1a2, 0xfff, 0xfff, 0xfff, 0xfff, | ||
955 | 0x20d, 0x2ac, 0xfff, 0xfff, 0x39b, 0xfff, 0x377, 0xfff, | ||
956 | 0x512, 0x495, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
957 | 0xfff, 0xfff, 0xfff, 0xfff, 0x357, 0x4ea, 0xfff, 0xfff, | ||
958 | 0xfff, 0xfff, 0x198, 0xfff, 0xfff, 0xfff, 0x434, 0x04a, | ||
959 | 0xfff, 0xfff, 0xfff, 0xfff, 0x062, 0xfff, 0x1d6, 0x1c8, | ||
960 | 0xfff, 0x1f3, 0x281, 0xfff, 0x462, 0xfff, 0xfff, 0xfff, | ||
961 | 0x4b0, 0xfff, 0x207, 0xfff, 0xfff, 0xfff, 0xfff, 0x3dd, | ||
962 | 0xfff, 0xfff, 0x55d, 0xfff, 0x552, 0x494, 0x1af, 0xfff, | ||
963 | 0xfff, 0xfff, 0xfff, 0xfff, 0x227, 0xfff, 0xfff, 0x069, | ||
964 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x43e, | ||
965 | 0x0b5, 0xfff, 0x524, 0x2d2, 0xfff, 0xfff, 0xfff, 0x28f, | ||
966 | 0xfff, 0x01b, 0x50e, 0xfff, 0xfff, 0x1bb, 0xfff, 0xfff, | ||
967 | 0x41d, 0xfff, 0x32e, 0x48e, 0xfff, 0x1f7, 0x224, 0xfff, | ||
968 | 0xfff, 0xfff, 0xfff, 0xfff, 0x394, 0xfff, 0xfff, 0xfff, | ||
969 | 0xfff, 0x52c, 0xfff, 0xfff, 0xfff, 0x392, 0xfff, 0x1e7, | ||
970 | 0xfff, 0xfff, 0x3f9, 0x3a7, 0xfff, 0x51f, 0xfff, 0x0bb, | ||
971 | 0x118, 0x3ca, 0xfff, 0x1dd, 0xfff, 0x48b, 0xfff, 0xfff, | ||
972 | 0xfff, 0xfff, 0x50f, 0xfff, 0x0d6, 0xfff, 0x1fa, 0xfff, | ||
973 | 0x11e, 0xfff, 0xfff, 0xfff, 0xfff, 0x4d7, 0xfff, 0x078, | ||
974 | 0x008, 0xfff, 0x25d, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
975 | 0x032, 0x33c, 0xfff, 0x4d9, 0x160, 0xfff, 0xfff, 0x300, | ||
976 | 0x0b1, 0xfff, 0x322, 0xfff, 0x4ec, 0xfff, 0xfff, 0x200, | ||
977 | 0x00c, 0x369, 0x473, 0xfff, 0xfff, 0x32c, 0xfff, 0xfff, | ||
978 | 0xfff, 0xfff, 0xfff, 0xfff, 0x53e, 0x3d4, 0x417, 0xfff, | ||
979 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
980 | 0x34b, 0x001, 0x39a, 0x02c, 0xfff, 0xfff, 0x2ce, 0x00f, | ||
981 | 0xfff, 0x0ba, 0xfff, 0xfff, 0xfff, 0xfff, 0x060, 0xfff, | ||
982 | 0x406, 0xfff, 0xfff, 0xfff, 0x4ee, 0x4ac, 0xfff, 0x43f, | ||
983 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x29b, 0xfff, 0xfff, | ||
984 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x216, | ||
985 | 0x190, 0xfff, 0x396, 0x464, 0xfff, 0xfff, 0x323, 0xfff, | ||
986 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x2e9, 0xfff, 0x26d, | ||
987 | 0x2cd, 0x040, 0xfff, 0xfff, 0xfff, 0xfff, 0x38b, 0x3c0, | ||
988 | 0xfff, 0xfff, 0xfff, 0x1f2, 0xfff, 0x0ea, 0xfff, 0xfff, | ||
989 | 0x472, 0xfff, 0x1fb, 0xfff, 0xfff, 0x0af, 0x27f, 0xfff, | ||
990 | 0xfff, 0xfff, 0x479, 0x023, 0xfff, 0x0d8, 0x3b3, 0xfff, | ||
991 | 0xfff, 0xfff, 0x121, 0xfff, 0xfff, 0x3bf, 0xfff, 0xfff, | ||
992 | 0x16b, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
993 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
994 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
995 | 0x45a, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
996 | 0xfff, 0x0be, 0xfff, 0xfff, 0xfff, 0x111, 0xfff, 0x220, | ||
997 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
998 | 0xfff, 0xfff, 0x09b, 0x218, 0xfff, 0x022, 0x202, 0xfff, | ||
999 | 0x4c8, 0xfff, 0x0ed, 0xfff, 0xfff, 0x182, 0xfff, 0xfff, | ||
1000 | 0xfff, 0x17f, 0x213, 0xfff, 0x321, 0x36a, 0xfff, 0x086, | ||
1001 | 0xfff, 0xfff, 0xfff, 0x43b, 0x088, 0xfff, 0xfff, 0xfff, | ||
1002 | 0xfff, 0x26c, 0xfff, 0x2f8, 0x3b4, 0xfff, 0xfff, 0xfff, | ||
1003 | 0x132, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x333, 0x444, | ||
1004 | 0x0c1, 0x4d8, 0x46d, 0x264, 0xfff, 0xfff, 0xfff, 0xfff, | ||
1005 | 0x426, 0xfff, 0xfff, 0xfff, 0xfff, 0x2fe, 0xfff, 0xfff, | ||
1006 | 0xfff, 0xfff, 0x011, 0xfff, 0x05f, 0xfff, 0xfff, 0xfff, | ||
1007 | 0xfff, 0x10c, 0x101, 0xfff, 0xfff, 0xfff, 0xfff, 0x110, | ||
1008 | 0xfff, 0x044, 0x304, 0x361, 0x404, 0xfff, 0x51b, 0x099, | ||
1009 | 0xfff, 0x440, 0xfff, 0xfff, 0xfff, 0x222, 0xfff, 0xfff, | ||
1010 | 0xfff, 0xfff, 0x1b5, 0xfff, 0x136, 0x430, 0xfff, 0x1da, | ||
1011 | 0xfff, 0xfff, 0xfff, 0x043, 0xfff, 0x17c, 0xfff, 0xfff, | ||
1012 | 0xfff, 0x01c, 0xfff, 0xfff, 0xfff, 0x425, 0x236, 0xfff, | ||
1013 | 0x317, 0xfff, 0xfff, 0x437, 0x3fc, 0xfff, 0x1f1, 0xfff, | ||
1014 | 0x324, 0xfff, 0xfff, 0x0ca, 0x306, 0xfff, 0x548, 0xfff, | ||
1015 | 0x46e, 0xfff, 0xfff, 0xfff, 0x4b8, 0x1c2, 0x286, 0xfff, | ||
1016 | 0xfff, 0x087, 0x18a, 0x19f, 0xfff, 0xfff, 0xfff, 0xfff, | ||
1017 | 0x18c, 0xfff, 0x215, 0xfff, 0xfff, 0xfff, 0xfff, 0x283, | ||
1018 | 0xfff, 0xfff, 0xfff, 0x126, 0xfff, 0xfff, 0x370, 0xfff, | ||
1019 | 0x53f, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0x31c, 0xfff, | ||
1020 | 0x4d1, 0xfff, 0xfff, 0xfff, 0x021, 0xfff, 0x157, 0xfff, | ||
1021 | 0xfff, 0x028, 0x16e, 0xfff, 0x421, 0xfff, 0x1c6, 0xfff, | ||
1022 | 0xfff, 0x511, 0xfff, 0xfff, 0x39c, 0x46f, 0x1b2, 0xfff, | ||
1023 | 0xfff, 0x316, 0xfff, 0xfff, 0x009, 0xfff, 0xfff, 0x195, | ||
1024 | 0xfff, 0x240, 0x546, 0xfff, 0xfff, 0x520, 0xfff, 0xfff, | ||
1025 | 0xfff, 0xfff, 0xfff, 0xfff, 0x454, 0xfff, 0xfff, 0xfff, | ||
1026 | 0x3f3, 0xfff, 0xfff, 0x187, 0xfff, 0x4a9, 0xfff, 0xfff, | ||
1027 | 0xfff, 0xfff, 0xfff, 0xfff, 0x51c, 0x453, 0x1e6, 0xfff, | ||
1028 | 0xfff, 0xfff, 0x1b0, 0xfff, 0x477, 0xfff, 0xfff, 0xfff, | ||
1029 | 0x4fe, 0xfff, 0x32f, 0xfff, 0xfff, 0x15e, 0x1d4, 0xfff, | ||
1030 | 0x0e5, 0xfff, 0xfff, 0xfff, 0x242, 0x14b, 0x046, 0xfff, | ||
1031 | 0x3f6, 0x3bb, 0x3e4, 0xfff, 0xfff, 0x2e3, 0xfff, 0x245, | ||
1032 | 0xfff, 0x149, 0xfff, 0xfff, 0xfff, 0x2db, 0xfff, 0xfff, | ||
1033 | 0x181, 0xfff, 0x089, 0x2c5, 0xfff, 0x1f5, 0xfff, 0x2d6, | ||
1034 | 0x507, 0xfff, 0x42d, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
1035 | 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
1036 | 0x080, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, 0xfff, | ||
1037 | 0xfff, 0xfff, 0xfff, 0xfff, 0x3c3, 0x320, 0xfff, 0x1e1, | ||
1038 | 0xfff, 0x0f5, 0x13b, 0xfff, 0xfff, 0xfff, 0x003, 0x4da, | ||
1039 | 0xfff, 0xfff, 0xfff, 0x42c, 0xfff, 0xfff, 0x0cb, 0xfff, | ||
1040 | 0x536, 0x2c3, 0xfff, 0xfff, 0xfff, 0xfff, 0x199, 0xfff, | ||
1041 | 0xfff, 0x0c0, 0xfff, 0x01e, 0x497, 0xfff, 0xfff, 0x3e5, | ||
1042 | 0xfff, 0xfff, 0xfff, 0x0cf, 0xfff, 0x2bd, 0xfff, 0x223, | ||
1043 | 0xfff, 0x3ff, 0xfff, 0x058, 0x174, 0x3ef, 0xfff, 0x002 | ||
1044 | }; | ||
1045 | |||
1046 | static unsigned short err_pos(unsigned short din) | ||
1047 | { | ||
1048 | BUG_ON(din > 4096); | ||
1049 | return err_pos_lut[din]; | ||
1050 | } | ||
1051 | static int chk_no_err_only(unsigned short *chk_syndrome_list, unsigned short *err_info) | ||
1052 | { | ||
1053 | if ((chk_syndrome_list[0] | chk_syndrome_list[1] | | ||
1054 | chk_syndrome_list[2] | chk_syndrome_list[3] | | ||
1055 | chk_syndrome_list[4] | chk_syndrome_list[5] | | ||
1056 | chk_syndrome_list[6] | chk_syndrome_list[7]) != 0x0) { | ||
1057 | return -EINVAL; | ||
1058 | } else { | ||
1059 | err_info[0] = 0x0; | ||
1060 | return 0; | ||
1061 | } | ||
1062 | } | ||
1063 | static int chk_1_err_only(unsigned short *chk_syndrome_list, unsigned short *err_info) | ||
1064 | { | ||
1065 | unsigned short tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6; | ||
1066 | tmp0 = gf4096_mul(chk_syndrome_list[1], gf4096_inv(chk_syndrome_list[0])); | ||
1067 | tmp1 = gf4096_mul(chk_syndrome_list[2], gf4096_inv(chk_syndrome_list[1])); | ||
1068 | tmp2 = gf4096_mul(chk_syndrome_list[3], gf4096_inv(chk_syndrome_list[2])); | ||
1069 | tmp3 = gf4096_mul(chk_syndrome_list[4], gf4096_inv(chk_syndrome_list[3])); | ||
1070 | tmp4 = gf4096_mul(chk_syndrome_list[5], gf4096_inv(chk_syndrome_list[4])); | ||
1071 | tmp5 = gf4096_mul(chk_syndrome_list[6], gf4096_inv(chk_syndrome_list[5])); | ||
1072 | tmp6 = gf4096_mul(chk_syndrome_list[7], gf4096_inv(chk_syndrome_list[6])); | ||
1073 | if ((tmp0 == tmp1) & (tmp1 == tmp2) & (tmp2 == tmp3) & (tmp3 == tmp4) & (tmp4 == tmp5) & (tmp5 == tmp6)) { | ||
1074 | err_info[0] = 0x1; // encode 1-symbol error as 0x1 | ||
1075 | err_info[1] = err_pos(tmp0); | ||
1076 | err_info[1] = (unsigned short)(0x55e - err_info[1]); | ||
1077 | err_info[5] = chk_syndrome_list[0]; | ||
1078 | return 0; | ||
1079 | } else | ||
1080 | return -EINVAL; | ||
1081 | } | ||
1082 | static int chk_2_err_only(unsigned short *chk_syndrome_list, unsigned short *err_info) | ||
1083 | { | ||
1084 | unsigned short tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7; | ||
1085 | unsigned short coefs[4]; | ||
1086 | unsigned short err_pats[4]; | ||
1087 | int found_num_root = 0; | ||
1088 | unsigned short bit2_root0, bit2_root1; | ||
1089 | unsigned short bit2_root0_inv, bit2_root1_inv; | ||
1090 | unsigned short err_loc_eqn, test_root; | ||
1091 | unsigned short bit2_loc0, bit2_loc1; | ||
1092 | unsigned short bit2_pat0, bit2_pat1; | ||
1093 | |||
1094 | find_2x2_soln(chk_syndrome_list[1], | ||
1095 | chk_syndrome_list[0], | ||
1096 | chk_syndrome_list[2], chk_syndrome_list[1], chk_syndrome_list[2], chk_syndrome_list[3], coefs); | ||
1097 | for (test_root = 0x1; test_root < 0xfff; test_root++) { | ||
1098 | err_loc_eqn = | ||
1099 | gf4096_mul(coefs[1], gf4096_mul(test_root, test_root)) ^ gf4096_mul(coefs[0], test_root) ^ 0x1; | ||
1100 | if (err_loc_eqn == 0x0) { | ||
1101 | if (found_num_root == 0) { | ||
1102 | bit2_root0 = test_root; | ||
1103 | found_num_root = 1; | ||
1104 | } else if (found_num_root == 1) { | ||
1105 | bit2_root1 = test_root; | ||
1106 | found_num_root = 2; | ||
1107 | break; | ||
1108 | } | ||
1109 | } | ||
1110 | } | ||
1111 | if (found_num_root != 2) | ||
1112 | return -EINVAL; | ||
1113 | else { | ||
1114 | bit2_root0_inv = gf4096_inv(bit2_root0); | ||
1115 | bit2_root1_inv = gf4096_inv(bit2_root1); | ||
1116 | find_2bit_err_pats(chk_syndrome_list[0], | ||
1117 | chk_syndrome_list[1], bit2_root0_inv, bit2_root1_inv, err_pats); | ||
1118 | bit2_pat0 = err_pats[0]; | ||
1119 | bit2_pat1 = err_pats[1]; | ||
1120 | //for(x+1) | ||
1121 | tmp0 = gf4096_mul(gf4096_mul(bit2_root0_inv, bit2_root0_inv), gf4096_mul(bit2_root0_inv, bit2_root0_inv)); //rinv0^4 | ||
1122 | tmp1 = gf4096_mul(bit2_root0_inv, tmp0); //rinv0^5 | ||
1123 | tmp2 = gf4096_mul(bit2_root0_inv, tmp1); //rinv0^6 | ||
1124 | tmp3 = gf4096_mul(bit2_root0_inv, tmp2); //rinv0^7 | ||
1125 | tmp4 = gf4096_mul(gf4096_mul(bit2_root1_inv, bit2_root1_inv), gf4096_mul(bit2_root1_inv, bit2_root1_inv)); //rinv1^4 | ||
1126 | tmp5 = gf4096_mul(bit2_root1_inv, tmp4); //rinv1^5 | ||
1127 | tmp6 = gf4096_mul(bit2_root1_inv, tmp5); //rinv1^6 | ||
1128 | tmp7 = gf4096_mul(bit2_root1_inv, tmp6); //rinv1^7 | ||
1129 | //check if only 2-bit error | ||
1130 | if ((chk_syndrome_list[4] == | ||
1131 | (gf4096_mul(bit2_pat0, tmp0) ^ | ||
1132 | gf4096_mul(bit2_pat1, | ||
1133 | tmp4))) & (chk_syndrome_list[5] == | ||
1134 | (gf4096_mul(bit2_pat0, tmp1) ^ | ||
1135 | gf4096_mul(bit2_pat1, | ||
1136 | tmp5))) & | ||
1137 | (chk_syndrome_list[6] == | ||
1138 | (gf4096_mul(bit2_pat0, tmp2) ^ | ||
1139 | gf4096_mul(bit2_pat1, | ||
1140 | tmp6))) & (chk_syndrome_list[7] == | ||
1141 | (gf4096_mul(bit2_pat0, tmp3) ^ gf4096_mul(bit2_pat1, tmp7)))) { | ||
1142 | if ((err_pos(bit2_root0_inv) == 0xfff) | (err_pos(bit2_root1_inv) == 0xfff)) { | ||
1143 | return -EINVAL; | ||
1144 | } else { | ||
1145 | bit2_loc0 = 0x55e - err_pos(bit2_root0_inv); | ||
1146 | bit2_loc1 = 0x55e - err_pos(bit2_root1_inv); | ||
1147 | err_info[0] = 0x2; // encode 2-symbol error as 0x2 | ||
1148 | err_info[1] = bit2_loc0; | ||
1149 | err_info[2] = bit2_loc1; | ||
1150 | err_info[5] = bit2_pat0; | ||
1151 | err_info[6] = bit2_pat1; | ||
1152 | return 0; | ||
1153 | } | ||
1154 | } else | ||
1155 | return -EINVAL; | ||
1156 | } | ||
1157 | } | ||
1158 | static int chk_3_err_only(unsigned short *chk_syndrome_list, unsigned short *err_info) | ||
1159 | { | ||
1160 | unsigned short tmp0, tmp1, tmp2, tmp3, tmp4, tmp5; | ||
1161 | unsigned short coefs[4]; | ||
1162 | unsigned short err_pats[4]; | ||
1163 | int found_num_root = 0; | ||
1164 | unsigned short bit3_root0, bit3_root1, bit3_root2; | ||
1165 | unsigned short bit3_root0_inv, bit3_root1_inv, bit3_root2_inv; | ||
1166 | unsigned short err_loc_eqn, test_root; | ||
1167 | |||
1168 | find_3bit_err_coefs(chk_syndrome_list[0], chk_syndrome_list[1], | ||
1169 | chk_syndrome_list[2], chk_syndrome_list[3], | ||
1170 | chk_syndrome_list[4], chk_syndrome_list[5], coefs); | ||
1171 | |||
1172 | for (test_root = 0x1; test_root < 0xfff; test_root++) { | ||
1173 | err_loc_eqn = gf4096_mul(coefs[2], | ||
1174 | gf4096_mul(gf4096_mul(test_root, test_root), | ||
1175 | test_root)) ^ gf4096_mul(coefs[1], gf4096_mul(test_root, test_root)) | ||
1176 | ^ gf4096_mul(coefs[0], test_root) ^ 0x1; | ||
1177 | |||
1178 | if (err_loc_eqn == 0x0) { | ||
1179 | if (found_num_root == 0) { | ||
1180 | bit3_root0 = test_root; | ||
1181 | found_num_root = 1; | ||
1182 | } else if (found_num_root == 1) { | ||
1183 | bit3_root1 = test_root; | ||
1184 | found_num_root = 2; | ||
1185 | } else if (found_num_root == 2) { | ||
1186 | bit3_root2 = test_root; | ||
1187 | found_num_root = 3; | ||
1188 | break; | ||
1189 | } | ||
1190 | } | ||
1191 | } | ||
1192 | if (found_num_root != 3) | ||
1193 | return -EINVAL; | ||
1194 | else { | ||
1195 | bit3_root0_inv = gf4096_inv(bit3_root0); | ||
1196 | bit3_root1_inv = gf4096_inv(bit3_root1); | ||
1197 | bit3_root2_inv = gf4096_inv(bit3_root2); | ||
1198 | |||
1199 | find_3bit_err_pats(chk_syndrome_list[0], chk_syndrome_list[1], | ||
1200 | chk_syndrome_list[2], bit3_root0_inv, | ||
1201 | bit3_root1_inv, bit3_root2_inv, err_pats); | ||
1202 | |||
1203 | //check if only 3-bit error | ||
1204 | tmp0 = gf4096_mul(bit3_root0_inv, bit3_root0_inv); | ||
1205 | tmp0 = gf4096_mul(tmp0, tmp0); | ||
1206 | tmp0 = gf4096_mul(tmp0, bit3_root0_inv); | ||
1207 | tmp0 = gf4096_mul(tmp0, bit3_root0_inv); //rinv0^6 | ||
1208 | tmp1 = gf4096_mul(tmp0, bit3_root0_inv); //rinv0^7 | ||
1209 | tmp2 = gf4096_mul(bit3_root1_inv, bit3_root1_inv); | ||
1210 | tmp2 = gf4096_mul(tmp2, tmp2); | ||
1211 | tmp2 = gf4096_mul(tmp2, bit3_root1_inv); | ||
1212 | tmp2 = gf4096_mul(tmp2, bit3_root1_inv); //rinv1^6 | ||
1213 | tmp3 = gf4096_mul(tmp2, bit3_root1_inv); //rinv1^7 | ||
1214 | tmp4 = gf4096_mul(bit3_root2_inv, bit3_root2_inv); | ||
1215 | tmp4 = gf4096_mul(tmp4, tmp4); | ||
1216 | tmp4 = gf4096_mul(tmp4, bit3_root2_inv); | ||
1217 | tmp4 = gf4096_mul(tmp4, bit3_root2_inv); //rinv2^6 | ||
1218 | tmp5 = gf4096_mul(tmp4, bit3_root2_inv); //rinv2^7 | ||
1219 | |||
1220 | //check if only 3 errors | ||
1221 | if ((chk_syndrome_list[6] == (gf4096_mul(err_pats[0], tmp0) ^ | ||
1222 | gf4096_mul(err_pats[1], tmp2) ^ | ||
1223 | gf4096_mul(err_pats[2], tmp4))) & | ||
1224 | (chk_syndrome_list[7] == (gf4096_mul(err_pats[0], tmp1) ^ | ||
1225 | gf4096_mul(err_pats[1], tmp3) ^ gf4096_mul(err_pats[2], tmp5)))) { | ||
1226 | if ((err_pos(bit3_root0_inv) == 0xfff) | | ||
1227 | (err_pos(bit3_root1_inv) == 0xfff) | (err_pos(bit3_root2_inv) == 0xfff)) { | ||
1228 | return -EINVAL; | ||
1229 | } else { | ||
1230 | err_info[0] = 0x3; | ||
1231 | err_info[1] = (0x55e - err_pos(bit3_root0_inv)); | ||
1232 | err_info[2] = (0x55e - err_pos(bit3_root1_inv)); | ||
1233 | err_info[3] = (0x55e - err_pos(bit3_root2_inv)); | ||
1234 | err_info[5] = err_pats[0]; | ||
1235 | err_info[6] = err_pats[1]; | ||
1236 | err_info[7] = err_pats[2]; | ||
1237 | return 0; | ||
1238 | } | ||
1239 | } else | ||
1240 | return -EINVAL; | ||
1241 | } | ||
1242 | } | ||
1243 | static int chk_4_err_only(unsigned short *chk_syndrome_list, unsigned short *err_info) | ||
1244 | { | ||
1245 | unsigned short coefs[4]; | ||
1246 | unsigned short err_pats[4]; | ||
1247 | int found_num_root = 0; | ||
1248 | unsigned short bit4_root0, bit4_root1, bit4_root2, bit4_root3; | ||
1249 | unsigned short bit4_root0_inv, bit4_root1_inv, bit4_root2_inv, bit4_root3_inv; | ||
1250 | unsigned short err_loc_eqn, test_root; | ||
1251 | |||
1252 | find_4bit_err_coefs(chk_syndrome_list[0], | ||
1253 | chk_syndrome_list[1], | ||
1254 | chk_syndrome_list[2], | ||
1255 | chk_syndrome_list[3], | ||
1256 | chk_syndrome_list[4], | ||
1257 | chk_syndrome_list[5], chk_syndrome_list[6], chk_syndrome_list[7], coefs); | ||
1258 | |||
1259 | for (test_root = 0x1; test_root < 0xfff; test_root++) { | ||
1260 | err_loc_eqn = | ||
1261 | gf4096_mul(coefs[3], | ||
1262 | gf4096_mul(gf4096_mul | ||
1263 | (gf4096_mul(test_root, test_root), | ||
1264 | test_root), | ||
1265 | test_root)) ^ gf4096_mul(coefs[2], | ||
1266 | gf4096_mul | ||
1267 | (gf4096_mul(test_root, test_root), test_root)) | ||
1268 | ^ gf4096_mul(coefs[1], gf4096_mul(test_root, test_root)) ^ gf4096_mul(coefs[0], test_root) | ||
1269 | ^ 0x1; | ||
1270 | if (err_loc_eqn == 0x0) { | ||
1271 | if (found_num_root == 0) { | ||
1272 | bit4_root0 = test_root; | ||
1273 | found_num_root = 1; | ||
1274 | } else if (found_num_root == 1) { | ||
1275 | bit4_root1 = test_root; | ||
1276 | found_num_root = 2; | ||
1277 | } else if (found_num_root == 2) { | ||
1278 | bit4_root2 = test_root; | ||
1279 | found_num_root = 3; | ||
1280 | } else { | ||
1281 | found_num_root = 4; | ||
1282 | bit4_root3 = test_root; | ||
1283 | break; | ||
1284 | } | ||
1285 | } | ||
1286 | } | ||
1287 | if (found_num_root != 4) { | ||
1288 | return -EINVAL; | ||
1289 | } else { | ||
1290 | bit4_root0_inv = gf4096_inv(bit4_root0); | ||
1291 | bit4_root1_inv = gf4096_inv(bit4_root1); | ||
1292 | bit4_root2_inv = gf4096_inv(bit4_root2); | ||
1293 | bit4_root3_inv = gf4096_inv(bit4_root3); | ||
1294 | find_4bit_err_pats(chk_syndrome_list[0], | ||
1295 | chk_syndrome_list[1], | ||
1296 | chk_syndrome_list[2], | ||
1297 | chk_syndrome_list[3], | ||
1298 | bit4_root0_inv, bit4_root1_inv, bit4_root2_inv, bit4_root3_inv, err_pats); | ||
1299 | err_info[0] = 0x4; | ||
1300 | err_info[1] = (0x55e - err_pos(bit4_root0_inv)); | ||
1301 | err_info[2] = (0x55e - err_pos(bit4_root1_inv)); | ||
1302 | err_info[3] = (0x55e - err_pos(bit4_root2_inv)); | ||
1303 | err_info[4] = (0x55e - err_pos(bit4_root3_inv)); | ||
1304 | err_info[5] = err_pats[0]; | ||
1305 | err_info[6] = err_pats[1]; | ||
1306 | err_info[7] = err_pats[2]; | ||
1307 | err_info[8] = err_pats[3]; | ||
1308 | return 0; | ||
1309 | } | ||
1310 | } | ||
1311 | |||
1312 | void correct_12bit_symbol(unsigned char *buf, unsigned short sym, | ||
1313 | unsigned short val) | ||
1314 | { | ||
1315 | if (unlikely(sym > 1366)) { | ||
1316 | printk(KERN_ERR "Error: symbol %d out of range; cannot correct\n", sym); | ||
1317 | } else if (sym == 0) { | ||
1318 | buf[0] ^= val; | ||
1319 | } else if (sym & 1) { | ||
1320 | buf[1+(3*(sym-1))/2] ^= (val >> 4); | ||
1321 | buf[2+(3*(sym-1))/2] ^= ((val & 0xf) << 4); | ||
1322 | } else { | ||
1323 | buf[2+(3*(sym-2))/2] ^= (val >> 8); | ||
1324 | buf[3+(3*(sym-2))/2] ^= (val & 0xff); | ||
1325 | } | ||
1326 | } | ||
1327 | |||
1328 | static int debugecc = 0; | ||
1329 | module_param(debugecc, int, 0644); | ||
1330 | |||
1331 | int cafe_correct_ecc(unsigned char *buf, | ||
1332 | unsigned short *chk_syndrome_list) | ||
1333 | { | ||
1334 | unsigned short err_info[9]; | ||
1335 | int i; | ||
1336 | |||
1337 | if (debugecc) { | ||
1338 | printk(KERN_WARNING "cafe_correct_ecc invoked. Syndromes %x %x %x %x %x %x %x %x\n", | ||
1339 | chk_syndrome_list[0], chk_syndrome_list[1], | ||
1340 | chk_syndrome_list[2], chk_syndrome_list[3], | ||
1341 | chk_syndrome_list[4], chk_syndrome_list[5], | ||
1342 | chk_syndrome_list[6], chk_syndrome_list[7]); | ||
1343 | for (i=0; i < 2048; i+=16) { | ||
1344 | printk(KERN_WARNING "D %04x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", | ||
1345 | i, | ||
1346 | buf[i], buf[i+1], buf[i+2], buf[i+3], | ||
1347 | buf[i+4], buf[i+5], buf[i+6], buf[i+7], | ||
1348 | buf[i+8], buf[i+9], buf[i+10], buf[i+11], | ||
1349 | buf[i+12], buf[i+13], buf[i+14], buf[i+15]); | ||
1350 | } | ||
1351 | for ( ; i < 2112; i+=16) { | ||
1352 | printk(KERN_WARNING "O %02x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", | ||
1353 | i - 2048, | ||
1354 | buf[i], buf[i+1], buf[i+2], buf[i+3], | ||
1355 | buf[i+4], buf[i+5], buf[i+6], buf[i+7], | ||
1356 | buf[i+8], buf[i+9], buf[i+10], buf[i+11], | ||
1357 | buf[i+12], buf[i+13], buf[i+14], buf[i+15]); | ||
1358 | } | ||
1359 | } | ||
1360 | |||
1361 | |||
1362 | |||
1363 | if (chk_no_err_only(chk_syndrome_list, err_info) && | ||
1364 | chk_1_err_only(chk_syndrome_list, err_info) && | ||
1365 | chk_2_err_only(chk_syndrome_list, err_info) && | ||
1366 | chk_3_err_only(chk_syndrome_list, err_info) && | ||
1367 | chk_4_err_only(chk_syndrome_list, err_info)) { | ||
1368 | return -EIO; | ||
1369 | } | ||
1370 | |||
1371 | for (i=0; i < err_info[0]; i++) { | ||
1372 | if (debugecc) | ||
1373 | printk(KERN_WARNING "Correct symbol %d with 0x%03x\n", | ||
1374 | err_info[1+i], err_info[5+i]); | ||
1375 | |||
1376 | correct_12bit_symbol(buf, err_info[1+i], err_info[5+i]); | ||
1377 | } | ||
1378 | |||
1379 | return err_info[0]; | ||
1380 | } | ||
1381 | |||
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index 6107f532855b..12608c13cce5 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c | |||
@@ -1635,13 +1635,12 @@ static int __init doc_probe(unsigned long physadr) | |||
1635 | 1635 | ||
1636 | len = sizeof(struct mtd_info) + | 1636 | len = sizeof(struct mtd_info) + |
1637 | sizeof(struct nand_chip) + sizeof(struct doc_priv) + (2 * sizeof(struct nand_bbt_descr)); | 1637 | sizeof(struct nand_chip) + sizeof(struct doc_priv) + (2 * sizeof(struct nand_bbt_descr)); |
1638 | mtd = kmalloc(len, GFP_KERNEL); | 1638 | mtd = kzalloc(len, GFP_KERNEL); |
1639 | if (!mtd) { | 1639 | if (!mtd) { |
1640 | printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len); | 1640 | printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len); |
1641 | ret = -ENOMEM; | 1641 | ret = -ENOMEM; |
1642 | goto fail; | 1642 | goto fail; |
1643 | } | 1643 | } |
1644 | memset(mtd, 0, len); | ||
1645 | 1644 | ||
1646 | nand = (struct nand_chip *) (mtd + 1); | 1645 | nand = (struct nand_chip *) (mtd + 1); |
1647 | doc = (struct doc_priv *) (nand + 1); | 1646 | doc = (struct doc_priv *) (nand + 1); |
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 8df36e2c9a53..5dcb2e066ce7 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -897,12 +897,11 @@ static int nand_read_page_syndrome(struct mtd_info *mtd, struct nand_chip *chip, | |||
897 | * @chip: nand chip structure | 897 | * @chip: nand chip structure |
898 | * @oob: oob destination address | 898 | * @oob: oob destination address |
899 | * @ops: oob ops structure | 899 | * @ops: oob ops structure |
900 | * @len: size of oob to transfer | ||
900 | */ | 901 | */ |
901 | static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob, | 902 | static uint8_t *nand_transfer_oob(struct nand_chip *chip, uint8_t *oob, |
902 | struct mtd_oob_ops *ops) | 903 | struct mtd_oob_ops *ops, size_t len) |
903 | { | 904 | { |
904 | size_t len = ops->ooblen; | ||
905 | |||
906 | switch(ops->mode) { | 905 | switch(ops->mode) { |
907 | 906 | ||
908 | case MTD_OOB_PLACE: | 907 | case MTD_OOB_PLACE: |
@@ -960,6 +959,7 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, | |||
960 | int sndcmd = 1; | 959 | int sndcmd = 1; |
961 | int ret = 0; | 960 | int ret = 0; |
962 | uint32_t readlen = ops->len; | 961 | uint32_t readlen = ops->len; |
962 | uint32_t oobreadlen = ops->ooblen; | ||
963 | uint8_t *bufpoi, *oob, *buf; | 963 | uint8_t *bufpoi, *oob, *buf; |
964 | 964 | ||
965 | stats = mtd->ecc_stats; | 965 | stats = mtd->ecc_stats; |
@@ -1006,10 +1006,17 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, | |||
1006 | 1006 | ||
1007 | if (unlikely(oob)) { | 1007 | if (unlikely(oob)) { |
1008 | /* Raw mode does data:oob:data:oob */ | 1008 | /* Raw mode does data:oob:data:oob */ |
1009 | if (ops->mode != MTD_OOB_RAW) | 1009 | if (ops->mode != MTD_OOB_RAW) { |
1010 | oob = nand_transfer_oob(chip, oob, ops); | 1010 | int toread = min(oobreadlen, |
1011 | else | 1011 | chip->ecc.layout->oobavail); |
1012 | buf = nand_transfer_oob(chip, buf, ops); | 1012 | if (toread) { |
1013 | oob = nand_transfer_oob(chip, | ||
1014 | oob, ops, toread); | ||
1015 | oobreadlen -= toread; | ||
1016 | } | ||
1017 | } else | ||
1018 | buf = nand_transfer_oob(chip, | ||
1019 | buf, ops, mtd->oobsize); | ||
1013 | } | 1020 | } |
1014 | 1021 | ||
1015 | if (!(chip->options & NAND_NO_READRDY)) { | 1022 | if (!(chip->options & NAND_NO_READRDY)) { |
@@ -1056,6 +1063,8 @@ static int nand_do_read_ops(struct mtd_info *mtd, loff_t from, | |||
1056 | } | 1063 | } |
1057 | 1064 | ||
1058 | ops->retlen = ops->len - (size_t) readlen; | 1065 | ops->retlen = ops->len - (size_t) readlen; |
1066 | if (oob) | ||
1067 | ops->oobretlen = ops->ooblen - oobreadlen; | ||
1059 | 1068 | ||
1060 | if (ret) | 1069 | if (ret) |
1061 | return ret; | 1070 | return ret; |
@@ -1256,12 +1265,18 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, | |||
1256 | int page, realpage, chipnr, sndcmd = 1; | 1265 | int page, realpage, chipnr, sndcmd = 1; |
1257 | struct nand_chip *chip = mtd->priv; | 1266 | struct nand_chip *chip = mtd->priv; |
1258 | int blkcheck = (1 << (chip->phys_erase_shift - chip->page_shift)) - 1; | 1267 | int blkcheck = (1 << (chip->phys_erase_shift - chip->page_shift)) - 1; |
1259 | int readlen = ops->len; | 1268 | int readlen = ops->ooblen; |
1269 | int len; | ||
1260 | uint8_t *buf = ops->oobbuf; | 1270 | uint8_t *buf = ops->oobbuf; |
1261 | 1271 | ||
1262 | DEBUG(MTD_DEBUG_LEVEL3, "nand_read_oob: from = 0x%08Lx, len = %i\n", | 1272 | DEBUG(MTD_DEBUG_LEVEL3, "nand_read_oob: from = 0x%08Lx, len = %i\n", |
1263 | (unsigned long long)from, readlen); | 1273 | (unsigned long long)from, readlen); |
1264 | 1274 | ||
1275 | if (ops->mode == MTD_OOB_RAW) | ||
1276 | len = mtd->oobsize; | ||
1277 | else | ||
1278 | len = chip->ecc.layout->oobavail; | ||
1279 | |||
1265 | chipnr = (int)(from >> chip->chip_shift); | 1280 | chipnr = (int)(from >> chip->chip_shift); |
1266 | chip->select_chip(mtd, chipnr); | 1281 | chip->select_chip(mtd, chipnr); |
1267 | 1282 | ||
@@ -1271,7 +1286,9 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, | |||
1271 | 1286 | ||
1272 | while(1) { | 1287 | while(1) { |
1273 | sndcmd = chip->ecc.read_oob(mtd, chip, page, sndcmd); | 1288 | sndcmd = chip->ecc.read_oob(mtd, chip, page, sndcmd); |
1274 | buf = nand_transfer_oob(chip, buf, ops); | 1289 | |
1290 | len = min(len, readlen); | ||
1291 | buf = nand_transfer_oob(chip, buf, ops, len); | ||
1275 | 1292 | ||
1276 | if (!(chip->options & NAND_NO_READRDY)) { | 1293 | if (!(chip->options & NAND_NO_READRDY)) { |
1277 | /* | 1294 | /* |
@@ -1286,7 +1303,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, | |||
1286 | nand_wait_ready(mtd); | 1303 | nand_wait_ready(mtd); |
1287 | } | 1304 | } |
1288 | 1305 | ||
1289 | readlen -= ops->ooblen; | 1306 | readlen -= len; |
1290 | if (!readlen) | 1307 | if (!readlen) |
1291 | break; | 1308 | break; |
1292 | 1309 | ||
@@ -1308,7 +1325,7 @@ static int nand_do_read_oob(struct mtd_info *mtd, loff_t from, | |||
1308 | sndcmd = 1; | 1325 | sndcmd = 1; |
1309 | } | 1326 | } |
1310 | 1327 | ||
1311 | ops->retlen = ops->len; | 1328 | ops->oobretlen = ops->ooblen; |
1312 | return 0; | 1329 | return 0; |
1313 | } | 1330 | } |
1314 | 1331 | ||
@@ -1329,7 +1346,7 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from, | |||
1329 | ops->retlen = 0; | 1346 | ops->retlen = 0; |
1330 | 1347 | ||
1331 | /* Do not allow reads past end of device */ | 1348 | /* Do not allow reads past end of device */ |
1332 | if ((from + ops->len) > mtd->size) { | 1349 | if (ops->datbuf && (from + ops->len) > mtd->size) { |
1333 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_oob: " | 1350 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_oob: " |
1334 | "Attempt read beyond end of device\n"); | 1351 | "Attempt read beyond end of device\n"); |
1335 | return -EINVAL; | 1352 | return -EINVAL; |
@@ -1654,6 +1671,8 @@ static int nand_do_write_ops(struct mtd_info *mtd, loff_t to, | |||
1654 | } | 1671 | } |
1655 | 1672 | ||
1656 | ops->retlen = ops->len - writelen; | 1673 | ops->retlen = ops->len - writelen; |
1674 | if (unlikely(oob)) | ||
1675 | ops->oobretlen = ops->ooblen; | ||
1657 | return ret; | 1676 | return ret; |
1658 | } | 1677 | } |
1659 | 1678 | ||
@@ -1709,10 +1728,10 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, | |||
1709 | struct nand_chip *chip = mtd->priv; | 1728 | struct nand_chip *chip = mtd->priv; |
1710 | 1729 | ||
1711 | DEBUG(MTD_DEBUG_LEVEL3, "nand_write_oob: to = 0x%08x, len = %i\n", | 1730 | DEBUG(MTD_DEBUG_LEVEL3, "nand_write_oob: to = 0x%08x, len = %i\n", |
1712 | (unsigned int)to, (int)ops->len); | 1731 | (unsigned int)to, (int)ops->ooblen); |
1713 | 1732 | ||
1714 | /* Do not allow write past end of page */ | 1733 | /* Do not allow write past end of page */ |
1715 | if ((ops->ooboffs + ops->len) > mtd->oobsize) { | 1734 | if ((ops->ooboffs + ops->ooblen) > mtd->oobsize) { |
1716 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_oob: " | 1735 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_oob: " |
1717 | "Attempt to write past end of page\n"); | 1736 | "Attempt to write past end of page\n"); |
1718 | return -EINVAL; | 1737 | return -EINVAL; |
@@ -1748,7 +1767,7 @@ static int nand_do_write_oob(struct mtd_info *mtd, loff_t to, | |||
1748 | if (status) | 1767 | if (status) |
1749 | return status; | 1768 | return status; |
1750 | 1769 | ||
1751 | ops->retlen = ops->len; | 1770 | ops->oobretlen = ops->ooblen; |
1752 | 1771 | ||
1753 | return 0; | 1772 | return 0; |
1754 | } | 1773 | } |
@@ -1768,7 +1787,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, | |||
1768 | ops->retlen = 0; | 1787 | ops->retlen = 0; |
1769 | 1788 | ||
1770 | /* Do not allow writes past end of device */ | 1789 | /* Do not allow writes past end of device */ |
1771 | if ((to + ops->len) > mtd->size) { | 1790 | if (ops->datbuf && (to + ops->len) > mtd->size) { |
1772 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_oob: " | 1791 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_oob: " |
1773 | "Attempt read beyond end of device\n"); | 1792 | "Attempt read beyond end of device\n"); |
1774 | return -EINVAL; | 1793 | return -EINVAL; |
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index 9402653eb09b..5e121ceaa598 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
@@ -333,7 +333,6 @@ static int scan_block_fast(struct mtd_info *mtd, struct nand_bbt_descr *bd, | |||
333 | struct mtd_oob_ops ops; | 333 | struct mtd_oob_ops ops; |
334 | int j, ret; | 334 | int j, ret; |
335 | 335 | ||
336 | ops.len = mtd->oobsize; | ||
337 | ops.ooblen = mtd->oobsize; | 336 | ops.ooblen = mtd->oobsize; |
338 | ops.oobbuf = buf; | 337 | ops.oobbuf = buf; |
339 | ops.ooboffs = 0; | 338 | ops.ooboffs = 0; |
@@ -676,10 +675,10 @@ static int write_bbt(struct mtd_info *mtd, uint8_t *buf, | |||
676 | "bad block table\n"); | 675 | "bad block table\n"); |
677 | } | 676 | } |
678 | /* Read oob data */ | 677 | /* Read oob data */ |
679 | ops.len = (len >> this->page_shift) * mtd->oobsize; | 678 | ops.ooblen = (len >> this->page_shift) * mtd->oobsize; |
680 | ops.oobbuf = &buf[len]; | 679 | ops.oobbuf = &buf[len]; |
681 | res = mtd->read_oob(mtd, to + mtd->writesize, &ops); | 680 | res = mtd->read_oob(mtd, to + mtd->writesize, &ops); |
682 | if (res < 0 || ops.retlen != ops.len) | 681 | if (res < 0 || ops.oobretlen != ops.ooblen) |
683 | goto outerr; | 682 | goto outerr; |
684 | 683 | ||
685 | /* Calc the byte offset in the buffer */ | 684 | /* Calc the byte offset in the buffer */ |
@@ -961,14 +960,12 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) | |||
961 | struct nand_bbt_descr *md = this->bbt_md; | 960 | struct nand_bbt_descr *md = this->bbt_md; |
962 | 961 | ||
963 | len = mtd->size >> (this->bbt_erase_shift + 2); | 962 | len = mtd->size >> (this->bbt_erase_shift + 2); |
964 | /* Allocate memory (2bit per block) */ | 963 | /* Allocate memory (2bit per block) and clear the memory bad block table */ |
965 | this->bbt = kmalloc(len, GFP_KERNEL); | 964 | this->bbt = kzalloc(len, GFP_KERNEL); |
966 | if (!this->bbt) { | 965 | if (!this->bbt) { |
967 | printk(KERN_ERR "nand_scan_bbt: Out of memory\n"); | 966 | printk(KERN_ERR "nand_scan_bbt: Out of memory\n"); |
968 | return -ENOMEM; | 967 | return -ENOMEM; |
969 | } | 968 | } |
970 | /* Clear the memory bad block table */ | ||
971 | memset(this->bbt, 0x00, len); | ||
972 | 969 | ||
973 | /* If no primary table decriptor is given, scan the device | 970 | /* If no primary table decriptor is given, scan the device |
974 | * to build a memory based bad block table | 971 | * to build a memory based bad block table |
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index abebcab47631..3d39451ae8f5 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
@@ -1511,14 +1511,12 @@ static int __init ns_init_module(void) | |||
1511 | } | 1511 | } |
1512 | 1512 | ||
1513 | /* Allocate and initialize mtd_info, nand_chip and nandsim structures */ | 1513 | /* Allocate and initialize mtd_info, nand_chip and nandsim structures */ |
1514 | nsmtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip) | 1514 | nsmtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip) |
1515 | + sizeof(struct nandsim), GFP_KERNEL); | 1515 | + sizeof(struct nandsim), GFP_KERNEL); |
1516 | if (!nsmtd) { | 1516 | if (!nsmtd) { |
1517 | NS_ERR("unable to allocate core structures.\n"); | 1517 | NS_ERR("unable to allocate core structures.\n"); |
1518 | return -ENOMEM; | 1518 | return -ENOMEM; |
1519 | } | 1519 | } |
1520 | memset(nsmtd, 0, sizeof(struct mtd_info) + sizeof(struct nand_chip) + | ||
1521 | sizeof(struct nandsim)); | ||
1522 | chip = (struct nand_chip *)(nsmtd + 1); | 1520 | chip = (struct nand_chip *)(nsmtd + 1); |
1523 | nsmtd->priv = (void *)chip; | 1521 | nsmtd->priv = (void *)chip; |
1524 | nand = (struct nandsim *)(chip + 1); | 1522 | nand = (struct nandsim *)(chip + 1); |
diff --git a/drivers/mtd/nand/ndfc.c b/drivers/mtd/nand/ndfc.c index 039c759cfbfc..fd7a8d5ba29a 100644 --- a/drivers/mtd/nand/ndfc.c +++ b/drivers/mtd/nand/ndfc.c | |||
@@ -56,7 +56,7 @@ static void ndfc_select_chip(struct mtd_info *mtd, int chip) | |||
56 | ccr |= NDFC_CCR_BS(chip + pchip->chip_offset); | 56 | ccr |= NDFC_CCR_BS(chip + pchip->chip_offset); |
57 | } else | 57 | } else |
58 | ccr |= NDFC_CCR_RESET_CE; | 58 | ccr |= NDFC_CCR_RESET_CE; |
59 | writel(ccr, ndfc->ndfcbase + NDFC_CCR); | 59 | __raw_writel(ccr, ndfc->ndfcbase + NDFC_CCR); |
60 | } | 60 | } |
61 | 61 | ||
62 | static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) | 62 | static void ndfc_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl) |
diff --git a/drivers/mtd/nand/rtc_from4.c b/drivers/mtd/nand/rtc_from4.c index f8c49645324d..4a83a7dd58da 100644 --- a/drivers/mtd/nand/rtc_from4.c +++ b/drivers/mtd/nand/rtc_from4.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
25 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
26 | #include <linux/rslib.h> | 26 | #include <linux/rslib.h> |
27 | #include <linux/bitrev.h> | ||
27 | #include <linux/module.h> | 28 | #include <linux/module.h> |
28 | #include <linux/mtd/compatmac.h> | 29 | #include <linux/mtd/compatmac.h> |
29 | #include <linux/mtd/mtd.h> | 30 | #include <linux/mtd/mtd.h> |
@@ -152,47 +153,6 @@ static struct nand_ecclayout rtc_from4_nand_oobinfo = { | |||
152 | .oobfree = {{32, 32}} | 153 | .oobfree = {{32, 32}} |
153 | }; | 154 | }; |
154 | 155 | ||
155 | /* Aargh. I missed the reversed bit order, when I | ||
156 | * was talking to Renesas about the FPGA. | ||
157 | * | ||
158 | * The table is used for bit reordering and inversion | ||
159 | * of the ecc byte which we get from the FPGA | ||
160 | */ | ||
161 | static uint8_t revbits[256] = { | ||
162 | 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, | ||
163 | 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, | ||
164 | 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, | ||
165 | 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, | ||
166 | 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, | ||
167 | 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, | ||
168 | 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, | ||
169 | 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, | ||
170 | 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, | ||
171 | 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, | ||
172 | 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, | ||
173 | 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, | ||
174 | 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, | ||
175 | 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, | ||
176 | 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, | ||
177 | 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, | ||
178 | 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, | ||
179 | 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, | ||
180 | 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, | ||
181 | 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, | ||
182 | 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, | ||
183 | 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, | ||
184 | 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, | ||
185 | 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, | ||
186 | 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, | ||
187 | 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, | ||
188 | 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, | ||
189 | 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, | ||
190 | 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, | ||
191 | 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, | ||
192 | 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, | ||
193 | 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, | ||
194 | }; | ||
195 | |||
196 | #endif | 156 | #endif |
197 | 157 | ||
198 | /* | 158 | /* |
@@ -397,7 +357,7 @@ static int rtc_from4_correct_data(struct mtd_info *mtd, const u_char *buf, u_cha | |||
397 | /* Read the syndrom pattern from the FPGA and correct the bitorder */ | 357 | /* Read the syndrom pattern from the FPGA and correct the bitorder */ |
398 | rs_ecc = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC); | 358 | rs_ecc = (volatile unsigned short *)(rtc_from4_fio_base + RTC_FROM4_RS_ECC); |
399 | for (i = 0; i < 8; i++) { | 359 | for (i = 0; i < 8; i++) { |
400 | ecc[i] = revbits[(*rs_ecc) & 0xFF]; | 360 | ecc[i] = byte_rev_table[(*rs_ecc) & 0xFF]; |
401 | rs_ecc++; | 361 | rs_ecc++; |
402 | } | 362 | } |
403 | 363 | ||
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c index b5a5f8da4722..4b1ba4fcfcd3 100644 --- a/drivers/mtd/nftlcore.c +++ b/drivers/mtd/nftlcore.c | |||
@@ -57,17 +57,16 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
57 | 57 | ||
58 | DEBUG(MTD_DEBUG_LEVEL1, "NFTL: add_mtd for %s\n", mtd->name); | 58 | DEBUG(MTD_DEBUG_LEVEL1, "NFTL: add_mtd for %s\n", mtd->name); |
59 | 59 | ||
60 | nftl = kmalloc(sizeof(struct NFTLrecord), GFP_KERNEL); | 60 | nftl = kzalloc(sizeof(struct NFTLrecord), GFP_KERNEL); |
61 | 61 | ||
62 | if (!nftl) { | 62 | if (!nftl) { |
63 | printk(KERN_WARNING "NFTL: out of memory for data structures\n"); | 63 | printk(KERN_WARNING "NFTL: out of memory for data structures\n"); |
64 | return; | 64 | return; |
65 | } | 65 | } |
66 | memset(nftl, 0, sizeof(*nftl)); | ||
67 | 66 | ||
68 | nftl->mbd.mtd = mtd; | 67 | nftl->mbd.mtd = mtd; |
69 | nftl->mbd.devnum = -1; | 68 | nftl->mbd.devnum = -1; |
70 | nftl->mbd.blksize = 512; | 69 | |
71 | nftl->mbd.tr = tr; | 70 | nftl->mbd.tr = tr; |
72 | 71 | ||
73 | if (NFTL_mount(nftl) < 0) { | 72 | if (NFTL_mount(nftl) < 0) { |
@@ -147,10 +146,9 @@ int nftl_read_oob(struct mtd_info *mtd, loff_t offs, size_t len, | |||
147 | ops.ooblen = len; | 146 | ops.ooblen = len; |
148 | ops.oobbuf = buf; | 147 | ops.oobbuf = buf; |
149 | ops.datbuf = NULL; | 148 | ops.datbuf = NULL; |
150 | ops.len = len; | ||
151 | 149 | ||
152 | res = mtd->read_oob(mtd, offs & ~(mtd->writesize - 1), &ops); | 150 | res = mtd->read_oob(mtd, offs & ~(mtd->writesize - 1), &ops); |
153 | *retlen = ops.retlen; | 151 | *retlen = ops.oobretlen; |
154 | return res; | 152 | return res; |
155 | } | 153 | } |
156 | 154 | ||
@@ -168,10 +166,9 @@ int nftl_write_oob(struct mtd_info *mtd, loff_t offs, size_t len, | |||
168 | ops.ooblen = len; | 166 | ops.ooblen = len; |
169 | ops.oobbuf = buf; | 167 | ops.oobbuf = buf; |
170 | ops.datbuf = NULL; | 168 | ops.datbuf = NULL; |
171 | ops.len = len; | ||
172 | 169 | ||
173 | res = mtd->write_oob(mtd, offs & ~(mtd->writesize - 1), &ops); | 170 | res = mtd->write_oob(mtd, offs & ~(mtd->writesize - 1), &ops); |
174 | *retlen = ops.retlen; | 171 | *retlen = ops.oobretlen; |
175 | return res; | 172 | return res; |
176 | } | 173 | } |
177 | 174 | ||
@@ -797,6 +794,7 @@ static struct mtd_blktrans_ops nftl_tr = { | |||
797 | .name = "nftl", | 794 | .name = "nftl", |
798 | .major = NFTL_MAJOR, | 795 | .major = NFTL_MAJOR, |
799 | .part_bits = NFTL_PARTN_BITS, | 796 | .part_bits = NFTL_PARTN_BITS, |
797 | .blksize = 512, | ||
800 | .getgeo = nftl_getgeo, | 798 | .getgeo = nftl_getgeo, |
801 | .readsect = nftl_readblock, | 799 | .readsect = nftl_readblock, |
802 | #ifdef CONFIG_NFTL_RW | 800 | #ifdef CONFIG_NFTL_RW |
diff --git a/drivers/mtd/onenand/generic.c b/drivers/mtd/onenand/generic.c index cdf80c68160f..3d44d040a47d 100644 --- a/drivers/mtd/onenand/generic.c +++ b/drivers/mtd/onenand/generic.c | |||
@@ -45,12 +45,10 @@ static int __devinit generic_onenand_probe(struct device *dev) | |||
45 | unsigned long size = res->end - res->start + 1; | 45 | unsigned long size = res->end - res->start + 1; |
46 | int err; | 46 | int err; |
47 | 47 | ||
48 | info = kmalloc(sizeof(struct onenand_info), GFP_KERNEL); | 48 | info = kzalloc(sizeof(struct onenand_info), GFP_KERNEL); |
49 | if (!info) | 49 | if (!info) |
50 | return -ENOMEM; | 50 | return -ENOMEM; |
51 | 51 | ||
52 | memset(info, 0, sizeof(struct onenand_info)); | ||
53 | |||
54 | if (!request_mem_region(res->start, size, dev->driver->name)) { | 52 | if (!request_mem_region(res->start, size, dev->driver->name)) { |
55 | err = -EBUSY; | 53 | err = -EBUSY; |
56 | goto out_free_info; | 54 | goto out_free_info; |
diff --git a/drivers/mtd/onenand/onenand_bbt.c b/drivers/mtd/onenand/onenand_bbt.c index c8067b8f20a6..6cceeca40567 100644 --- a/drivers/mtd/onenand/onenand_bbt.c +++ b/drivers/mtd/onenand/onenand_bbt.c | |||
@@ -178,14 +178,12 @@ int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) | |||
178 | int len, ret = 0; | 178 | int len, ret = 0; |
179 | 179 | ||
180 | len = mtd->size >> (this->erase_shift + 2); | 180 | len = mtd->size >> (this->erase_shift + 2); |
181 | /* Allocate memory (2bit per block) */ | 181 | /* Allocate memory (2bit per block) and clear the memory bad block table */ |
182 | bbm->bbt = kmalloc(len, GFP_KERNEL); | 182 | bbm->bbt = kzalloc(len, GFP_KERNEL); |
183 | if (!bbm->bbt) { | 183 | if (!bbm->bbt) { |
184 | printk(KERN_ERR "onenand_scan_bbt: Out of memory\n"); | 184 | printk(KERN_ERR "onenand_scan_bbt: Out of memory\n"); |
185 | return -ENOMEM; | 185 | return -ENOMEM; |
186 | } | 186 | } |
187 | /* Clear the memory bad block table */ | ||
188 | memset(bbm->bbt, 0x00, len); | ||
189 | 187 | ||
190 | /* Set the bad block position */ | 188 | /* Set the bad block position */ |
191 | bbm->badblockpos = ONENAND_BADBLOCK_POS; | 189 | bbm->badblockpos = ONENAND_BADBLOCK_POS; |
@@ -231,14 +229,12 @@ int onenand_default_bbt(struct mtd_info *mtd) | |||
231 | struct onenand_chip *this = mtd->priv; | 229 | struct onenand_chip *this = mtd->priv; |
232 | struct bbm_info *bbm; | 230 | struct bbm_info *bbm; |
233 | 231 | ||
234 | this->bbm = kmalloc(sizeof(struct bbm_info), GFP_KERNEL); | 232 | this->bbm = kzalloc(sizeof(struct bbm_info), GFP_KERNEL); |
235 | if (!this->bbm) | 233 | if (!this->bbm) |
236 | return -ENOMEM; | 234 | return -ENOMEM; |
237 | 235 | ||
238 | bbm = this->bbm; | 236 | bbm = this->bbm; |
239 | 237 | ||
240 | memset(bbm, 0, sizeof(struct bbm_info)); | ||
241 | |||
242 | /* 1KB page has same configuration as 2KB page */ | 238 | /* 1KB page has same configuration as 2KB page */ |
243 | if (!bbm->badblock_pattern) | 239 | if (!bbm->badblock_pattern) |
244 | bbm->badblock_pattern = &largepage_memorybased; | 240 | bbm->badblock_pattern = &largepage_memorybased; |
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c index 5b58523e4d4e..4b277211e27b 100644 --- a/drivers/mtd/redboot.c +++ b/drivers/mtd/redboot.c | |||
@@ -165,15 +165,13 @@ static int parse_redboot_partitions(struct mtd_info *master, | |||
165 | } | 165 | } |
166 | } | 166 | } |
167 | #endif | 167 | #endif |
168 | parts = kmalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL); | 168 | parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL); |
169 | 169 | ||
170 | if (!parts) { | 170 | if (!parts) { |
171 | ret = -ENOMEM; | 171 | ret = -ENOMEM; |
172 | goto out; | 172 | goto out; |
173 | } | 173 | } |
174 | 174 | ||
175 | memset(parts, 0, sizeof(*parts)*nrparts + nulllen + namelen); | ||
176 | |||
177 | nullname = (char *)&parts[nrparts]; | 175 | nullname = (char *)&parts[nrparts]; |
178 | #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED | 176 | #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED |
179 | if (nulllen > 0) { | 177 | if (nulllen > 0) { |
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index fa4362fb4dd8..d60cc6696cbd 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c | |||
@@ -787,7 +787,6 @@ static void rfd_ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
787 | 787 | ||
788 | if (scan_header(part) == 0) { | 788 | if (scan_header(part) == 0) { |
789 | part->mbd.size = part->sector_count; | 789 | part->mbd.size = part->sector_count; |
790 | part->mbd.blksize = SECTOR_SIZE; | ||
791 | part->mbd.tr = tr; | 790 | part->mbd.tr = tr; |
792 | part->mbd.devnum = -1; | 791 | part->mbd.devnum = -1; |
793 | if (!(mtd->flags & MTD_WRITEABLE)) | 792 | if (!(mtd->flags & MTD_WRITEABLE)) |
@@ -829,6 +828,8 @@ struct mtd_blktrans_ops rfd_ftl_tr = { | |||
829 | .name = "rfd", | 828 | .name = "rfd", |
830 | .major = RFD_FTL_MAJOR, | 829 | .major = RFD_FTL_MAJOR, |
831 | .part_bits = PART_BITS, | 830 | .part_bits = PART_BITS, |
831 | .blksize = SECTOR_SIZE, | ||
832 | |||
832 | .readsect = rfd_ftl_readsect, | 833 | .readsect = rfd_ftl_readsect, |
833 | .writesect = rfd_ftl_writesect, | 834 | .writesect = rfd_ftl_writesect, |
834 | .getgeo = rfd_ftl_getgeo, | 835 | .getgeo = rfd_ftl_getgeo, |
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c index 79d3bb659bfe..e834cc16c9f9 100644 --- a/drivers/mtd/ssfdc.c +++ b/drivers/mtd/ssfdc.c | |||
@@ -172,13 +172,12 @@ static int read_raw_oob(struct mtd_info *mtd, loff_t offs, uint8_t *buf) | |||
172 | 172 | ||
173 | ops.mode = MTD_OOB_RAW; | 173 | ops.mode = MTD_OOB_RAW; |
174 | ops.ooboffs = 0; | 174 | ops.ooboffs = 0; |
175 | ops.ooblen = mtd->oobsize; | 175 | ops.ooblen = OOB_SIZE; |
176 | ops.len = OOB_SIZE; | ||
177 | ops.oobbuf = buf; | 176 | ops.oobbuf = buf; |
178 | ops.datbuf = NULL; | 177 | ops.datbuf = NULL; |
179 | 178 | ||
180 | ret = mtd->read_oob(mtd, offs, &ops); | 179 | ret = mtd->read_oob(mtd, offs, &ops); |
181 | if (ret < 0 || ops.retlen != OOB_SIZE) | 180 | if (ret < 0 || ops.oobretlen != OOB_SIZE) |
182 | return -1; | 181 | return -1; |
183 | 182 | ||
184 | return 0; | 183 | return 0; |
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index b9b700730dfe..dcb18e9a646e 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
@@ -968,8 +968,7 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c, | |||
968 | int oobsize = c->mtd->oobsize; | 968 | int oobsize = c->mtd->oobsize; |
969 | struct mtd_oob_ops ops; | 969 | struct mtd_oob_ops ops; |
970 | 970 | ||
971 | ops.len = NR_OOB_SCAN_PAGES * oobsize; | 971 | ops.ooblen = NR_OOB_SCAN_PAGES * oobsize; |
972 | ops.ooblen = oobsize; | ||
973 | ops.oobbuf = c->oobbuf; | 972 | ops.oobbuf = c->oobbuf; |
974 | ops.ooboffs = 0; | 973 | ops.ooboffs = 0; |
975 | ops.datbuf = NULL; | 974 | ops.datbuf = NULL; |
@@ -982,10 +981,10 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c, | |||
982 | return ret; | 981 | return ret; |
983 | } | 982 | } |
984 | 983 | ||
985 | if (ops.retlen < ops.len) { | 984 | if (ops.oobretlen < ops.ooblen) { |
986 | D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB " | 985 | D1(printk(KERN_WARNING "jffs2_check_oob_empty(): Read OOB " |
987 | "returned short read (%zd bytes not %d) for block " | 986 | "returned short read (%zd bytes not %d) for block " |
988 | "at %08x\n", ops.retlen, ops.len, jeb->offset)); | 987 | "at %08x\n", ops.oobretlen, ops.ooblen, jeb->offset)); |
989 | return -EIO; | 988 | return -EIO; |
990 | } | 989 | } |
991 | 990 | ||
@@ -1004,7 +1003,7 @@ int jffs2_check_oob_empty(struct jffs2_sb_info *c, | |||
1004 | } | 1003 | } |
1005 | 1004 | ||
1006 | /* we know, we are aligned :) */ | 1005 | /* we know, we are aligned :) */ |
1007 | for (page = oobsize; page < ops.len; page += sizeof(long)) { | 1006 | for (page = oobsize; page < ops.ooblen; page += sizeof(long)) { |
1008 | long dat = *(long *)(&ops.oobbuf[page]); | 1007 | long dat = *(long *)(&ops.oobbuf[page]); |
1009 | if(dat != -1) | 1008 | if(dat != -1) |
1010 | return 1; | 1009 | return 1; |
@@ -1032,7 +1031,6 @@ int jffs2_check_nand_cleanmarker (struct jffs2_sb_info *c, | |||
1032 | return 2; | 1031 | return 2; |
1033 | } | 1032 | } |
1034 | 1033 | ||
1035 | ops.len = oobsize; | ||
1036 | ops.ooblen = oobsize; | 1034 | ops.ooblen = oobsize; |
1037 | ops.oobbuf = c->oobbuf; | 1035 | ops.oobbuf = c->oobbuf; |
1038 | ops.ooboffs = 0; | 1036 | ops.ooboffs = 0; |
@@ -1047,10 +1045,10 @@ int jffs2_check_nand_cleanmarker (struct jffs2_sb_info *c, | |||
1047 | return ret; | 1045 | return ret; |
1048 | } | 1046 | } |
1049 | 1047 | ||
1050 | if (ops.retlen < ops.len) { | 1048 | if (ops.oobretlen < ops.ooblen) { |
1051 | D1 (printk (KERN_WARNING "jffs2_check_nand_cleanmarker(): " | 1049 | D1 (printk (KERN_WARNING "jffs2_check_nand_cleanmarker(): " |
1052 | "Read OOB return short read (%zd bytes not %d) " | 1050 | "Read OOB return short read (%zd bytes not %d) " |
1053 | "for block at %08x\n", ops.retlen, ops.len, | 1051 | "for block at %08x\n", ops.oobretlen, ops.ooblen, |
1054 | jeb->offset)); | 1052 | jeb->offset)); |
1055 | return -EIO; | 1053 | return -EIO; |
1056 | } | 1054 | } |
@@ -1089,8 +1087,7 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, | |||
1089 | n.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER); | 1087 | n.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER); |
1090 | n.totlen = cpu_to_je32(8); | 1088 | n.totlen = cpu_to_je32(8); |
1091 | 1089 | ||
1092 | ops.len = c->fsdata_len; | 1090 | ops.ooblen = c->fsdata_len; |
1093 | ops.ooblen = c->fsdata_len;; | ||
1094 | ops.oobbuf = (uint8_t *)&n; | 1091 | ops.oobbuf = (uint8_t *)&n; |
1095 | ops.ooboffs = c->fsdata_pos; | 1092 | ops.ooboffs = c->fsdata_pos; |
1096 | ops.datbuf = NULL; | 1093 | ops.datbuf = NULL; |
@@ -1104,10 +1101,10 @@ int jffs2_write_nand_cleanmarker(struct jffs2_sb_info *c, | |||
1104 | jeb->offset, ret)); | 1101 | jeb->offset, ret)); |
1105 | return ret; | 1102 | return ret; |
1106 | } | 1103 | } |
1107 | if (ops.retlen != ops.len) { | 1104 | if (ops.oobretlen != ops.ooblen) { |
1108 | D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): " | 1105 | D1(printk(KERN_WARNING "jffs2_write_nand_cleanmarker(): " |
1109 | "Short write for block at %08x: %zd not %d\n", | 1106 | "Short write for block at %08x: %zd not %d\n", |
1110 | jeb->offset, ops.retlen, ops.len)); | 1107 | jeb->offset, ops.oobretlen, ops.ooblen)); |
1111 | return -EIO; | 1108 | return -EIO; |
1112 | } | 1109 | } |
1113 | return 0; | 1110 | return 0; |
diff --git a/include/linux/mtd/blktrans.h b/include/linux/mtd/blktrans.h index 72fc68c5ee96..9a6e2f953cba 100644 --- a/include/linux/mtd/blktrans.h +++ b/include/linux/mtd/blktrans.h | |||
@@ -24,7 +24,6 @@ struct mtd_blktrans_dev { | |||
24 | struct mtd_info *mtd; | 24 | struct mtd_info *mtd; |
25 | struct mutex lock; | 25 | struct mutex lock; |
26 | int devnum; | 26 | int devnum; |
27 | int blksize; | ||
28 | unsigned long size; | 27 | unsigned long size; |
29 | int readonly; | 28 | int readonly; |
30 | void *blkcore_priv; /* gendisk in 2.5, devfs_handle in 2.4 */ | 29 | void *blkcore_priv; /* gendisk in 2.5, devfs_handle in 2.4 */ |
@@ -36,6 +35,8 @@ struct mtd_blktrans_ops { | |||
36 | char *name; | 35 | char *name; |
37 | int major; | 36 | int major; |
38 | int part_bits; | 37 | int part_bits; |
38 | int blksize; | ||
39 | int blkshift; | ||
39 | 40 | ||
40 | /* Access functions */ | 41 | /* Access functions */ |
41 | int (*readsect)(struct mtd_blktrans_dev *dev, | 42 | int (*readsect)(struct mtd_blktrans_dev *dev, |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 94a443d45258..4fc391ec9d01 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
@@ -75,15 +75,12 @@ typedef enum { | |||
75 | * struct mtd_oob_ops - oob operation operands | 75 | * struct mtd_oob_ops - oob operation operands |
76 | * @mode: operation mode | 76 | * @mode: operation mode |
77 | * | 77 | * |
78 | * @len: number of bytes to write/read. When a data buffer is given | 78 | * @len: number of data bytes to write/read |
79 | * (datbuf != NULL) this is the number of data bytes. When | ||
80 | * no data buffer is available this is the number of oob bytes. | ||
81 | * | 79 | * |
82 | * @retlen: number of bytes written/read. When a data buffer is given | 80 | * @retlen: number of data bytes written/read |
83 | * (datbuf != NULL) this is the number of data bytes. When | ||
84 | * no data buffer is available this is the number of oob bytes. | ||
85 | * | 81 | * |
86 | * @ooblen: number of oob bytes per page | 82 | * @ooblen: number of oob bytes to write/read |
83 | * @oobretlen: number of oob bytes written/read | ||
87 | * @ooboffs: offset of oob data in the oob area (only relevant when | 84 | * @ooboffs: offset of oob data in the oob area (only relevant when |
88 | * mode = MTD_OOB_PLACE) | 85 | * mode = MTD_OOB_PLACE) |
89 | * @datbuf: data buffer - if NULL only oob data are read/written | 86 | * @datbuf: data buffer - if NULL only oob data are read/written |
@@ -94,6 +91,7 @@ struct mtd_oob_ops { | |||
94 | size_t len; | 91 | size_t len; |
95 | size_t retlen; | 92 | size_t retlen; |
96 | size_t ooblen; | 93 | size_t ooblen; |
94 | size_t oobretlen; | ||
97 | uint32_t ooboffs; | 95 | uint32_t ooboffs; |
98 | uint8_t *datbuf; | 96 | uint8_t *datbuf; |
99 | uint8_t *oobbuf; | 97 | uint8_t *oobbuf; |