aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorDave Airlie <airlied@starflyer.(none)>2006-01-03 02:18:01 -0500
committerDave Airlie <airlied@linux.ie>2006-01-03 02:18:01 -0500
commit97f2aab6698f3ab2552c41c1024a65ffd0763a6d (patch)
treebb6e3b2949459f54f884c710fc74d40eef00d834 /drivers/mtd
parentd985c1088146607532093d9eaaaf99758f6a4d21 (diff)
parent88026842b0a760145aa71d69e74fbc9ec118ca44 (diff)
drm: merge in Linus mainline
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c10
-rw-r--r--drivers/mtd/chips/cfi_probe.c8
-rw-r--r--drivers/mtd/chips/sharp.c123
-rw-r--r--drivers/mtd/devices/blkmtd.c8
-rw-r--r--drivers/mtd/devices/block2mtd.c6
-rw-r--r--drivers/mtd/devices/ms02-nv.c6
-rw-r--r--drivers/mtd/ftl.c6
-rw-r--r--drivers/mtd/maps/Kconfig10
-rw-r--r--drivers/mtd/maps/Makefile1
-rw-r--r--drivers/mtd/maps/bast-flash.c33
-rw-r--r--drivers/mtd/maps/integrator-flash.c23
-rw-r--r--drivers/mtd/maps/ipaq-flash.c6
-rw-r--r--drivers/mtd/maps/ixp2000.c47
-rw-r--r--drivers/mtd/maps/ixp4xx.c103
-rw-r--r--drivers/mtd/maps/nettel.c4
-rw-r--r--drivers/mtd/maps/omap_nor.c23
-rw-r--r--drivers/mtd/maps/pci.c4
-rw-r--r--drivers/mtd/maps/physmap.c3
-rw-r--r--drivers/mtd/maps/plat-ram.c68
-rw-r--r--drivers/mtd/maps/sa1100-flash.c36
-rw-r--r--drivers/mtd/maps/sc520cdp.c4
-rw-r--r--drivers/mtd/nand/h1910.c2
-rw-r--r--drivers/mtd/nand/nandsim.c2
-rw-r--r--drivers/mtd/nand/s3c2410.c77
-rw-r--r--drivers/mtd/onenand/generic.c4
-rw-r--r--drivers/mtd/onenand/onenand_base.c53
-rw-r--r--drivers/mtd/onenand/onenand_bbt.c4
-rw-r--r--drivers/mtd/rfd_ftl.c6
28 files changed, 376 insertions, 304 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 143f01a4c170..69c04945591f 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * (C) 2000 Red Hat. GPL'd 5 * (C) 2000 Red Hat. GPL'd
6 * 6 *
7 * $Id: cfi_cmdset_0001.c,v 1.185 2005/11/07 11:14:22 gleixner Exp $ 7 * $Id: cfi_cmdset_0001.c,v 1.186 2005/11/23 22:07:52 nico Exp $
8 * 8 *
9 * 9 *
10 * 10/10/2000 Nicolas Pitre <nico@cam.org> 10 * 10/10/2000 Nicolas Pitre <nico@cam.org>
@@ -644,9 +644,8 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
644 * 644 *
645 * - contension arbitration is handled in the owner's context. 645 * - contension arbitration is handled in the owner's context.
646 * 646 *
647 * The 'shared' struct can be read when its lock is taken. 647 * The 'shared' struct can be read and/or written only when
648 * However any writes to it can only be made when the current 648 * its lock is taken.
649 * owner's lock is also held.
650 */ 649 */
651 struct flchip_shared *shared = chip->priv; 650 struct flchip_shared *shared = chip->priv;
652 struct flchip *contender; 651 struct flchip *contender;
@@ -675,14 +674,13 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
675 } 674 }
676 timeo = jiffies + HZ; 675 timeo = jiffies + HZ;
677 spin_lock(&shared->lock); 676 spin_lock(&shared->lock);
677 spin_unlock(contender->mutex);
678 } 678 }
679 679
680 /* We now own it */ 680 /* We now own it */
681 shared->writing = chip; 681 shared->writing = chip;
682 if (mode == FL_ERASING) 682 if (mode == FL_ERASING)
683 shared->erasing = chip; 683 shared->erasing = chip;
684 if (contender && contender != chip)
685 spin_unlock(contender->mutex);
686 spin_unlock(&shared->lock); 684 spin_unlock(&shared->lock);
687 } 685 }
688 686
diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c
index 90eb30e06b7c..e636aa86bc24 100644
--- a/drivers/mtd/chips/cfi_probe.c
+++ b/drivers/mtd/chips/cfi_probe.c
@@ -1,7 +1,7 @@
1/* 1/*
2 Common Flash Interface probe code. 2 Common Flash Interface probe code.
3 (C) 2000 Red Hat. GPL'd. 3 (C) 2000 Red Hat. GPL'd.
4 $Id: cfi_probe.c,v 1.84 2005/11/07 11:14:23 gleixner Exp $ 4 $Id: cfi_probe.c,v 1.86 2005/11/29 14:48:31 gleixner Exp $
5*/ 5*/
6 6
7#include <linux/config.h> 7#include <linux/config.h>
@@ -230,8 +230,8 @@ static int __xipram cfi_chip_setup(struct map_info *map,
230 cfi_send_gen_cmd(0xaa, 0x555, base, map, cfi, cfi->device_type, NULL); 230 cfi_send_gen_cmd(0xaa, 0x555, base, map, cfi, cfi->device_type, NULL);
231 cfi_send_gen_cmd(0x55, 0x2aa, base, map, cfi, cfi->device_type, NULL); 231 cfi_send_gen_cmd(0x55, 0x2aa, base, map, cfi, cfi->device_type, NULL);
232 cfi_send_gen_cmd(0x90, 0x555, base, map, cfi, cfi->device_type, NULL); 232 cfi_send_gen_cmd(0x90, 0x555, base, map, cfi, cfi->device_type, NULL);
233 cfi->mfr = cfi_read_query(map, base); 233 cfi->mfr = cfi_read_query16(map, base);
234 cfi->id = cfi_read_query(map, base + ofs_factor); 234 cfi->id = cfi_read_query16(map, base + ofs_factor);
235 235
236 /* Put it back into Read Mode */ 236 /* Put it back into Read Mode */
237 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); 237 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
@@ -426,7 +426,7 @@ static struct mtd_chip_driver cfi_chipdrv = {
426 .module = THIS_MODULE 426 .module = THIS_MODULE
427}; 427};
428 428
429int __init cfi_probe_init(void) 429static int __init cfi_probe_init(void)
430{ 430{
431 register_mtd_chip_driver(&cfi_chipdrv); 431 register_mtd_chip_driver(&cfi_chipdrv);
432 return 0; 432 return 0;
diff --git a/drivers/mtd/chips/sharp.c b/drivers/mtd/chips/sharp.c
index 2d26bdef82d5..36f61a6a766e 100644
--- a/drivers/mtd/chips/sharp.c
+++ b/drivers/mtd/chips/sharp.c
@@ -4,7 +4,7 @@
4 * Copyright 2000,2001 David A. Schleef <ds@schleef.org> 4 * Copyright 2000,2001 David A. Schleef <ds@schleef.org>
5 * 2000,2001 Lineo, Inc. 5 * 2000,2001 Lineo, Inc.
6 * 6 *
7 * $Id: sharp.c,v 1.16 2005/11/07 11:14:23 gleixner Exp $ 7 * $Id: sharp.c,v 1.17 2005/11/29 14:28:28 gleixner Exp $
8 * 8 *
9 * Devices supported: 9 * Devices supported:
10 * LH28F016SCT Symmetrical block flash memory, 2Mx8 10 * LH28F016SCT Symmetrical block flash memory, 2Mx8
@@ -160,22 +160,28 @@ struct mtd_info *sharp_probe(struct map_info *map)
160 return mtd; 160 return mtd;
161} 161}
162 162
163static inline void sharp_send_cmd(struct map_info *map, unsigned long cmd, unsigned long adr)
164{
165 map_word map_cmd;
166 map_cmd.x[0] = cmd;
167 map_write(map, map_cmd, adr);
168}
169
163static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd) 170static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd)
164{ 171{
165 unsigned long tmp; 172 map_word tmp, read0, read4;
166 unsigned long base = 0; 173 unsigned long base = 0;
167 u32 read0, read4;
168 int width = 4; 174 int width = 4;
169 175
170 tmp = map_read32(map, base+0); 176 tmp = map_read(map, base+0);
171 177
172 map_write32(map, CMD_READ_ID, base+0); 178 sharp_send_cmd(map, CMD_READ_ID, base+0);
173 179
174 read0=map_read32(map, base+0); 180 read0 = map_read(map, base+0);
175 read4=map_read32(map, base+4); 181 read4 = map_read(map, base+4);
176 if(read0 == 0x89898989){ 182 if(read0.x[0] == 0x89898989){
177 printk("Looks like sharp flash\n"); 183 printk("Looks like sharp flash\n");
178 switch(read4){ 184 switch(read4.x[0]){
179 case 0xaaaaaaaa: 185 case 0xaaaaaaaa:
180 case 0xa0a0a0a0: 186 case 0xa0a0a0a0:
181 /* aa - LH28F016SCT-L95 2Mx8, 32 64k blocks*/ 187 /* aa - LH28F016SCT-L95 2Mx8, 32 64k blocks*/
@@ -197,16 +203,16 @@ static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd)
197 return width; 203 return width;
198#endif 204#endif
199 default: 205 default:
200 printk("Sort-of looks like sharp flash, 0x%08x 0x%08x\n", 206 printk("Sort-of looks like sharp flash, 0x%08lx 0x%08lx\n",
201 read0,read4); 207 read0.x[0], read4.x[0]);
202 } 208 }
203 }else if((map_read32(map, base+0) == CMD_READ_ID)){ 209 }else if((map_read(map, base+0).x[0] == CMD_READ_ID)){
204 /* RAM, probably */ 210 /* RAM, probably */
205 printk("Looks like RAM\n"); 211 printk("Looks like RAM\n");
206 map_write32(map, tmp, base+0); 212 map_write(map, tmp, base+0);
207 }else{ 213 }else{
208 printk("Doesn't look like sharp flash, 0x%08x 0x%08x\n", 214 printk("Doesn't look like sharp flash, 0x%08lx 0x%08lx\n",
209 read0,read4); 215 read0.x[0], read4.x[0]);
210 } 216 }
211 217
212 return 0; 218 return 0;
@@ -215,7 +221,8 @@ static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd)
215/* This function returns with the chip->mutex lock held. */ 221/* This function returns with the chip->mutex lock held. */
216static int sharp_wait(struct map_info *map, struct flchip *chip) 222static int sharp_wait(struct map_info *map, struct flchip *chip)
217{ 223{
218 int status, i; 224 int i;
225 map_word status;
219 unsigned long timeo = jiffies + HZ; 226 unsigned long timeo = jiffies + HZ;
220 DECLARE_WAITQUEUE(wait, current); 227 DECLARE_WAITQUEUE(wait, current);
221 int adr = 0; 228 int adr = 0;
@@ -225,12 +232,12 @@ retry:
225 232
226 switch(chip->state){ 233 switch(chip->state){
227 case FL_READY: 234 case FL_READY:
228 map_write32(map,CMD_READ_STATUS,adr); 235 sharp_send_cmd(map, CMD_READ_STATUS, adr);
229 chip->state = FL_STATUS; 236 chip->state = FL_STATUS;
230 case FL_STATUS: 237 case FL_STATUS:
231 for(i=0;i<100;i++){ 238 for(i=0;i<100;i++){
232 status = map_read32(map,adr); 239 status = map_read(map, adr);
233 if((status & SR_READY)==SR_READY) 240 if((status.x[0] & SR_READY)==SR_READY)
234 break; 241 break;
235 udelay(1); 242 udelay(1);
236 } 243 }
@@ -254,7 +261,7 @@ retry:
254 goto retry; 261 goto retry;
255 } 262 }
256 263
257 map_write32(map,CMD_RESET, adr); 264 sharp_send_cmd(map, CMD_RESET, adr);
258 265
259 chip->state = FL_READY; 266 chip->state = FL_READY;
260 267
@@ -351,37 +358,39 @@ static int sharp_write_oneword(struct map_info *map, struct flchip *chip,
351 int timeo; 358 int timeo;
352 int try; 359 int try;
353 int i; 360 int i;
354 int status = 0; 361 map_word data, status;
355 362
363 status.x[0] = 0;
356 ret = sharp_wait(map,chip); 364 ret = sharp_wait(map,chip);
357 365
358 for(try=0;try<10;try++){ 366 for(try=0;try<10;try++){
359 map_write32(map,CMD_BYTE_WRITE,adr); 367 sharp_send_cmd(map, CMD_BYTE_WRITE, adr);
360 /* cpu_to_le32 -> hack to fix the writel be->le conversion */ 368 /* cpu_to_le32 -> hack to fix the writel be->le conversion */
361 map_write32(map,cpu_to_le32(datum),adr); 369 data.x[0] = cpu_to_le32(datum);
370 map_write(map, data, adr);
362 371
363 chip->state = FL_WRITING; 372 chip->state = FL_WRITING;
364 373
365 timeo = jiffies + (HZ/2); 374 timeo = jiffies + (HZ/2);
366 375
367 map_write32(map,CMD_READ_STATUS,adr); 376 sharp_send_cmd(map, CMD_READ_STATUS, adr);
368 for(i=0;i<100;i++){ 377 for(i=0;i<100;i++){
369 status = map_read32(map,adr); 378 status = map_read(map, adr);
370 if((status & SR_READY)==SR_READY) 379 if((status.x[0] & SR_READY) == SR_READY)
371 break; 380 break;
372 } 381 }
373 if(i==100){ 382 if(i==100){
374 printk("sharp: timed out writing\n"); 383 printk("sharp: timed out writing\n");
375 } 384 }
376 385
377 if(!(status&SR_ERRORS)) 386 if(!(status.x[0] & SR_ERRORS))
378 break; 387 break;
379 388
380 printk("sharp: error writing byte at addr=%08lx status=%08x\n",adr,status); 389 printk("sharp: error writing byte at addr=%08lx status=%08lx\n", adr, status.x[0]);
381 390
382 map_write32(map,CMD_CLEAR_STATUS,adr); 391 sharp_send_cmd(map, CMD_CLEAR_STATUS, adr);
383 } 392 }
384 map_write32(map,CMD_RESET,adr); 393 sharp_send_cmd(map, CMD_RESET, adr);
385 chip->state = FL_READY; 394 chip->state = FL_READY;
386 395
387 wake_up(&chip->wq); 396 wake_up(&chip->wq);
@@ -434,18 +443,18 @@ static int sharp_do_wait_for_ready(struct map_info *map, struct flchip *chip,
434{ 443{
435 int ret; 444 int ret;
436 unsigned long timeo; 445 unsigned long timeo;
437 int status; 446 map_word status;
438 DECLARE_WAITQUEUE(wait, current); 447 DECLARE_WAITQUEUE(wait, current);
439 448
440 map_write32(map,CMD_READ_STATUS,adr); 449 sharp_send_cmd(map, CMD_READ_STATUS, adr);
441 status = map_read32(map,adr); 450 status = map_read(map, adr);
442 451
443 timeo = jiffies + HZ; 452 timeo = jiffies + HZ;
444 453
445 while(time_before(jiffies, timeo)){ 454 while(time_before(jiffies, timeo)){
446 map_write32(map,CMD_READ_STATUS,adr); 455 sharp_send_cmd(map, CMD_READ_STATUS, adr);
447 status = map_read32(map,adr); 456 status = map_read(map, adr);
448 if((status & SR_READY)==SR_READY){ 457 if((status.x[0] & SR_READY)==SR_READY){
449 ret = 0; 458 ret = 0;
450 goto out; 459 goto out;
451 } 460 }
@@ -476,7 +485,7 @@ static int sharp_erase_oneblock(struct map_info *map, struct flchip *chip,
476{ 485{
477 int ret; 486 int ret;
478 //int timeo; 487 //int timeo;
479 int status; 488 map_word status;
480 //int i; 489 //int i;
481 490
482//printk("sharp_erase_oneblock()\n"); 491//printk("sharp_erase_oneblock()\n");
@@ -486,26 +495,26 @@ static int sharp_erase_oneblock(struct map_info *map, struct flchip *chip,
486 sharp_unlock_oneblock(map,chip,adr); 495 sharp_unlock_oneblock(map,chip,adr);
487#endif 496#endif
488 497
489 map_write32(map,CMD_BLOCK_ERASE_1,adr); 498 sharp_send_cmd(map, CMD_BLOCK_ERASE_1, adr);
490 map_write32(map,CMD_BLOCK_ERASE_2,adr); 499 sharp_send_cmd(map, CMD_BLOCK_ERASE_2, adr);
491 500
492 chip->state = FL_ERASING; 501 chip->state = FL_ERASING;
493 502
494 ret = sharp_do_wait_for_ready(map,chip,adr); 503 ret = sharp_do_wait_for_ready(map,chip,adr);
495 if(ret<0)return ret; 504 if(ret<0)return ret;
496 505
497 map_write32(map,CMD_READ_STATUS,adr); 506 sharp_send_cmd(map, CMD_READ_STATUS, adr);
498 status = map_read32(map,adr); 507 status = map_read(map, adr);
499 508
500 if(!(status&SR_ERRORS)){ 509 if(!(status.x[0] & SR_ERRORS)){
501 map_write32(map,CMD_RESET,adr); 510 sharp_send_cmd(map, CMD_RESET, adr);
502 chip->state = FL_READY; 511 chip->state = FL_READY;
503 //spin_unlock_bh(chip->mutex); 512 //spin_unlock_bh(chip->mutex);
504 return 0; 513 return 0;
505 } 514 }
506 515
507 printk("sharp: error erasing block at addr=%08lx status=%08x\n",adr,status); 516 printk("sharp: error erasing block at addr=%08lx status=%08lx\n", adr, status.x[0]);
508 map_write32(map,CMD_CLEAR_STATUS,adr); 517 sharp_send_cmd(map, CMD_CLEAR_STATUS, adr);
509 518
510 //spin_unlock_bh(chip->mutex); 519 //spin_unlock_bh(chip->mutex);
511 520
@@ -517,20 +526,20 @@ static void sharp_unlock_oneblock(struct map_info *map, struct flchip *chip,
517 unsigned long adr) 526 unsigned long adr)
518{ 527{
519 int i; 528 int i;
520 int status; 529 map_word status;
521 530
522 map_write32(map,CMD_CLEAR_BLOCK_LOCKS_1,adr); 531 sharp_send_cmd(map, CMD_CLEAR_BLOCK_LOCKS_1, adr);
523 map_write32(map,CMD_CLEAR_BLOCK_LOCKS_2,adr); 532 sharp_send_cmd(map, CMD_CLEAR_BLOCK_LOCKS_2, adr);
524 533
525 udelay(100); 534 udelay(100);
526 535
527 status = map_read32(map,adr); 536 status = map_read(map, adr);
528 printk("status=%08x\n",status); 537 printk("status=%08lx\n", status.x[0]);
529 538
530 for(i=0;i<1000;i++){ 539 for(i=0;i<1000;i++){
531 //map_write32(map,CMD_READ_STATUS,adr); 540 //sharp_send_cmd(map, CMD_READ_STATUS, adr);
532 status = map_read32(map,adr); 541 status = map_read(map, adr);
533 if((status & SR_READY)==SR_READY) 542 if((status.x[0] & SR_READY) == SR_READY)
534 break; 543 break;
535 udelay(100); 544 udelay(100);
536 } 545 }
@@ -538,14 +547,14 @@ static void sharp_unlock_oneblock(struct map_info *map, struct flchip *chip,
538 printk("sharp: timed out unlocking block\n"); 547 printk("sharp: timed out unlocking block\n");
539 } 548 }
540 549
541 if(!(status&SR_ERRORS)){ 550 if(!(status.x[0] & SR_ERRORS)){
542 map_write32(map,CMD_RESET,adr); 551 sharp_send_cmd(map, CMD_RESET, adr);
543 chip->state = FL_READY; 552 chip->state = FL_READY;
544 return; 553 return;
545 } 554 }
546 555
547 printk("sharp: error unlocking block at addr=%08lx status=%08x\n",adr,status); 556 printk("sharp: error unlocking block at addr=%08lx status=%08lx\n", adr, status.x[0]);
548 map_write32(map,CMD_CLEAR_STATUS,adr); 557 sharp_send_cmd(map, CMD_CLEAR_STATUS, adr);
549} 558}
550#endif 559#endif
551 560
diff --git a/drivers/mtd/devices/blkmtd.c b/drivers/mtd/devices/blkmtd.c
index f9db52f6bf00..04f864d238db 100644
--- a/drivers/mtd/devices/blkmtd.c
+++ b/drivers/mtd/devices/blkmtd.c
@@ -113,7 +113,7 @@ static int bi_write_complete(struct bio *bio, unsigned int bytes_done, int error
113 ClearPageUptodate(page); 113 ClearPageUptodate(page);
114 SetPageError(page); 114 SetPageError(page);
115 } 115 }
116 ClearPageDirty(page); 116 clear_page_dirty(page);
117 unlock_page(page); 117 unlock_page(page);
118 page_cache_release(page); 118 page_cache_release(page);
119 } while (bvec >= bio->bi_io_vec); 119 } while (bvec >= bio->bi_io_vec);
@@ -289,7 +289,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to,
289 BUG(); 289 BUG();
290 } 290 }
291 memcpy(page_address(page)+offset, buf, start_len); 291 memcpy(page_address(page)+offset, buf, start_len);
292 SetPageDirty(page); 292 set_page_dirty(page);
293 SetPageUptodate(page); 293 SetPageUptodate(page);
294 buf += start_len; 294 buf += start_len;
295 thislen = start_len; 295 thislen = start_len;
@@ -336,7 +336,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to,
336 } 336 }
337 pagenr++; 337 pagenr++;
338 pagecnt--; 338 pagecnt--;
339 SetPageDirty(page); 339 set_page_dirty(page);
340 SetPageUptodate(page); 340 SetPageUptodate(page);
341 pagesc--; 341 pagesc--;
342 thislen += PAGE_SIZE; 342 thislen += PAGE_SIZE;
@@ -357,7 +357,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to,
357 BUG(); 357 BUG();
358 } 358 }
359 memcpy(page_address(page), buf, end_len); 359 memcpy(page_address(page), buf, end_len);
360 SetPageDirty(page); 360 set_page_dirty(page);
361 SetPageUptodate(page); 361 SetPageUptodate(page);
362 DEBUG(3, "blkmtd: write: writing out partial end\n"); 362 DEBUG(3, "blkmtd: write: writing out partial end\n");
363 thislen += end_len; 363 thislen += end_len;
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 0aaa0ced9aba..7ff403b2a0a0 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: block2mtd.c,v 1.29 2005/11/07 11:14:24 gleixner Exp $ 2 * $Id: block2mtd.c,v 1.30 2005/11/29 14:48:32 gleixner Exp $
3 * 3 *
4 * block2mtd.c - create an mtd from a block device 4 * block2mtd.c - create an mtd from a block device
5 * 5 *
@@ -19,7 +19,7 @@
19#include <linux/mtd/mtd.h> 19#include <linux/mtd/mtd.h>
20#include <linux/buffer_head.h> 20#include <linux/buffer_head.h>
21 21
22#define VERSION "$Revision: 1.29 $" 22#define VERSION "$Revision: 1.30 $"
23 23
24 24
25#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args) 25#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args)
@@ -40,7 +40,7 @@ static LIST_HEAD(blkmtd_device_list);
40 40
41 41
42#define PAGE_READAHEAD 64 42#define PAGE_READAHEAD 64
43void cache_readahead(struct address_space *mapping, int index) 43static void cache_readahead(struct address_space *mapping, int index)
44{ 44{
45 filler_t *filler = (filler_t*)mapping->a_ops->readpage; 45 filler_t *filler = (filler_t*)mapping->a_ops->readpage;
46 int i, pagei; 46 int i, pagei;
diff --git a/drivers/mtd/devices/ms02-nv.c b/drivers/mtd/devices/ms02-nv.c
index f5026cee087f..0ff2e4378244 100644
--- a/drivers/mtd/devices/ms02-nv.c
+++ b/drivers/mtd/devices/ms02-nv.c
@@ -6,7 +6,7 @@
6 * as published by the Free Software Foundation; either version 6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version. 7 * 2 of the License, or (at your option) any later version.
8 * 8 *
9 * $Id: ms02-nv.c,v 1.10 2005/06/20 12:24:41 macro Exp $ 9 * $Id: ms02-nv.c,v 1.11 2005/11/14 13:41:47 macro Exp $
10 */ 10 */
11 11
12#include <linux/init.h> 12#include <linux/init.h>
@@ -293,13 +293,13 @@ static int __init ms02nv_init(void)
293 293
294 switch (mips_machtype) { 294 switch (mips_machtype) {
295 case MACH_DS5000_200: 295 case MACH_DS5000_200:
296 csr = (volatile u32 *)KN02_CSR_BASE; 296 csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE + KN02_CSR);
297 if (*csr & KN02_CSR_BNK32M) 297 if (*csr & KN02_CSR_BNK32M)
298 stride = 2; 298 stride = 2;
299 break; 299 break;
300 case MACH_DS5000_2X0: 300 case MACH_DS5000_2X0:
301 case MACH_DS5900: 301 case MACH_DS5900:
302 csr = (volatile u32 *)KN03_MCR_BASE; 302 csr = (volatile u32 *)CKSEG1ADDR(KN03_SLOT_BASE + IOASIC_MCR);
303 if (*csr & KN03_MCR_BNK32M) 303 if (*csr & KN03_MCR_BNK32M)
304 stride = 2; 304 stride = 2;
305 break; 305 break;
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index de7e231d6d18..8a878b34eca0 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -1,5 +1,5 @@
1/* This version ported to the Linux-MTD system by dwmw2@infradead.org 1/* This version ported to the Linux-MTD system by dwmw2@infradead.org
2 * $Id: ftl.c,v 1.58 2005/11/07 11:14:19 gleixner Exp $ 2 * $Id: ftl.c,v 1.59 2005/11/29 14:48:31 gleixner Exp $
3 * 3 *
4 * Fixes: Arnaldo Carvalho de Melo <acme@conectiva.com.br> 4 * Fixes: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
5 * - fixes some leaks on failure in build_maps and ftl_notify_add, cleanups 5 * - fixes some leaks on failure in build_maps and ftl_notify_add, cleanups
@@ -1084,9 +1084,9 @@ struct mtd_blktrans_ops ftl_tr = {
1084 .owner = THIS_MODULE, 1084 .owner = THIS_MODULE,
1085}; 1085};
1086 1086
1087int init_ftl(void) 1087static int init_ftl(void)
1088{ 1088{
1089 DEBUG(0, "$Id: ftl.c,v 1.58 2005/11/07 11:14:19 gleixner Exp $\n"); 1089 DEBUG(0, "$Id: ftl.c,v 1.59 2005/11/29 14:48:31 gleixner Exp $\n");
1090 1090
1091 return register_mtd_blktrans(&ftl_tr); 1091 return register_mtd_blktrans(&ftl_tr);
1092} 1092}
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 48638c8097a5..b9b77cf39a18 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -62,7 +62,7 @@ config MTD_PHYSMAP_BANKWIDTH
62 62
63config MTD_SUN_UFLASH 63config MTD_SUN_UFLASH
64 tristate "Sun Microsystems userflash support" 64 tristate "Sun Microsystems userflash support"
65 depends on (SPARC32 || SPARC64) && MTD_CFI 65 depends on SPARC && MTD_CFI
66 help 66 help
67 This provides a 'mapping' driver which supports the way in 67 This provides a 'mapping' driver which supports the way in
68 which user-programmable flash chips are connected on various 68 which user-programmable flash chips are connected on various
@@ -94,7 +94,7 @@ config MTD_NETSC520
94 94
95config MTD_TS5500 95config MTD_TS5500
96 tristate "JEDEC Flash device mapped on Technologic Systems TS-5500" 96 tristate "JEDEC Flash device mapped on Technologic Systems TS-5500"
97 depends on ELAN 97 depends on X86
98 select MTD_PARTITIONS 98 select MTD_PARTITIONS
99 select MTD_JEDECPROBE 99 select MTD_JEDECPROBE
100 select MTD_CFI_AMDSTD 100 select MTD_CFI_AMDSTD
@@ -538,12 +538,6 @@ config MTD_MPC1211
538 This enables access to the flash chips on the Interface MPC-1211(CTP/PCI/MPC-SH02). 538 This enables access to the flash chips on the Interface MPC-1211(CTP/PCI/MPC-SH02).
539 If you have such a board, say 'Y'. 539 If you have such a board, say 'Y'.
540 540
541config MTD_PQ2FADS
542 tristate "JEDEC flash SIMM mapped on PQ2FADS and 8272ADS boards"
543 depends on (ADS8272 || PQ2FADS) && MTD_PARTITIONS && MTD_JEDECPROBE && MTD_PHYSMAP && MTD_CFI_GEOMETRY && MTD_CFI_INTELEXT
544 help
545 This enables access to flash SIMM on PQ2FADS-like boards
546
547config MTD_OMAP_NOR 541config MTD_OMAP_NOR
548 tristate "TI OMAP board mappings" 542 tristate "TI OMAP board mappings"
549 depends on MTD_CFI && ARCH_OMAP 543 depends on MTD_CFI && ARCH_OMAP
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 7d9e940a1dcd..2f7e254912f0 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -70,6 +70,5 @@ obj-$(CONFIG_MTD_DMV182) += dmv182.o
70obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o 70obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o
71obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o 71obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o
72obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o 72obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
73obj-$(CONFIG_MTD_PQ2FADS) += pq2fads.o
74obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o 73obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o
75obj-$(CONFIG_MTD_TQM834x) += tqm834x.o 74obj-$(CONFIG_MTD_TQM834x) += tqm834x.o
diff --git a/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c
index b7858eb93534..51f962dd7e31 100644
--- a/drivers/mtd/maps/bast-flash.c
+++ b/drivers/mtd/maps/bast-flash.c
@@ -63,11 +63,6 @@ struct bast_flash_info {
63 63
64static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 64static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
65 65
66static struct bast_flash_info *to_bast_info(struct device *dev)
67{
68 return (struct bast_flash_info *)dev_get_drvdata(dev);
69}
70
71static void bast_flash_setrw(int to) 66static void bast_flash_setrw(int to)
72{ 67{
73 unsigned int val; 68 unsigned int val;
@@ -87,11 +82,11 @@ static void bast_flash_setrw(int to)
87 local_irq_restore(flags); 82 local_irq_restore(flags);
88} 83}
89 84
90static int bast_flash_remove(struct device *dev) 85static int bast_flash_remove(struct platform_device *pdev)
91{ 86{
92 struct bast_flash_info *info = to_bast_info(dev); 87 struct bast_flash_info *info = platform_get_drvdata(pdev);
93 88
94 dev_set_drvdata(dev, NULL); 89 platform_set_drvdata(pdev, NULL);
95 90
96 if (info == NULL) 91 if (info == NULL)
97 return 0; 92 return 0;
@@ -116,9 +111,8 @@ static int bast_flash_remove(struct device *dev)
116 return 0; 111 return 0;
117} 112}
118 113
119static int bast_flash_probe(struct device *dev) 114static int bast_flash_probe(struct platform_device *pdev)
120{ 115{
121 struct platform_device *pdev = to_platform_device(dev);
122 struct bast_flash_info *info; 116 struct bast_flash_info *info;
123 struct resource *res; 117 struct resource *res;
124 int err = 0; 118 int err = 0;
@@ -131,13 +125,13 @@ static int bast_flash_probe(struct device *dev)
131 } 125 }
132 126
133 memzero(info, sizeof(*info)); 127 memzero(info, sizeof(*info));
134 dev_set_drvdata(dev, info); 128 platform_set_drvdata(pdev, info);
135 129
136 res = pdev->resource; /* assume that the flash has one resource */ 130 res = pdev->resource; /* assume that the flash has one resource */
137 131
138 info->map.phys = res->start; 132 info->map.phys = res->start;
139 info->map.size = res->end - res->start + 1; 133 info->map.size = res->end - res->start + 1;
140 info->map.name = dev->bus_id; 134 info->map.name = pdev->dev.bus_id;
141 info->map.bankwidth = 2; 135 info->map.bankwidth = 2;
142 136
143 if (info->map.size > AREA_MAXSIZE) 137 if (info->map.size > AREA_MAXSIZE)
@@ -199,27 +193,28 @@ static int bast_flash_probe(struct device *dev)
199 /* fall through to exit error */ 193 /* fall through to exit error */
200 194
201 exit_error: 195 exit_error:
202 bast_flash_remove(dev); 196 bast_flash_remove(pdev);
203 return err; 197 return err;
204} 198}
205 199
206static struct device_driver bast_flash_driver = { 200static struct platform_driver bast_flash_driver = {
207 .name = "bast-nor",
208 .owner = THIS_MODULE,
209 .bus = &platform_bus_type,
210 .probe = bast_flash_probe, 201 .probe = bast_flash_probe,
211 .remove = bast_flash_remove, 202 .remove = bast_flash_remove,
203 .driver = {
204 .name = "bast-nor",
205 .owner = THIS_MODULE,
206 },
212}; 207};
213 208
214static int __init bast_flash_init(void) 209static int __init bast_flash_init(void)
215{ 210{
216 printk("BAST NOR-Flash Driver, (c) 2004 Simtec Electronics\n"); 211 printk("BAST NOR-Flash Driver, (c) 2004 Simtec Electronics\n");
217 return driver_register(&bast_flash_driver); 212 return platform_driver_register(&bast_flash_driver);
218} 213}
219 214
220static void __exit bast_flash_exit(void) 215static void __exit bast_flash_exit(void)
221{ 216{
222 driver_unregister(&bast_flash_driver); 217 platform_driver_unregister(&bast_flash_driver);
223} 218}
224 219
225module_init(bast_flash_init); 220module_init(bast_flash_init);
diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c
index fe738fd8d6f8..a3ba52fbd868 100644
--- a/drivers/mtd/maps/integrator-flash.c
+++ b/drivers/mtd/maps/integrator-flash.c
@@ -67,9 +67,8 @@ static void armflash_set_vpp(struct map_info *map, int on)
67 67
68static const char *probes[] = { "cmdlinepart", "RedBoot", "afs", NULL }; 68static const char *probes[] = { "cmdlinepart", "RedBoot", "afs", NULL };
69 69
70static int armflash_probe(struct device *_dev) 70static int armflash_probe(struct platform_device *dev)
71{ 71{
72 struct platform_device *dev = to_platform_device(_dev);
73 struct flash_platform_data *plat = dev->dev.platform_data; 72 struct flash_platform_data *plat = dev->dev.platform_data;
74 struct resource *res = dev->resource; 73 struct resource *res = dev->resource;
75 unsigned int size = res->end - res->start + 1; 74 unsigned int size = res->end - res->start + 1;
@@ -138,7 +137,7 @@ static int armflash_probe(struct device *_dev)
138 } 137 }
139 138
140 if (err == 0) 139 if (err == 0)
141 dev_set_drvdata(&dev->dev, info); 140 platform_set_drvdata(dev, info);
142 141
143 /* 142 /*
144 * If we got an error, free all resources. 143 * If we got an error, free all resources.
@@ -163,12 +162,11 @@ static int armflash_probe(struct device *_dev)
163 return err; 162 return err;
164} 163}
165 164
166static int armflash_remove(struct device *_dev) 165static int armflash_remove(struct platform_device *dev)
167{ 166{
168 struct platform_device *dev = to_platform_device(_dev); 167 struct armflash_info *info = platform_get_drvdata(dev);
169 struct armflash_info *info = dev_get_drvdata(&dev->dev);
170 168
171 dev_set_drvdata(&dev->dev, NULL); 169 platform_set_drvdata(dev, NULL);
172 170
173 if (info) { 171 if (info) {
174 if (info->mtd) { 172 if (info->mtd) {
@@ -190,21 +188,22 @@ static int armflash_remove(struct device *_dev)
190 return 0; 188 return 0;
191} 189}
192 190
193static struct device_driver armflash_driver = { 191static struct platform_driver armflash_driver = {
194 .name = "armflash",
195 .bus = &platform_bus_type,
196 .probe = armflash_probe, 192 .probe = armflash_probe,
197 .remove = armflash_remove, 193 .remove = armflash_remove,
194 .driver = {
195 .name = "armflash",
196 },
198}; 197};
199 198
200static int __init armflash_init(void) 199static int __init armflash_init(void)
201{ 200{
202 return driver_register(&armflash_driver); 201 return platform_driver_register(&armflash_driver);
203} 202}
204 203
205static void __exit armflash_exit(void) 204static void __exit armflash_exit(void)
206{ 205{
207 driver_unregister(&armflash_driver); 206 platform_driver_unregister(&armflash_driver);
208} 207}
209 208
210module_init(armflash_init); 209module_init(armflash_init);
diff --git a/drivers/mtd/maps/ipaq-flash.c b/drivers/mtd/maps/ipaq-flash.c
index 35097c9bbf50..b8ccb0a95789 100644
--- a/drivers/mtd/maps/ipaq-flash.c
+++ b/drivers/mtd/maps/ipaq-flash.c
@@ -246,7 +246,7 @@ int __init ipaq_mtd_init(void)
246 ipaq_map[i].size = h3xxx_max_flash_size; 246 ipaq_map[i].size = h3xxx_max_flash_size;
247 ipaq_map[i].set_vpp = h3xxx_set_vpp; 247 ipaq_map[i].set_vpp = h3xxx_set_vpp;
248 ipaq_map[i].phys = cs_phys[i]; 248 ipaq_map[i].phys = cs_phys[i];
249 ipaq_map[i].virt = __ioremap(cs_phys[i], 0x04000000, 0, 1); 249 ipaq_map[i].virt = ioremap(cs_phys[i], 0x04000000);
250 if (machine_is_h3100 () || machine_is_h1900()) 250 if (machine_is_h3100 () || machine_is_h1900())
251 ipaq_map[i].bankwidth = 2; 251 ipaq_map[i].bankwidth = 2;
252 } 252 }
@@ -280,7 +280,7 @@ int __init ipaq_mtd_init(void)
280 nb_parts = ARRAY_SIZE(jornada_partitions); 280 nb_parts = ARRAY_SIZE(jornada_partitions);
281 ipaq_map[0].size = jornada_max_flash_size; 281 ipaq_map[0].size = jornada_max_flash_size;
282 ipaq_map[0].set_vpp = jornada56x_set_vpp; 282 ipaq_map[0].set_vpp = jornada56x_set_vpp;
283 ipaq_map[0].virt = (__u32)__ioremap(0x0, 0x04000000, 0, 1); 283 ipaq_map[0].virt = (__u32)ioremap(0x0, 0x04000000);
284 } 284 }
285#endif 285#endif
286#ifdef CONFIG_SA1100_JORNADA720 286#ifdef CONFIG_SA1100_JORNADA720
@@ -442,7 +442,7 @@ static int __init h1900_special_case(void)
442 ipaq_map[0].size = 0x80000; 442 ipaq_map[0].size = 0x80000;
443 ipaq_map[0].set_vpp = h3xxx_set_vpp; 443 ipaq_map[0].set_vpp = h3xxx_set_vpp;
444 ipaq_map[0].phys = 0x0; 444 ipaq_map[0].phys = 0x0;
445 ipaq_map[0].virt = __ioremap(0x0, 0x04000000, 0, 1); 445 ipaq_map[0].virt = ioremap(0x0, 0x04000000);
446 ipaq_map[0].bankwidth = 2; 446 ipaq_map[0].bankwidth = 2;
447 447
448 printk(KERN_NOTICE "iPAQ flash: probing %d-bit flash bus, window=%lx with JEDEC.\n", ipaq_map[0].bankwidth*8, ipaq_map[0].virt); 448 printk(KERN_NOTICE "iPAQ flash: probing %d-bit flash bus, window=%lx with JEDEC.\n", ipaq_map[0].bankwidth*8, ipaq_map[0].virt);
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
index 641eb2b55e9f..2c9cc7f37e92 100644
--- a/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -111,13 +111,12 @@ static void ixp2000_flash_copy_to(struct map_info *map, unsigned long to,
111} 111}
112 112
113 113
114static int ixp2000_flash_remove(struct device *_dev) 114static int ixp2000_flash_remove(struct platform_device *dev)
115{ 115{
116 struct platform_device *dev = to_platform_device(_dev);
117 struct flash_platform_data *plat = dev->dev.platform_data; 116 struct flash_platform_data *plat = dev->dev.platform_data;
118 struct ixp2000_flash_info *info = dev_get_drvdata(&dev->dev); 117 struct ixp2000_flash_info *info = platform_get_drvdata(dev);
119 118
120 dev_set_drvdata(&dev->dev, NULL); 119 platform_set_drvdata(dev, NULL);
121 120
122 if(!info) 121 if(!info)
123 return 0; 122 return 0;
@@ -143,10 +142,9 @@ static int ixp2000_flash_remove(struct device *_dev)
143} 142}
144 143
145 144
146static int ixp2000_flash_probe(struct device *_dev) 145static int ixp2000_flash_probe(struct platform_device *dev)
147{ 146{
148 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 147 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
149 struct platform_device *dev = to_platform_device(_dev);
150 struct ixp2000_flash_data *ixp_data = dev->dev.platform_data; 148 struct ixp2000_flash_data *ixp_data = dev->dev.platform_data;
151 struct flash_platform_data *plat; 149 struct flash_platform_data *plat;
152 struct ixp2000_flash_info *info; 150 struct ixp2000_flash_info *info;
@@ -161,12 +159,12 @@ static int ixp2000_flash_probe(struct device *_dev)
161 return -ENODEV; 159 return -ENODEV;
162 160
163 window_size = dev->resource->end - dev->resource->start + 1; 161 window_size = dev->resource->end - dev->resource->start + 1;
164 dev_info(_dev, "Probe of IXP2000 flash(%d banks x %dMiB)\n", 162 dev_info(&dev->dev, "Probe of IXP2000 flash(%d banks x %dMiB)\n",
165 ixp_data->nr_banks, ((u32)window_size >> 20)); 163 ixp_data->nr_banks, ((u32)window_size >> 20));
166 164
167 if (plat->width != 1) { 165 if (plat->width != 1) {
168 dev_err(_dev, "IXP2000 MTD map only supports 8-bit mode, asking for %d\n", 166 dev_err(&dev->dev, "IXP2000 MTD map only supports 8-bit mode, asking for %d\n",
169 plat->width * 8); 167 plat->width * 8);
170 return -EIO; 168 return -EIO;
171 } 169 }
172 170
@@ -177,7 +175,7 @@ static int ixp2000_flash_probe(struct device *_dev)
177 } 175 }
178 memzero(info, sizeof(struct ixp2000_flash_info)); 176 memzero(info, sizeof(struct ixp2000_flash_info));
179 177
180 dev_set_drvdata(&dev->dev, info); 178 platform_set_drvdata(dev, info);
181 179
182 /* 180 /*
183 * Tell the MTD layer we're not 1:1 mapped so that it does 181 * Tell the MTD layer we're not 1:1 mapped so that it does
@@ -204,7 +202,7 @@ static int ixp2000_flash_probe(struct device *_dev)
204 dev->resource->end - dev->resource->start + 1, 202 dev->resource->end - dev->resource->start + 1,
205 dev->dev.bus_id); 203 dev->dev.bus_id);
206 if (!info->res) { 204 if (!info->res) {
207 dev_err(_dev, "Could not reserve memory region\n"); 205 dev_err(&dev->dev, "Could not reserve memory region\n");
208 err = -ENOMEM; 206 err = -ENOMEM;
209 goto Error; 207 goto Error;
210 } 208 }
@@ -212,7 +210,7 @@ static int ixp2000_flash_probe(struct device *_dev)
212 info->map.map_priv_1 = (unsigned long) ioremap(dev->resource->start, 210 info->map.map_priv_1 = (unsigned long) ioremap(dev->resource->start,
213 dev->resource->end - dev->resource->start + 1); 211 dev->resource->end - dev->resource->start + 1);
214 if (!info->map.map_priv_1) { 212 if (!info->map.map_priv_1) {
215 dev_err(_dev, "Failed to ioremap flash region\n"); 213 dev_err(&dev->dev, "Failed to ioremap flash region\n");
216 err = -EIO; 214 err = -EIO;
217 goto Error; 215 goto Error;
218 } 216 }
@@ -223,13 +221,13 @@ static int ixp2000_flash_probe(struct device *_dev)
223 */ 221 */
224 222
225 erratum44_workaround = ixp2000_has_broken_slowport(); 223 erratum44_workaround = ixp2000_has_broken_slowport();
226 dev_info(_dev, "Erratum 44 workaround %s\n", 224 dev_info(&dev->dev, "Erratum 44 workaround %s\n",
227 erratum44_workaround ? "enabled" : "disabled"); 225 erratum44_workaround ? "enabled" : "disabled");
228#endif 226#endif
229 227
230 info->mtd = do_map_probe(plat->map_name, &info->map); 228 info->mtd = do_map_probe(plat->map_name, &info->map);
231 if (!info->mtd) { 229 if (!info->mtd) {
232 dev_err(_dev, "map_probe failed\n"); 230 dev_err(&dev->dev, "map_probe failed\n");
233 err = -ENXIO; 231 err = -ENXIO;
234 goto Error; 232 goto Error;
235 } 233 }
@@ -239,7 +237,7 @@ static int ixp2000_flash_probe(struct device *_dev)
239 if (err > 0) { 237 if (err > 0) {
240 err = add_mtd_partitions(info->mtd, info->partitions, err); 238 err = add_mtd_partitions(info->mtd, info->partitions, err);
241 if(err) 239 if(err)
242 dev_err(_dev, "Could not parse partitions\n"); 240 dev_err(&dev->dev, "Could not parse partitions\n");
243 } 241 }
244 242
245 if (err) 243 if (err)
@@ -248,25 +246,26 @@ static int ixp2000_flash_probe(struct device *_dev)
248 return 0; 246 return 0;
249 247
250Error: 248Error:
251 ixp2000_flash_remove(_dev); 249 ixp2000_flash_remove(dev);
252 return err; 250 return err;
253} 251}
254 252
255static struct device_driver ixp2000_flash_driver = { 253static struct platform_driver ixp2000_flash_driver = {
256 .name = "IXP2000-Flash", 254 .probe = ixp2000_flash_probe,
257 .bus = &platform_bus_type, 255 .remove = ixp2000_flash_remove,
258 .probe = &ixp2000_flash_probe, 256 .driver = {
259 .remove = &ixp2000_flash_remove 257 .name = "IXP2000-Flash",
258 },
260}; 259};
261 260
262static int __init ixp2000_flash_init(void) 261static int __init ixp2000_flash_init(void)
263{ 262{
264 return driver_register(&ixp2000_flash_driver); 263 return platform_driver_register(&ixp2000_flash_driver);
265} 264}
266 265
267static void __exit ixp2000_flash_exit(void) 266static void __exit ixp2000_flash_exit(void)
268{ 267{
269 driver_unregister(&ixp2000_flash_driver); 268 platform_driver_unregister(&ixp2000_flash_driver);
270} 269}
271 270
272module_init(ixp2000_flash_init); 271module_init(ixp2000_flash_init);
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 56b3a355bf7b..986c58628390 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ixp4xx.c,v 1.12 2005/11/07 11:14:27 gleixner Exp $ 2 * $Id: ixp4xx.c,v 1.13 2005/11/16 16:23:21 dvrabel Exp $
3 * 3 *
4 * drivers/mtd/maps/ixp4xx.c 4 * drivers/mtd/maps/ixp4xx.c
5 * 5 *
@@ -34,10 +34,55 @@
34 34
35#include <linux/reboot.h> 35#include <linux/reboot.h>
36 36
37/*
38 * Read/write a 16 bit word from flash address 'addr'.
39 *
40 * When the cpu is in little-endian mode it swizzles the address lines
41 * ('address coherency') so we need to undo the swizzling to ensure commands
42 * and the like end up on the correct flash address.
43 *
44 * To further complicate matters, due to the way the expansion bus controller
45 * handles 32 bit reads, the byte stream ABCD is stored on the flash as:
46 * D15 D0
47 * +---+---+
48 * | A | B | 0
49 * +---+---+
50 * | C | D | 2
51 * +---+---+
52 * This means that on LE systems each 16 bit word must be swapped. Note that
53 * this requires CONFIG_MTD_CFI_BE_BYTE_SWAP to be enabled to 'unswap' the CFI
54 * data and other flash commands which are always in D7-D0.
55 */
37#ifndef __ARMEB__ 56#ifndef __ARMEB__
57#ifndef CONFIG_MTD_CFI_BE_BYTE_SWAP
58# error CONFIG_MTD_CFI_BE_BYTE_SWAP required
59#endif
60
61static inline u16 flash_read16(void __iomem *addr)
62{
63 return be16_to_cpu(__raw_readw((void __iomem *)((unsigned long)addr ^ 0x2)));
64}
65
66static inline void flash_write16(u16 d, void __iomem *addr)
67{
68 __raw_writew(cpu_to_be16(d), (void __iomem *)((unsigned long)addr ^ 0x2));
69}
70
38#define BYTE0(h) ((h) & 0xFF) 71#define BYTE0(h) ((h) & 0xFF)
39#define BYTE1(h) (((h) >> 8) & 0xFF) 72#define BYTE1(h) (((h) >> 8) & 0xFF)
73
40#else 74#else
75
76static inline u16 flash_read16(const void __iomem *addr)
77{
78 return __raw_readw(addr);
79}
80
81static inline void flash_write16(u16 d, void __iomem *addr)
82{
83 __raw_writew(d, addr);
84}
85
41#define BYTE0(h) (((h) >> 8) & 0xFF) 86#define BYTE0(h) (((h) >> 8) & 0xFF)
42#define BYTE1(h) ((h) & 0xFF) 87#define BYTE1(h) ((h) & 0xFF)
43#endif 88#endif
@@ -45,7 +90,7 @@
45static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs) 90static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs)
46{ 91{
47 map_word val; 92 map_word val;
48 val.x[0] = le16_to_cpu(readw(map->virt + ofs)); 93 val.x[0] = flash_read16(map->virt + ofs);
49 return val; 94 return val;
50} 95}
51 96
@@ -57,19 +102,28 @@ static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs)
57static void ixp4xx_copy_from(struct map_info *map, void *to, 102static void ixp4xx_copy_from(struct map_info *map, void *to,
58 unsigned long from, ssize_t len) 103 unsigned long from, ssize_t len)
59{ 104{
60 int i;
61 u8 *dest = (u8 *) to; 105 u8 *dest = (u8 *) to;
62 void __iomem *src = map->virt + from; 106 void __iomem *src = map->virt + from;
63 u16 data;
64 107
65 for (i = 0; i < (len / 2); i++) { 108 if (len <= 0)
66 data = le16_to_cpu(readw(src + 2*i)); 109 return;
67 dest[i * 2] = BYTE0(data); 110
68 dest[i * 2 + 1] = BYTE1(data); 111 if (from & 1) {
112 *dest++ = BYTE1(flash_read16(src));
113 src++;
114 --len;
69 } 115 }
70 116
71 if (len & 1) 117 while (len >= 2) {
72 dest[len - 1] = BYTE0(le16_to_cpu(readw(src + 2*i))); 118 u16 data = flash_read16(src);
119 *dest++ = BYTE0(data);
120 *dest++ = BYTE1(data);
121 src += 2;
122 len -= 2;
123 }
124
125 if (len > 0)
126 *dest++ = BYTE0(flash_read16(src));
73} 127}
74 128
75/* 129/*
@@ -79,7 +133,7 @@ static void ixp4xx_copy_from(struct map_info *map, void *to,
79static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long adr) 133static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long adr)
80{ 134{
81 if (!(adr & 1)) 135 if (!(adr & 1))
82 writew(cpu_to_le16(d.x[0]), map->virt + adr); 136 flash_write16(d.x[0], map->virt + adr);
83} 137}
84 138
85/* 139/*
@@ -87,7 +141,7 @@ static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long
87 */ 141 */
88static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr) 142static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr)
89{ 143{
90 writew(cpu_to_le16(d.x[0]), map->virt + adr); 144 flash_write16(d.x[0], map->virt + adr);
91} 145}
92 146
93struct ixp4xx_flash_info { 147struct ixp4xx_flash_info {
@@ -99,13 +153,12 @@ struct ixp4xx_flash_info {
99 153
100static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 154static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
101 155
102static int ixp4xx_flash_remove(struct device *_dev) 156static int ixp4xx_flash_remove(struct platform_device *dev)
103{ 157{
104 struct platform_device *dev = to_platform_device(_dev);
105 struct flash_platform_data *plat = dev->dev.platform_data; 158 struct flash_platform_data *plat = dev->dev.platform_data;
106 struct ixp4xx_flash_info *info = dev_get_drvdata(&dev->dev); 159 struct ixp4xx_flash_info *info = platform_get_drvdata(dev);
107 160
108 dev_set_drvdata(&dev->dev, NULL); 161 platform_set_drvdata(dev, NULL);
109 162
110 if(!info) 163 if(!info)
111 return 0; 164 return 0;
@@ -130,9 +183,8 @@ static int ixp4xx_flash_remove(struct device *_dev)
130 return 0; 183 return 0;
131} 184}
132 185
133static int ixp4xx_flash_probe(struct device *_dev) 186static int ixp4xx_flash_probe(struct platform_device *dev)
134{ 187{
135 struct platform_device *dev = to_platform_device(_dev);
136 struct flash_platform_data *plat = dev->dev.platform_data; 188 struct flash_platform_data *plat = dev->dev.platform_data;
137 struct ixp4xx_flash_info *info; 189 struct ixp4xx_flash_info *info;
138 int err = -1; 190 int err = -1;
@@ -153,7 +205,7 @@ static int ixp4xx_flash_probe(struct device *_dev)
153 } 205 }
154 memzero(info, sizeof(struct ixp4xx_flash_info)); 206 memzero(info, sizeof(struct ixp4xx_flash_info));
155 207
156 dev_set_drvdata(&dev->dev, info); 208 platform_set_drvdata(dev, info);
157 209
158 /* 210 /*
159 * Tell the MTD layer we're not 1:1 mapped so that it does 211 * Tell the MTD layer we're not 1:1 mapped so that it does
@@ -214,25 +266,26 @@ static int ixp4xx_flash_probe(struct device *_dev)
214 return 0; 266 return 0;
215 267
216Error: 268Error:
217 ixp4xx_flash_remove(_dev); 269 ixp4xx_flash_remove(dev);
218 return err; 270 return err;
219} 271}
220 272
221static struct device_driver ixp4xx_flash_driver = { 273static struct platform_driver ixp4xx_flash_driver = {
222 .name = "IXP4XX-Flash",
223 .bus = &platform_bus_type,
224 .probe = ixp4xx_flash_probe, 274 .probe = ixp4xx_flash_probe,
225 .remove = ixp4xx_flash_remove, 275 .remove = ixp4xx_flash_remove,
276 .driver = {
277 .name = "IXP4XX-Flash",
278 },
226}; 279};
227 280
228static int __init ixp4xx_flash_init(void) 281static int __init ixp4xx_flash_init(void)
229{ 282{
230 return driver_register(&ixp4xx_flash_driver); 283 return platform_driver_register(&ixp4xx_flash_driver);
231} 284}
232 285
233static void __exit ixp4xx_flash_exit(void) 286static void __exit ixp4xx_flash_exit(void)
234{ 287{
235 driver_unregister(&ixp4xx_flash_driver); 288 platform_driver_unregister(&ixp4xx_flash_driver);
236} 289}
237 290
238 291
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c
index f00ee7e54dba..632eb2aa968f 100644
--- a/drivers/mtd/maps/nettel.c
+++ b/drivers/mtd/maps/nettel.c
@@ -6,7 +6,7 @@
6 * (C) Copyright 2000-2001, Greg Ungerer (gerg@snapgear.com) 6 * (C) Copyright 2000-2001, Greg Ungerer (gerg@snapgear.com)
7 * (C) Copyright 2001-2002, SnapGear (www.snapgear.com) 7 * (C) Copyright 2001-2002, SnapGear (www.snapgear.com)
8 * 8 *
9 * $Id: nettel.c,v 1.11 2005/11/07 11:14:27 gleixner Exp $ 9 * $Id: nettel.c,v 1.12 2005/11/29 14:30:00 gleixner Exp $
10 */ 10 */
11 11
12/****************************************************************************/ 12/****************************************************************************/
@@ -479,7 +479,7 @@ void __exit nettel_cleanup(void)
479 } 479 }
480 if (nettel_intel_map.virt) { 480 if (nettel_intel_map.virt) {
481 iounmap(nettel_intel_map.virt); 481 iounmap(nettel_intel_map.virt);
482 nettel_intel_map.virt = 0; 482 nettel_intel_map.virt = NULL;
483 } 483 }
484#endif 484#endif
485} 485}
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c
index fd3b4a5fc207..418afffb2d80 100644
--- a/drivers/mtd/maps/omap_nor.c
+++ b/drivers/mtd/maps/omap_nor.c
@@ -70,11 +70,10 @@ static void omap_set_vpp(struct map_info *map, int enable)
70 } 70 }
71} 71}
72 72
73static int __devinit omapflash_probe(struct device *dev) 73static int __devinit omapflash_probe(struct platform_device *pdev)
74{ 74{
75 int err; 75 int err;
76 struct omapflash_info *info; 76 struct omapflash_info *info;
77 struct platform_device *pdev = to_platform_device(dev);
78 struct flash_platform_data *pdata = pdev->dev.platform_data; 77 struct flash_platform_data *pdata = pdev->dev.platform_data;
79 struct resource *res = pdev->resource; 78 struct resource *res = pdev->resource;
80 unsigned long size = res->end - res->start + 1; 79 unsigned long size = res->end - res->start + 1;
@@ -119,7 +118,7 @@ static int __devinit omapflash_probe(struct device *dev)
119#endif 118#endif
120 add_mtd_device(info->mtd); 119 add_mtd_device(info->mtd);
121 120
122 dev_set_drvdata(&pdev->dev, info); 121 platform_set_drvdata(pdev, info);
123 122
124 return 0; 123 return 0;
125 124
@@ -133,12 +132,11 @@ out_free_info:
133 return err; 132 return err;
134} 133}
135 134
136static int __devexit omapflash_remove(struct device *dev) 135static int __devexit omapflash_remove(struct platform_device *pdev)
137{ 136{
138 struct platform_device *pdev = to_platform_device(dev); 137 struct omapflash_info *info = platform_get_drvdata(pdev);
139 struct omapflash_info *info = dev_get_drvdata(&pdev->dev);
140 138
141 dev_set_drvdata(&pdev->dev, NULL); 139 platform_set_drvdata(pdev, NULL);
142 140
143 if (info) { 141 if (info) {
144 if (info->parts) { 142 if (info->parts) {
@@ -155,21 +153,22 @@ static int __devexit omapflash_remove(struct device *dev)
155 return 0; 153 return 0;
156} 154}
157 155
158static struct device_driver omapflash_driver = { 156static struct platform_driver omapflash_driver = {
159 .name = "omapflash",
160 .bus = &platform_bus_type,
161 .probe = omapflash_probe, 157 .probe = omapflash_probe,
162 .remove = __devexit_p(omapflash_remove), 158 .remove = __devexit_p(omapflash_remove),
159 .driver = {
160 .name = "omapflash",
161 },
163}; 162};
164 163
165static int __init omapflash_init(void) 164static int __init omapflash_init(void)
166{ 165{
167 return driver_register(&omapflash_driver); 166 return platform_driver_register(&omapflash_driver);
168} 167}
169 168
170static void __exit omapflash_exit(void) 169static void __exit omapflash_exit(void)
171{ 170{
172 driver_unregister(&omapflash_driver); 171 platform_driver_unregister(&omapflash_driver);
173} 172}
174 173
175module_init(omapflash_init); 174module_init(omapflash_init);
diff --git a/drivers/mtd/maps/pci.c b/drivers/mtd/maps/pci.c
index 8b3570b09095..21822c2edbe4 100644
--- a/drivers/mtd/maps/pci.c
+++ b/drivers/mtd/maps/pci.c
@@ -7,7 +7,7 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 * 9 *
10 * $Id: pci.c,v 1.13 2005/11/07 11:14:27 gleixner Exp $ 10 * $Id: pci.c,v 1.14 2005/11/17 08:20:27 dwmw2 Exp $
11 * 11 *
12 * Generic PCI memory map driver. We support the following boards: 12 * Generic PCI memory map driver. We support the following boards:
13 * - Intel IQ80310 ATU. 13 * - Intel IQ80310 ATU.
@@ -102,7 +102,7 @@ static void mtd_pci_copyto(struct map_info *_map, unsigned long to, const void *
102 memcpy_toio(map->base + map->translate(map, to), from, len); 102 memcpy_toio(map->base + map->translate(map, to), from, len);
103} 103}
104 104
105static struct map_info mtd_pci_map = { 105static const struct map_info mtd_pci_map = {
106 .phys = NO_XIP, 106 .phys = NO_XIP,
107 .copy_from = mtd_pci_copyfrom, 107 .copy_from = mtd_pci_copyfrom,
108 .copy_to = mtd_pci_copyto, 108 .copy_to = mtd_pci_copyto,
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 9ee760f97bc6..f49ebc3c4606 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: physmap.c,v 1.38 2005/11/07 11:14:28 gleixner Exp $ 2 * $Id: physmap.c,v 1.39 2005/11/29 14:49:36 gleixner Exp $
3 * 3 *
4 * Normal mappings of chips in physical memory 4 * Normal mappings of chips in physical memory
5 * 5 *
@@ -19,6 +19,7 @@
19#include <linux/mtd/map.h> 19#include <linux/mtd/map.h>
20#include <linux/config.h> 20#include <linux/config.h>
21#include <linux/mtd/partitions.h> 21#include <linux/mtd/partitions.h>
22#include <linux/mtd/physmap.h>
22 23
23static struct mtd_info *mymtd; 24static struct mtd_info *mymtd;
24 25
diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c
index a02eed94a231..5d3c75451ca2 100644
--- a/drivers/mtd/maps/plat-ram.c
+++ b/drivers/mtd/maps/plat-ram.c
@@ -56,9 +56,9 @@ struct platram_info {
56 * device private data to struct platram_info conversion 56 * device private data to struct platram_info conversion
57*/ 57*/
58 58
59static inline struct platram_info *to_platram_info(struct device *dev) 59static inline struct platram_info *to_platram_info(struct platform_device *dev)
60{ 60{
61 return (struct platram_info *)dev_get_drvdata(dev); 61 return (struct platram_info *)platform_get_drvdata(dev);
62} 62}
63 63
64/* platram_setrw 64/* platram_setrw
@@ -83,13 +83,13 @@ static inline void platram_setrw(struct platram_info *info, int to)
83 * called to remove the device from the driver's control 83 * called to remove the device from the driver's control
84*/ 84*/
85 85
86static int platram_remove(struct device *dev) 86static int platram_remove(struct platform_device *pdev)
87{ 87{
88 struct platram_info *info = to_platram_info(dev); 88 struct platram_info *info = to_platram_info(pdev);
89 89
90 dev_set_drvdata(dev, NULL); 90 platform_set_drvdata(pdev, NULL);
91 91
92 dev_dbg(dev, "removing device\n"); 92 dev_dbg(&pdev->dev, "removing device\n");
93 93
94 if (info == NULL) 94 if (info == NULL)
95 return 0; 95 return 0;
@@ -130,61 +130,60 @@ static int platram_remove(struct device *dev)
130 * driver is found. 130 * driver is found.
131*/ 131*/
132 132
133static int platram_probe(struct device *dev) 133static int platram_probe(struct platform_device *pdev)
134{ 134{
135 struct platform_device *pd = to_platform_device(dev);
136 struct platdata_mtd_ram *pdata; 135 struct platdata_mtd_ram *pdata;
137 struct platram_info *info; 136 struct platram_info *info;
138 struct resource *res; 137 struct resource *res;
139 int err = 0; 138 int err = 0;
140 139
141 dev_dbg(dev, "probe entered\n"); 140 dev_dbg(&pdev->dev, "probe entered\n");
142 141
143 if (dev->platform_data == NULL) { 142 if (pdev->dev.platform_data == NULL) {
144 dev_err(dev, "no platform data supplied\n"); 143 dev_err(&pdev->dev, "no platform data supplied\n");
145 err = -ENOENT; 144 err = -ENOENT;
146 goto exit_error; 145 goto exit_error;
147 } 146 }
148 147
149 pdata = dev->platform_data; 148 pdata = pdev->dev.platform_data;
150 149
151 info = kmalloc(sizeof(*info), GFP_KERNEL); 150 info = kmalloc(sizeof(*info), GFP_KERNEL);
152 if (info == NULL) { 151 if (info == NULL) {
153 dev_err(dev, "no memory for flash info\n"); 152 dev_err(&pdev->dev, "no memory for flash info\n");
154 err = -ENOMEM; 153 err = -ENOMEM;
155 goto exit_error; 154 goto exit_error;
156 } 155 }
157 156
158 memset(info, 0, sizeof(*info)); 157 memset(info, 0, sizeof(*info));
159 dev_set_drvdata(dev, info); 158 platform_set_drvdata(pdev, info);
160 159
161 info->dev = dev; 160 info->dev = &pdev->dev;
162 info->pdata = pdata; 161 info->pdata = pdata;
163 162
164 /* get the resource for the memory mapping */ 163 /* get the resource for the memory mapping */
165 164
166 res = platform_get_resource(pd, IORESOURCE_MEM, 0); 165 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
167 166
168 if (res == NULL) { 167 if (res == NULL) {
169 dev_err(dev, "no memory resource specified\n"); 168 dev_err(&pdev->dev, "no memory resource specified\n");
170 err = -ENOENT; 169 err = -ENOENT;
171 goto exit_free; 170 goto exit_free;
172 } 171 }
173 172
174 dev_dbg(dev, "got platform resource %p (0x%lx)\n", res, res->start); 173 dev_dbg(&pdev->dev, "got platform resource %p (0x%lx)\n", res, res->start);
175 174
176 /* setup map parameters */ 175 /* setup map parameters */
177 176
178 info->map.phys = res->start; 177 info->map.phys = res->start;
179 info->map.size = (res->end - res->start) + 1; 178 info->map.size = (res->end - res->start) + 1;
180 info->map.name = pdata->mapname != NULL ? pdata->mapname : (char *)pd->name; 179 info->map.name = pdata->mapname != NULL ? pdata->mapname : (char *)pdev->name;
181 info->map.bankwidth = pdata->bankwidth; 180 info->map.bankwidth = pdata->bankwidth;
182 181
183 /* register our usage of the memory area */ 182 /* register our usage of the memory area */
184 183
185 info->area = request_mem_region(res->start, info->map.size, pd->name); 184 info->area = request_mem_region(res->start, info->map.size, pdev->name);
186 if (info->area == NULL) { 185 if (info->area == NULL) {
187 dev_err(dev, "failed to request memory region\n"); 186 dev_err(&pdev->dev, "failed to request memory region\n");
188 err = -EIO; 187 err = -EIO;
189 goto exit_free; 188 goto exit_free;
190 } 189 }
@@ -192,23 +191,23 @@ static int platram_probe(struct device *dev)
192 /* remap the memory area */ 191 /* remap the memory area */
193 192
194 info->map.virt = ioremap(res->start, info->map.size); 193 info->map.virt = ioremap(res->start, info->map.size);
195 dev_dbg(dev, "virt %p, %lu bytes\n", info->map.virt, info->map.size); 194 dev_dbg(&pdev->dev, "virt %p, %lu bytes\n", info->map.virt, info->map.size);
196 195
197 if (info->map.virt == NULL) { 196 if (info->map.virt == NULL) {
198 dev_err(dev, "failed to ioremap() region\n"); 197 dev_err(&pdev->dev, "failed to ioremap() region\n");
199 err = -EIO; 198 err = -EIO;
200 goto exit_free; 199 goto exit_free;
201 } 200 }
202 201
203 simple_map_init(&info->map); 202 simple_map_init(&info->map);
204 203
205 dev_dbg(dev, "initialised map, probing for mtd\n"); 204 dev_dbg(&pdev->dev, "initialised map, probing for mtd\n");
206 205
207 /* probe for the right mtd map driver */ 206 /* probe for the right mtd map driver */
208 207
209 info->mtd = do_map_probe("map_ram" , &info->map); 208 info->mtd = do_map_probe("map_ram" , &info->map);
210 if (info->mtd == NULL) { 209 if (info->mtd == NULL) {
211 dev_err(dev, "failed to probe for map_ram\n"); 210 dev_err(&pdev->dev, "failed to probe for map_ram\n");
212 err = -ENOMEM; 211 err = -ENOMEM;
213 goto exit_free; 212 goto exit_free;
214 } 213 }
@@ -237,27 +236,28 @@ static int platram_probe(struct device *dev)
237#endif /* CONFIG_MTD_PARTITIONS */ 236#endif /* CONFIG_MTD_PARTITIONS */
238 237
239 if (add_mtd_device(info->mtd)) { 238 if (add_mtd_device(info->mtd)) {
240 dev_err(dev, "add_mtd_device() failed\n"); 239 dev_err(&pdev->dev, "add_mtd_device() failed\n");
241 err = -ENOMEM; 240 err = -ENOMEM;
242 } 241 }
243 242
244 dev_info(dev, "registered mtd device\n"); 243 dev_info(&pdev->dev, "registered mtd device\n");
245 return err; 244 return err;
246 245
247 exit_free: 246 exit_free:
248 platram_remove(dev); 247 platram_remove(pdev);
249 exit_error: 248 exit_error:
250 return err; 249 return err;
251} 250}
252 251
253/* device driver info */ 252/* device driver info */
254 253
255static struct device_driver platram_driver = { 254static struct platform_driver platram_driver = {
256 .name = "mtd-ram",
257 .owner = THIS_MODULE,
258 .bus = &platform_bus_type,
259 .probe = platram_probe, 255 .probe = platram_probe,
260 .remove = platram_remove, 256 .remove = platram_remove,
257 .driver = {
258 .name = "mtd-ram",
259 .owner = THIS_MODULE,
260 },
261}; 261};
262 262
263/* module init/exit */ 263/* module init/exit */
@@ -265,12 +265,12 @@ static struct device_driver platram_driver = {
265static int __init platram_init(void) 265static int __init platram_init(void)
266{ 266{
267 printk("Generic platform RAM MTD, (c) 2004 Simtec Electronics\n"); 267 printk("Generic platform RAM MTD, (c) 2004 Simtec Electronics\n");
268 return driver_register(&platram_driver); 268 return platform_driver_register(&platram_driver);
269} 269}
270 270
271static void __exit platram_exit(void) 271static void __exit platram_exit(void)
272{ 272{
273 driver_unregister(&platram_driver); 273 platform_driver_unregister(&platram_driver);
274} 274}
275 275
276module_init(platram_init); 276module_init(platram_init);
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c
index 9e8bb1782be0..5cefb015633c 100644
--- a/drivers/mtd/maps/sa1100-flash.c
+++ b/drivers/mtd/maps/sa1100-flash.c
@@ -356,9 +356,8 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat)
356 356
357static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL }; 357static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
358 358
359static int __init sa1100_mtd_probe(struct device *dev) 359static int __init sa1100_mtd_probe(struct platform_device *pdev)
360{ 360{
361 struct platform_device *pdev = to_platform_device(dev);
362 struct flash_platform_data *plat = pdev->dev.platform_data; 361 struct flash_platform_data *plat = pdev->dev.platform_data;
363 struct mtd_partition *parts; 362 struct mtd_partition *parts;
364 const char *part_type = NULL; 363 const char *part_type = NULL;
@@ -402,28 +401,28 @@ static int __init sa1100_mtd_probe(struct device *dev)
402 401
403 info->nr_parts = nr_parts; 402 info->nr_parts = nr_parts;
404 403
405 dev_set_drvdata(dev, info); 404 platform_set_drvdata(pdev, info);
406 err = 0; 405 err = 0;
407 406
408 out: 407 out:
409 return err; 408 return err;
410} 409}
411 410
412static int __exit sa1100_mtd_remove(struct device *dev) 411static int __exit sa1100_mtd_remove(struct platform_device *pdev)
413{ 412{
414 struct sa_info *info = dev_get_drvdata(dev); 413 struct sa_info *info = platform_get_drvdata(pdev);
415 struct flash_platform_data *plat = dev->platform_data; 414 struct flash_platform_data *plat = pdev->dev.platform_data;
416 415
417 dev_set_drvdata(dev, NULL); 416 platform_set_drvdata(pdev, NULL);
418 sa1100_destroy(info, plat); 417 sa1100_destroy(info, plat);
419 418
420 return 0; 419 return 0;
421} 420}
422 421
423#ifdef CONFIG_PM 422#ifdef CONFIG_PM
424static int sa1100_mtd_suspend(struct device *dev, pm_message_t state) 423static int sa1100_mtd_suspend(struct platform_device *dev, pm_message_t state)
425{ 424{
426 struct sa_info *info = dev_get_drvdata(dev); 425 struct sa_info *info = platform_get_drvdata(dev);
427 int ret = 0; 426 int ret = 0;
428 427
429 if (info) 428 if (info)
@@ -432,17 +431,17 @@ static int sa1100_mtd_suspend(struct device *dev, pm_message_t state)
432 return ret; 431 return ret;
433} 432}
434 433
435static int sa1100_mtd_resume(struct device *dev) 434static int sa1100_mtd_resume(struct platform_device *dev)
436{ 435{
437 struct sa_info *info = dev_get_drvdata(dev); 436 struct sa_info *info = platform_get_drvdata(dev);
438 if (info) 437 if (info)
439 info->mtd->resume(info->mtd); 438 info->mtd->resume(info->mtd);
440 return 0; 439 return 0;
441} 440}
442 441
443static void sa1100_mtd_shutdown(struct device *dev) 442static void sa1100_mtd_shutdown(struct platform_device *dev)
444{ 443{
445 struct sa_info *info = dev_get_drvdata(dev); 444 struct sa_info *info = platform_get_drvdata(dev);
446 if (info && info->mtd->suspend(info->mtd) == 0) 445 if (info && info->mtd->suspend(info->mtd) == 0)
447 info->mtd->resume(info->mtd); 446 info->mtd->resume(info->mtd);
448} 447}
@@ -452,24 +451,25 @@ static void sa1100_mtd_shutdown(struct device *dev)
452#define sa1100_mtd_shutdown NULL 451#define sa1100_mtd_shutdown NULL
453#endif 452#endif
454 453
455static struct device_driver sa1100_mtd_driver = { 454static struct platform_driver sa1100_mtd_driver = {
456 .name = "flash",
457 .bus = &platform_bus_type,
458 .probe = sa1100_mtd_probe, 455 .probe = sa1100_mtd_probe,
459 .remove = __exit_p(sa1100_mtd_remove), 456 .remove = __exit_p(sa1100_mtd_remove),
460 .suspend = sa1100_mtd_suspend, 457 .suspend = sa1100_mtd_suspend,
461 .resume = sa1100_mtd_resume, 458 .resume = sa1100_mtd_resume,
462 .shutdown = sa1100_mtd_shutdown, 459 .shutdown = sa1100_mtd_shutdown,
460 .driver = {
461 .name = "flash",
462 },
463}; 463};
464 464
465static int __init sa1100_mtd_init(void) 465static int __init sa1100_mtd_init(void)
466{ 466{
467 return driver_register(&sa1100_mtd_driver); 467 return platform_driver_register(&sa1100_mtd_driver);
468} 468}
469 469
470static void __exit sa1100_mtd_exit(void) 470static void __exit sa1100_mtd_exit(void)
471{ 471{
472 driver_unregister(&sa1100_mtd_driver); 472 platform_driver_unregister(&sa1100_mtd_driver);
473} 473}
474 474
475module_init(sa1100_mtd_init); 475module_init(sa1100_mtd_init);
diff --git a/drivers/mtd/maps/sc520cdp.c b/drivers/mtd/maps/sc520cdp.c
index 6fb9f3c57aab..ed92afadd8a9 100644
--- a/drivers/mtd/maps/sc520cdp.c
+++ b/drivers/mtd/maps/sc520cdp.c
@@ -16,7 +16,7 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18 * 18 *
19 * $Id: sc520cdp.c,v 1.22 2005/11/07 11:14:28 gleixner Exp $ 19 * $Id: sc520cdp.c,v 1.23 2005/11/17 08:20:27 dwmw2 Exp $
20 * 20 *
21 * 21 *
22 * The SC520CDP is an evaluation board for the Elan SC520 processor available 22 * The SC520CDP is an evaluation board for the Elan SC520 processor available
@@ -164,7 +164,7 @@ struct sc520_par_table
164 unsigned long default_address; 164 unsigned long default_address;
165}; 165};
166 166
167static struct sc520_par_table par_table[NUM_FLASH_BANKS] = 167static const struct sc520_par_table par_table[NUM_FLASH_BANKS] =
168{ 168{
169 { /* Flash Bank #0: selected by ROMCS0 */ 169 { /* Flash Bank #0: selected by ROMCS0 */
170 SC520_PAR_ROMCS0, 170 SC520_PAR_ROMCS0,
diff --git a/drivers/mtd/nand/h1910.c b/drivers/mtd/nand/h1910.c
index 041e4b3358fb..f68f7a99a630 100644
--- a/drivers/mtd/nand/h1910.c
+++ b/drivers/mtd/nand/h1910.c
@@ -112,7 +112,7 @@ static int __init h1910_init (void)
112 if (!machine_is_h1900()) 112 if (!machine_is_h1900())
113 return -ENODEV; 113 return -ENODEV;
114 114
115 nandaddr = __ioremap(0x08000000, 0x1000, 0, 1); 115 nandaddr = ioremap(0x08000000, 0x1000);
116 if (!nandaddr) { 116 if (!nandaddr) {
117 printk("Failed to ioremap nand flash.\n"); 117 printk("Failed to ioremap nand flash.\n");
118 return -ENOMEM; 118 return -ENOMEM;
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index de4500395300..a0af92cc7efd 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -1486,7 +1486,7 @@ ns_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
1486/* 1486/*
1487 * Module initialization function 1487 * Module initialization function
1488 */ 1488 */
1489int __init ns_init_module(void) 1489static int __init ns_init_module(void)
1490{ 1490{
1491 struct nand_chip *chip; 1491 struct nand_chip *chip;
1492 struct nandsim *nand; 1492 struct nandsim *nand;
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 97e9b7892d29..d209214b1318 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -125,14 +125,14 @@ static struct s3c2410_nand_info *s3c2410_nand_mtd_toinfo(struct mtd_info *mtd)
125 return s3c2410_nand_mtd_toours(mtd)->info; 125 return s3c2410_nand_mtd_toours(mtd)->info;
126} 126}
127 127
128static struct s3c2410_nand_info *to_nand_info(struct device *dev) 128static struct s3c2410_nand_info *to_nand_info(struct platform_device *dev)
129{ 129{
130 return dev_get_drvdata(dev); 130 return platform_get_drvdata(dev);
131} 131}
132 132
133static struct s3c2410_platform_nand *to_nand_plat(struct device *dev) 133static struct s3c2410_platform_nand *to_nand_plat(struct platform_device *dev)
134{ 134{
135 return dev->platform_data; 135 return dev->dev.platform_data;
136} 136}
137 137
138/* timing calculations */ 138/* timing calculations */
@@ -165,9 +165,9 @@ static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max)
165/* controller setup */ 165/* controller setup */
166 166
167static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, 167static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
168 struct device *dev) 168 struct platform_device *pdev)
169{ 169{
170 struct s3c2410_platform_nand *plat = to_nand_plat(dev); 170 struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
171 unsigned long clkrate = clk_get_rate(info->clk); 171 unsigned long clkrate = clk_get_rate(info->clk);
172 int tacls, twrph0, twrph1; 172 int tacls, twrph0, twrph1;
173 unsigned long cfg; 173 unsigned long cfg;
@@ -430,11 +430,11 @@ static void s3c2410_nand_write_buf(struct mtd_info *mtd,
430 430
431/* device management functions */ 431/* device management functions */
432 432
433static int s3c2410_nand_remove(struct device *dev) 433static int s3c2410_nand_remove(struct platform_device *pdev)
434{ 434{
435 struct s3c2410_nand_info *info = to_nand_info(dev); 435 struct s3c2410_nand_info *info = to_nand_info(pdev);
436 436
437 dev_set_drvdata(dev, NULL); 437 platform_set_drvdata(pdev, NULL);
438 438
439 if (info == NULL) 439 if (info == NULL)
440 return 0; 440 return 0;
@@ -562,10 +562,9 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
562 * nand layer to look for devices 562 * nand layer to look for devices
563*/ 563*/
564 564
565static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440) 565static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440)
566{ 566{
567 struct platform_device *pdev = to_platform_device(dev); 567 struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
568 struct s3c2410_platform_nand *plat = to_nand_plat(dev);
569 struct s3c2410_nand_info *info; 568 struct s3c2410_nand_info *info;
570 struct s3c2410_nand_mtd *nmtd; 569 struct s3c2410_nand_mtd *nmtd;
571 struct s3c2410_nand_set *sets; 570 struct s3c2410_nand_set *sets;
@@ -575,26 +574,26 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
575 int nr_sets; 574 int nr_sets;
576 int setno; 575 int setno;
577 576
578 pr_debug("s3c2410_nand_probe(%p)\n", dev); 577 pr_debug("s3c2410_nand_probe(%p)\n", pdev);
579 578
580 info = kmalloc(sizeof(*info), GFP_KERNEL); 579 info = kmalloc(sizeof(*info), GFP_KERNEL);
581 if (info == NULL) { 580 if (info == NULL) {
582 dev_err(dev, "no memory for flash info\n"); 581 dev_err(&pdev->dev, "no memory for flash info\n");
583 err = -ENOMEM; 582 err = -ENOMEM;
584 goto exit_error; 583 goto exit_error;
585 } 584 }
586 585
587 memzero(info, sizeof(*info)); 586 memzero(info, sizeof(*info));
588 dev_set_drvdata(dev, info); 587 platform_set_drvdata(pdev, info);
589 588
590 spin_lock_init(&info->controller.lock); 589 spin_lock_init(&info->controller.lock);
591 init_waitqueue_head(&info->controller.wq); 590 init_waitqueue_head(&info->controller.wq);
592 591
593 /* get the clock source and enable it */ 592 /* get the clock source and enable it */
594 593
595 info->clk = clk_get(dev, "nand"); 594 info->clk = clk_get(&pdev->dev, "nand");
596 if (IS_ERR(info->clk)) { 595 if (IS_ERR(info->clk)) {
597 dev_err(dev, "failed to get clock"); 596 dev_err(&pdev->dev, "failed to get clock");
598 err = -ENOENT; 597 err = -ENOENT;
599 goto exit_error; 598 goto exit_error;
600 } 599 }
@@ -611,27 +610,27 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
611 info->area = request_mem_region(res->start, size, pdev->name); 610 info->area = request_mem_region(res->start, size, pdev->name);
612 611
613 if (info->area == NULL) { 612 if (info->area == NULL) {
614 dev_err(dev, "cannot reserve register region\n"); 613 dev_err(&pdev->dev, "cannot reserve register region\n");
615 err = -ENOENT; 614 err = -ENOENT;
616 goto exit_error; 615 goto exit_error;
617 } 616 }
618 617
619 info->device = dev; 618 info->device = &pdev->dev;
620 info->platform = plat; 619 info->platform = plat;
621 info->regs = ioremap(res->start, size); 620 info->regs = ioremap(res->start, size);
622 info->is_s3c2440 = is_s3c2440; 621 info->is_s3c2440 = is_s3c2440;
623 622
624 if (info->regs == NULL) { 623 if (info->regs == NULL) {
625 dev_err(dev, "cannot reserve register region\n"); 624 dev_err(&pdev->dev, "cannot reserve register region\n");
626 err = -EIO; 625 err = -EIO;
627 goto exit_error; 626 goto exit_error;
628 } 627 }
629 628
630 dev_dbg(dev, "mapped registers at %p\n", info->regs); 629 dev_dbg(&pdev->dev, "mapped registers at %p\n", info->regs);
631 630
632 /* initialise the hardware */ 631 /* initialise the hardware */
633 632
634 err = s3c2410_nand_inithw(info, dev); 633 err = s3c2410_nand_inithw(info, pdev);
635 if (err != 0) 634 if (err != 0)
636 goto exit_error; 635 goto exit_error;
637 636
@@ -645,7 +644,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
645 size = nr_sets * sizeof(*info->mtds); 644 size = nr_sets * sizeof(*info->mtds);
646 info->mtds = kmalloc(size, GFP_KERNEL); 645 info->mtds = kmalloc(size, GFP_KERNEL);
647 if (info->mtds == NULL) { 646 if (info->mtds == NULL) {
648 dev_err(dev, "failed to allocate mtd storage\n"); 647 dev_err(&pdev->dev, "failed to allocate mtd storage\n");
649 err = -ENOMEM; 648 err = -ENOMEM;
650 goto exit_error; 649 goto exit_error;
651 } 650 }
@@ -677,7 +676,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
677 return 0; 676 return 0;
678 677
679 exit_error: 678 exit_error:
680 s3c2410_nand_remove(dev); 679 s3c2410_nand_remove(pdev);
681 680
682 if (err == 0) 681 if (err == 0)
683 err = -EINVAL; 682 err = -EINVAL;
@@ -686,44 +685,46 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
686 685
687/* driver device registration */ 686/* driver device registration */
688 687
689static int s3c2410_nand_probe(struct device *dev) 688static int s3c2410_nand_probe(struct platform_device *dev)
690{ 689{
691 return s3c24xx_nand_probe(dev, 0); 690 return s3c24xx_nand_probe(dev, 0);
692} 691}
693 692
694static int s3c2440_nand_probe(struct device *dev) 693static int s3c2440_nand_probe(struct platform_device *dev)
695{ 694{
696 return s3c24xx_nand_probe(dev, 1); 695 return s3c24xx_nand_probe(dev, 1);
697} 696}
698 697
699static struct device_driver s3c2410_nand_driver = { 698static struct platform_driver s3c2410_nand_driver = {
700 .name = "s3c2410-nand",
701 .owner = THIS_MODULE,
702 .bus = &platform_bus_type,
703 .probe = s3c2410_nand_probe, 699 .probe = s3c2410_nand_probe,
704 .remove = s3c2410_nand_remove, 700 .remove = s3c2410_nand_remove,
701 .driver = {
702 .name = "s3c2410-nand",
703 .owner = THIS_MODULE,
704 },
705}; 705};
706 706
707static struct device_driver s3c2440_nand_driver = { 707static struct platform_driver s3c2440_nand_driver = {
708 .name = "s3c2440-nand",
709 .owner = THIS_MODULE,
710 .bus = &platform_bus_type,
711 .probe = s3c2440_nand_probe, 708 .probe = s3c2440_nand_probe,
712 .remove = s3c2410_nand_remove, 709 .remove = s3c2410_nand_remove,
710 .driver = {
711 .name = "s3c2440-nand",
712 .owner = THIS_MODULE,
713 },
713}; 714};
714 715
715static int __init s3c2410_nand_init(void) 716static int __init s3c2410_nand_init(void)
716{ 717{
717 printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n"); 718 printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n");
718 719
719 driver_register(&s3c2440_nand_driver); 720 platform_driver_register(&s3c2440_nand_driver);
720 return driver_register(&s3c2410_nand_driver); 721 return platform_driver_register(&s3c2410_nand_driver);
721} 722}
722 723
723static void __exit s3c2410_nand_exit(void) 724static void __exit s3c2410_nand_exit(void)
724{ 725{
725 driver_unregister(&s3c2440_nand_driver); 726 platform_driver_unregister(&s3c2440_nand_driver);
726 driver_unregister(&s3c2410_nand_driver); 727 platform_driver_unregister(&s3c2410_nand_driver);
727} 728}
728 729
729module_init(s3c2410_nand_init); 730module_init(s3c2410_nand_init);
diff --git a/drivers/mtd/onenand/generic.c b/drivers/mtd/onenand/generic.c
index 48cce431f89f..45c077d0f063 100644
--- a/drivers/mtd/onenand/generic.c
+++ b/drivers/mtd/onenand/generic.c
@@ -12,9 +12,9 @@
12 * This is a device driver for the OneNAND flash for generic boards. 12 * This is a device driver for the OneNAND flash for generic boards.
13 */ 13 */
14 14
15#include <linux/device.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/mtd/mtd.h> 18#include <linux/mtd/mtd.h>
19#include <linux/mtd/onenand.h> 19#include <linux/mtd/onenand.h>
20#include <linux/mtd/partitions.h> 20#include <linux/mtd/partitions.h>
@@ -39,7 +39,7 @@ static int __devinit generic_onenand_probe(struct device *dev)
39{ 39{
40 struct onenand_info *info; 40 struct onenand_info *info;
41 struct platform_device *pdev = to_platform_device(dev); 41 struct platform_device *pdev = to_platform_device(dev);
42 struct onenand_platform_data *pdata = pdev->dev.platform_data; 42 struct flash_platform_data *pdata = pdev->dev.platform_data;
43 struct resource *res = pdev->resource; 43 struct resource *res = pdev->resource;
44 unsigned long size = res->end - res->start + 1; 44 unsigned long size = res->end - res->start + 1;
45 int err; 45 int err;
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index f67d5d6eb9a6..a53a73fc2a5a 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -940,7 +940,7 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
940 u_char *eccbuf, struct nand_oobinfo *oobsel) 940 u_char *eccbuf, struct nand_oobinfo *oobsel)
941{ 941{
942 struct onenand_chip *this = mtd->priv; 942 struct onenand_chip *this = mtd->priv;
943 unsigned char buffer[MAX_ONENAND_PAGESIZE], *pbuf; 943 unsigned char *pbuf;
944 size_t total_len, len; 944 size_t total_len, len;
945 int i, written = 0; 945 int i, written = 0;
946 int ret = 0; 946 int ret = 0;
@@ -975,7 +975,7 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
975 /* Loop until all keve's data has been written */ 975 /* Loop until all keve's data has been written */
976 len = 0; 976 len = 0;
977 while (count) { 977 while (count) {
978 pbuf = buffer; 978 pbuf = this->page_buf;
979 /* 979 /*
980 * If the given tuple is >= pagesize then 980 * If the given tuple is >= pagesize then
981 * write it out from the iov 981 * write it out from the iov
@@ -995,7 +995,7 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
995 int cnt = 0, thislen; 995 int cnt = 0, thislen;
996 while (cnt < mtd->oobblock) { 996 while (cnt < mtd->oobblock) {
997 thislen = min_t(int, mtd->oobblock - cnt, vecs->iov_len - len); 997 thislen = min_t(int, mtd->oobblock - cnt, vecs->iov_len - len);
998 memcpy(buffer + cnt, vecs->iov_base + len, thislen); 998 memcpy(this->page_buf + cnt, vecs->iov_base + len, thislen);
999 cnt += thislen; 999 cnt += thislen;
1000 len += thislen; 1000 len += thislen;
1001 1001
@@ -1296,6 +1296,12 @@ static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
1296 1296
1297 /* Block lock scheme */ 1297 /* Block lock scheme */
1298 for (block = start; block < end; block++) { 1298 for (block = start; block < end; block++) {
1299 /* Set block address */
1300 value = onenand_block_address(this, block);
1301 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
1302 /* Select DataRAM for DDP */
1303 value = onenand_bufferram_address(this, block);
1304 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
1299 /* Set start block address */ 1305 /* Set start block address */
1300 this->write_word(block, this->base + ONENAND_REG_START_BLOCK_ADDRESS); 1306 this->write_word(block, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
1301 /* Write unlock command */ 1307 /* Write unlock command */
@@ -1309,10 +1315,6 @@ static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
1309 & ONENAND_CTRL_ONGO) 1315 & ONENAND_CTRL_ONGO)
1310 continue; 1316 continue;
1311 1317
1312 /* Set block address for read block status */
1313 value = onenand_block_address(this, block);
1314 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
1315
1316 /* Check lock status */ 1318 /* Check lock status */
1317 status = this->read_word(this->base + ONENAND_REG_WP_STATUS); 1319 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
1318 if (!(status & ONENAND_WP_US)) 1320 if (!(status & ONENAND_WP_US))
@@ -1346,7 +1348,6 @@ static void onenand_print_device_info(int device)
1346 1348
1347static const struct onenand_manufacturers onenand_manuf_ids[] = { 1349static const struct onenand_manufacturers onenand_manuf_ids[] = {
1348 {ONENAND_MFR_SAMSUNG, "Samsung"}, 1350 {ONENAND_MFR_SAMSUNG, "Samsung"},
1349 {ONENAND_MFR_UNKNOWN, "Unknown"}
1350}; 1351};
1351 1352
1352/** 1353/**
@@ -1357,17 +1358,22 @@ static const struct onenand_manufacturers onenand_manuf_ids[] = {
1357 */ 1358 */
1358static int onenand_check_maf(int manuf) 1359static int onenand_check_maf(int manuf)
1359{ 1360{
1361 int size = ARRAY_SIZE(onenand_manuf_ids);
1362 char *name;
1360 int i; 1363 int i;
1361 1364
1362 for (i = 0; onenand_manuf_ids[i].id; i++) { 1365 for (i = 0; i < size; i++)
1363 if (manuf == onenand_manuf_ids[i].id) 1366 if (manuf == onenand_manuf_ids[i].id)
1364 break; 1367 break;
1365 }
1366 1368
1367 printk(KERN_DEBUG "OneNAND Manufacturer: %s (0x%0x)\n", 1369 if (i < size)
1368 onenand_manuf_ids[i].name, manuf); 1370 name = onenand_manuf_ids[i].name;
1371 else
1372 name = "Unknown";
1373
1374 printk(KERN_DEBUG "OneNAND Manufacturer: %s (0x%0x)\n", name, manuf);
1369 1375
1370 return (i != ONENAND_MFR_UNKNOWN); 1376 return (i == size);
1371} 1377}
1372 1378
1373/** 1379/**
@@ -1513,6 +1519,18 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
1513 this->read_bufferram = onenand_sync_read_bufferram; 1519 this->read_bufferram = onenand_sync_read_bufferram;
1514 } 1520 }
1515 1521
1522 /* Allocate buffers, if necessary */
1523 if (!this->page_buf) {
1524 size_t len;
1525 len = mtd->oobblock + mtd->oobsize;
1526 this->page_buf = kmalloc(len, GFP_KERNEL);
1527 if (!this->page_buf) {
1528 printk(KERN_ERR "onenand_scan(): Can't allocate page_buf\n");
1529 return -ENOMEM;
1530 }
1531 this->options |= ONENAND_PAGEBUF_ALLOC;
1532 }
1533
1516 this->state = FL_READY; 1534 this->state = FL_READY;
1517 init_waitqueue_head(&this->wq); 1535 init_waitqueue_head(&this->wq);
1518 spin_lock_init(&this->chip_lock); 1536 spin_lock_init(&this->chip_lock);
@@ -1574,12 +1592,21 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
1574 */ 1592 */
1575void onenand_release(struct mtd_info *mtd) 1593void onenand_release(struct mtd_info *mtd)
1576{ 1594{
1595 struct onenand_chip *this = mtd->priv;
1596
1577#ifdef CONFIG_MTD_PARTITIONS 1597#ifdef CONFIG_MTD_PARTITIONS
1578 /* Deregister partitions */ 1598 /* Deregister partitions */
1579 del_mtd_partitions (mtd); 1599 del_mtd_partitions (mtd);
1580#endif 1600#endif
1581 /* Deregister the device */ 1601 /* Deregister the device */
1582 del_mtd_device (mtd); 1602 del_mtd_device (mtd);
1603
1604 /* Free bad block table memory, if allocated */
1605 if (this->bbm)
1606 kfree(this->bbm);
1607 /* Buffer allocated by onenand_scan */
1608 if (this->options & ONENAND_PAGEBUF_ALLOC)
1609 kfree(this->page_buf);
1583} 1610}
1584 1611
1585EXPORT_SYMBOL_GPL(onenand_scan); 1612EXPORT_SYMBOL_GPL(onenand_scan);
diff --git a/drivers/mtd/onenand/onenand_bbt.c b/drivers/mtd/onenand/onenand_bbt.c
index f40190f499e1..4510d3361eaa 100644
--- a/drivers/mtd/onenand/onenand_bbt.c
+++ b/drivers/mtd/onenand/onenand_bbt.c
@@ -118,10 +118,10 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
118 */ 118 */
119static inline int onenand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) 119static inline int onenand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd)
120{ 120{
121 unsigned char data_buf[MAX_ONENAND_PAGESIZE]; 121 struct onenand_chip *this = mtd->priv;
122 122
123 bd->options &= ~NAND_BBT_SCANEMPTY; 123 bd->options &= ~NAND_BBT_SCANEMPTY;
124 return create_bbt(mtd, data_buf, bd, -1); 124 return create_bbt(mtd, this->page_buf, bd, -1);
125} 125}
126 126
127/** 127/**
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index 0ab8d29caeea..20ce212638fc 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -30,11 +30,9 @@ MODULE_PARM_DESC(block_size, "Block size to use by RFD, defaults to erase unit s
30 30
31#define PREFIX "rfd_ftl: " 31#define PREFIX "rfd_ftl: "
32 32
33/* Major device # for FTL device */ 33/* This major has been assigned by device@lanana.org */
34
35/* A request for this major has been sent to device@lanana.org */
36#ifndef RFD_FTL_MAJOR 34#ifndef RFD_FTL_MAJOR
37#define RFD_FTL_MAJOR 95 35#define RFD_FTL_MAJOR 256
38#endif 36#endif
39 37
40/* Maximum number of partitions in an FTL region */ 38/* Maximum number of partitions in an FTL region */