aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/chips
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-30 20:31:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-30 20:31:56 -0400
commit623ff7739e7c00fa3d55dbfd42a492a68298fd7a (patch)
tree0b7461753a1b13b27ea2958a7d48c6efb47bba54 /drivers/mtd/chips
parentc39e8ede284f469971589f2e04af78216e1a771d (diff)
parent7b0e67f604e1829e5292e1ad7743eb18dc42ea7c (diff)
Merge tag 'for-linus-3.4' of git://git.infradead.org/mtd-2.6
Pull MTD changes from David Woodhouse: - Artem's cleanup of the MTD API continues apace. - Fixes and improvements for ST FSMC and SuperH FLCTL NAND, amongst others. - More work on DiskOnChip G3, new driver for DiskOnChip G4. - Clean up debug/warning printks in JFFS2 to use pr_<level>. Fix up various trivial conflicts, largely due to changes in calling conventions for things like dmaengine_prep_slave_sg() (new inline wrapper to hide new parameter, clashing with rewrite of previously last parameter that used to be an 'append' flag, and is now a bitmap of 'unsigned long flags'). (Also some header file fallout - like so many merges this merge window - and silly conflicts with sparse fixes) * tag 'for-linus-3.4' of git://git.infradead.org/mtd-2.6: (120 commits) mtd: docg3 add protection against concurrency mtd: docg3 refactor cascade floors structure mtd: docg3 increase write/erase timeout mtd: docg3 fix inbound calculations mtd: nand: gpmi: fix function annotations mtd: phram: fix section mismatch for phram_setup mtd: unify initialization of erase_info->fail_addr mtd: support ONFI multi lun NAND mtd: sm_ftl: fix typo in major number. mtd: add device-tree support to spear_smi mtd: spear_smi: Remove default partition information from driver mtd: Add device-tree support to fsmc_nand mtd: fix section mismatch for doc_probe_device mtd: nand/fsmc: Remove sparse warnings and errors mtd: nand/fsmc: Add DMA support mtd: nand/fsmc: Access the NAND device word by word whenever possible mtd: nand/fsmc: Use dev_err to report error scenario mtd: nand/fsmc: Use devm routines mtd: nand/fsmc: Modify fsmc driver to accept nand timing parameters via platform mtd: fsmc_nand: add pm callbacks to support hibernation ...
Diffstat (limited to 'drivers/mtd/chips')
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c83
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c283
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0020.c33
-rw-r--r--drivers/mtd/chips/cfi_util.c6
-rw-r--r--drivers/mtd/chips/fwh_lock.h4
-rw-r--r--drivers/mtd/chips/map_absent.c10
-rw-r--r--drivers/mtd/chips/map_ram.c14
-rw-r--r--drivers/mtd/chips/map_rom.c13
8 files changed, 319 insertions, 127 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 9bcd1f415f43..dbbd2edfb812 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -87,7 +87,7 @@ static int cfi_intelext_partition_fixup(struct mtd_info *, struct cfi_private **
87 87
88static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, 88static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len,
89 size_t *retlen, void **virt, resource_size_t *phys); 89 size_t *retlen, void **virt, resource_size_t *phys);
90static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len); 90static int cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len);
91 91
92static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode); 92static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode);
93static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode); 93static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode);
@@ -262,9 +262,9 @@ static void fixup_st_m28w320cb(struct mtd_info *mtd)
262static void fixup_use_point(struct mtd_info *mtd) 262static void fixup_use_point(struct mtd_info *mtd)
263{ 263{
264 struct map_info *map = mtd->priv; 264 struct map_info *map = mtd->priv;
265 if (!mtd->point && map_is_linear(map)) { 265 if (!mtd->_point && map_is_linear(map)) {
266 mtd->point = cfi_intelext_point; 266 mtd->_point = cfi_intelext_point;
267 mtd->unpoint = cfi_intelext_unpoint; 267 mtd->_unpoint = cfi_intelext_unpoint;
268 } 268 }
269} 269}
270 270
@@ -274,8 +274,8 @@ static void fixup_use_write_buffers(struct mtd_info *mtd)
274 struct cfi_private *cfi = map->fldrv_priv; 274 struct cfi_private *cfi = map->fldrv_priv;
275 if (cfi->cfiq->BufWriteTimeoutTyp) { 275 if (cfi->cfiq->BufWriteTimeoutTyp) {
276 printk(KERN_INFO "Using buffer write method\n" ); 276 printk(KERN_INFO "Using buffer write method\n" );
277 mtd->write = cfi_intelext_write_buffers; 277 mtd->_write = cfi_intelext_write_buffers;
278 mtd->writev = cfi_intelext_writev; 278 mtd->_writev = cfi_intelext_writev;
279 } 279 }
280} 280}
281 281
@@ -443,15 +443,15 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
443 mtd->type = MTD_NORFLASH; 443 mtd->type = MTD_NORFLASH;
444 444
445 /* Fill in the default mtd operations */ 445 /* Fill in the default mtd operations */
446 mtd->erase = cfi_intelext_erase_varsize; 446 mtd->_erase = cfi_intelext_erase_varsize;
447 mtd->read = cfi_intelext_read; 447 mtd->_read = cfi_intelext_read;
448 mtd->write = cfi_intelext_write_words; 448 mtd->_write = cfi_intelext_write_words;
449 mtd->sync = cfi_intelext_sync; 449 mtd->_sync = cfi_intelext_sync;
450 mtd->lock = cfi_intelext_lock; 450 mtd->_lock = cfi_intelext_lock;
451 mtd->unlock = cfi_intelext_unlock; 451 mtd->_unlock = cfi_intelext_unlock;
452 mtd->is_locked = cfi_intelext_is_locked; 452 mtd->_is_locked = cfi_intelext_is_locked;
453 mtd->suspend = cfi_intelext_suspend; 453 mtd->_suspend = cfi_intelext_suspend;
454 mtd->resume = cfi_intelext_resume; 454 mtd->_resume = cfi_intelext_resume;
455 mtd->flags = MTD_CAP_NORFLASH; 455 mtd->flags = MTD_CAP_NORFLASH;
456 mtd->name = map->name; 456 mtd->name = map->name;
457 mtd->writesize = 1; 457 mtd->writesize = 1;
@@ -600,12 +600,12 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
600 } 600 }
601 601
602#ifdef CONFIG_MTD_OTP 602#ifdef CONFIG_MTD_OTP
603 mtd->read_fact_prot_reg = cfi_intelext_read_fact_prot_reg; 603 mtd->_read_fact_prot_reg = cfi_intelext_read_fact_prot_reg;
604 mtd->read_user_prot_reg = cfi_intelext_read_user_prot_reg; 604 mtd->_read_user_prot_reg = cfi_intelext_read_user_prot_reg;
605 mtd->write_user_prot_reg = cfi_intelext_write_user_prot_reg; 605 mtd->_write_user_prot_reg = cfi_intelext_write_user_prot_reg;
606 mtd->lock_user_prot_reg = cfi_intelext_lock_user_prot_reg; 606 mtd->_lock_user_prot_reg = cfi_intelext_lock_user_prot_reg;
607 mtd->get_fact_prot_info = cfi_intelext_get_fact_prot_info; 607 mtd->_get_fact_prot_info = cfi_intelext_get_fact_prot_info;
608 mtd->get_user_prot_info = cfi_intelext_get_user_prot_info; 608 mtd->_get_user_prot_info = cfi_intelext_get_user_prot_info;
609#endif 609#endif
610 610
611 /* This function has the potential to distort the reality 611 /* This function has the potential to distort the reality
@@ -1017,8 +1017,6 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
1017 case FL_READY: 1017 case FL_READY:
1018 case FL_STATUS: 1018 case FL_STATUS:
1019 case FL_JEDEC_QUERY: 1019 case FL_JEDEC_QUERY:
1020 /* We should really make set_vpp() count, rather than doing this */
1021 DISABLE_VPP(map);
1022 break; 1020 break;
1023 default: 1021 default:
1024 printk(KERN_ERR "%s: put_chip() called with oldstate %d!!\n", map->name, chip->oldstate); 1022 printk(KERN_ERR "%s: put_chip() called with oldstate %d!!\n", map->name, chip->oldstate);
@@ -1324,7 +1322,7 @@ static int cfi_intelext_point(struct mtd_info *mtd, loff_t from, size_t len,
1324 int chipnum; 1322 int chipnum;
1325 int ret = 0; 1323 int ret = 0;
1326 1324
1327 if (!map->virt || (from + len > mtd->size)) 1325 if (!map->virt)
1328 return -EINVAL; 1326 return -EINVAL;
1329 1327
1330 /* Now lock the chip(s) to POINT state */ 1328 /* Now lock the chip(s) to POINT state */
@@ -1334,7 +1332,6 @@ static int cfi_intelext_point(struct mtd_info *mtd, loff_t from, size_t len,
1334 ofs = from - (chipnum << cfi->chipshift); 1332 ofs = from - (chipnum << cfi->chipshift);
1335 1333
1336 *virt = map->virt + cfi->chips[chipnum].start + ofs; 1334 *virt = map->virt + cfi->chips[chipnum].start + ofs;
1337 *retlen = 0;
1338 if (phys) 1335 if (phys)
1339 *phys = map->phys + cfi->chips[chipnum].start + ofs; 1336 *phys = map->phys + cfi->chips[chipnum].start + ofs;
1340 1337
@@ -1369,12 +1366,12 @@ static int cfi_intelext_point(struct mtd_info *mtd, loff_t from, size_t len,
1369 return 0; 1366 return 0;
1370} 1367}
1371 1368
1372static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) 1369static int cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
1373{ 1370{
1374 struct map_info *map = mtd->priv; 1371 struct map_info *map = mtd->priv;
1375 struct cfi_private *cfi = map->fldrv_priv; 1372 struct cfi_private *cfi = map->fldrv_priv;
1376 unsigned long ofs; 1373 unsigned long ofs;
1377 int chipnum; 1374 int chipnum, err = 0;
1378 1375
1379 /* Now unlock the chip(s) POINT state */ 1376 /* Now unlock the chip(s) POINT state */
1380 1377
@@ -1382,7 +1379,7 @@ static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
1382 chipnum = (from >> cfi->chipshift); 1379 chipnum = (from >> cfi->chipshift);
1383 ofs = from - (chipnum << cfi->chipshift); 1380 ofs = from - (chipnum << cfi->chipshift);
1384 1381
1385 while (len) { 1382 while (len && !err) {
1386 unsigned long thislen; 1383 unsigned long thislen;
1387 struct flchip *chip; 1384 struct flchip *chip;
1388 1385
@@ -1400,8 +1397,10 @@ static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
1400 chip->ref_point_counter--; 1397 chip->ref_point_counter--;
1401 if(chip->ref_point_counter == 0) 1398 if(chip->ref_point_counter == 0)
1402 chip->state = FL_READY; 1399 chip->state = FL_READY;
1403 } else 1400 } else {
1404 printk(KERN_ERR "%s: Warning: unpoint called on non pointed region\n", map->name); /* Should this give an error? */ 1401 printk(KERN_ERR "%s: Error: unpoint called on non pointed region\n", map->name);
1402 err = -EINVAL;
1403 }
1405 1404
1406 put_chip(map, chip, chip->start); 1405 put_chip(map, chip, chip->start);
1407 mutex_unlock(&chip->mutex); 1406 mutex_unlock(&chip->mutex);
@@ -1410,6 +1409,8 @@ static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len)
1410 ofs = 0; 1409 ofs = 0;
1411 chipnum++; 1410 chipnum++;
1412 } 1411 }
1412
1413 return err;
1413} 1414}
1414 1415
1415static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf) 1416static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf)
@@ -1456,8 +1457,6 @@ static int cfi_intelext_read (struct mtd_info *mtd, loff_t from, size_t len, siz
1456 chipnum = (from >> cfi->chipshift); 1457 chipnum = (from >> cfi->chipshift);
1457 ofs = from - (chipnum << cfi->chipshift); 1458 ofs = from - (chipnum << cfi->chipshift);
1458 1459
1459 *retlen = 0;
1460
1461 while (len) { 1460 while (len) {
1462 unsigned long thislen; 1461 unsigned long thislen;
1463 1462
@@ -1551,7 +1550,8 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1551 } 1550 }
1552 1551
1553 xip_enable(map, chip, adr); 1552 xip_enable(map, chip, adr);
1554 out: put_chip(map, chip, adr); 1553 out: DISABLE_VPP(map);
1554 put_chip(map, chip, adr);
1555 mutex_unlock(&chip->mutex); 1555 mutex_unlock(&chip->mutex);
1556 return ret; 1556 return ret;
1557} 1557}
@@ -1565,10 +1565,6 @@ static int cfi_intelext_write_words (struct mtd_info *mtd, loff_t to , size_t le
1565 int chipnum; 1565 int chipnum;
1566 unsigned long ofs; 1566 unsigned long ofs;
1567 1567
1568 *retlen = 0;
1569 if (!len)
1570 return 0;
1571
1572 chipnum = to >> cfi->chipshift; 1568 chipnum = to >> cfi->chipshift;
1573 ofs = to - (chipnum << cfi->chipshift); 1569 ofs = to - (chipnum << cfi->chipshift);
1574 1570
@@ -1794,7 +1790,8 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1794 } 1790 }
1795 1791
1796 xip_enable(map, chip, cmd_adr); 1792 xip_enable(map, chip, cmd_adr);
1797 out: put_chip(map, chip, cmd_adr); 1793 out: DISABLE_VPP(map);
1794 put_chip(map, chip, cmd_adr);
1798 mutex_unlock(&chip->mutex); 1795 mutex_unlock(&chip->mutex);
1799 return ret; 1796 return ret;
1800} 1797}
@@ -1813,7 +1810,6 @@ static int cfi_intelext_writev (struct mtd_info *mtd, const struct kvec *vecs,
1813 for (i = 0; i < count; i++) 1810 for (i = 0; i < count; i++)
1814 len += vecs[i].iov_len; 1811 len += vecs[i].iov_len;
1815 1812
1816 *retlen = 0;
1817 if (!len) 1813 if (!len)
1818 return 0; 1814 return 0;
1819 1815
@@ -1932,6 +1928,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1932 ret = -EIO; 1928 ret = -EIO;
1933 } else if (chipstatus & 0x20 && retries--) { 1929 } else if (chipstatus & 0x20 && retries--) {
1934 printk(KERN_DEBUG "block erase failed at 0x%08lx: status 0x%lx. Retrying...\n", adr, chipstatus); 1930 printk(KERN_DEBUG "block erase failed at 0x%08lx: status 0x%lx. Retrying...\n", adr, chipstatus);
1931 DISABLE_VPP(map);
1935 put_chip(map, chip, adr); 1932 put_chip(map, chip, adr);
1936 mutex_unlock(&chip->mutex); 1933 mutex_unlock(&chip->mutex);
1937 goto retry; 1934 goto retry;
@@ -1944,7 +1941,8 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1944 } 1941 }
1945 1942
1946 xip_enable(map, chip, adr); 1943 xip_enable(map, chip, adr);
1947 out: put_chip(map, chip, adr); 1944 out: DISABLE_VPP(map);
1945 put_chip(map, chip, adr);
1948 mutex_unlock(&chip->mutex); 1946 mutex_unlock(&chip->mutex);
1949 return ret; 1947 return ret;
1950} 1948}
@@ -2086,7 +2084,8 @@ static int __xipram do_xxlock_oneblock(struct map_info *map, struct flchip *chip
2086 } 2084 }
2087 2085
2088 xip_enable(map, chip, adr); 2086 xip_enable(map, chip, adr);
2089out: put_chip(map, chip, adr); 2087 out: DISABLE_VPP(map);
2088 put_chip(map, chip, adr);
2090 mutex_unlock(&chip->mutex); 2089 mutex_unlock(&chip->mutex);
2091 return ret; 2090 return ret;
2092} 2091}
@@ -2483,7 +2482,7 @@ static int cfi_intelext_suspend(struct mtd_info *mtd)
2483 allowed to. Or should we return -EAGAIN, because the upper layers 2482 allowed to. Or should we return -EAGAIN, because the upper layers
2484 ought to have already shut down anything which was using the device 2483 ought to have already shut down anything which was using the device
2485 anyway? The latter for now. */ 2484 anyway? The latter for now. */
2486 printk(KERN_NOTICE "Flash device refused suspend due to active operation (state %d)\n", chip->oldstate); 2485 printk(KERN_NOTICE "Flash device refused suspend due to active operation (state %d)\n", chip->state);
2487 ret = -EAGAIN; 2486 ret = -EAGAIN;
2488 case FL_PM_SUSPENDED: 2487 case FL_PM_SUSPENDED:
2489 break; 2488 break;
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index 8d70895a58d6..d02592e6a0f0 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -59,6 +59,9 @@ static void cfi_amdstd_resume (struct mtd_info *);
59static int cfi_amdstd_reboot(struct notifier_block *, unsigned long, void *); 59static int cfi_amdstd_reboot(struct notifier_block *, unsigned long, void *);
60static int cfi_amdstd_secsi_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); 60static int cfi_amdstd_secsi_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
61 61
62static int cfi_amdstd_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
63 size_t *retlen, const u_char *buf);
64
62static void cfi_amdstd_destroy(struct mtd_info *); 65static void cfi_amdstd_destroy(struct mtd_info *);
63 66
64struct mtd_info *cfi_cmdset_0002(struct map_info *, int); 67struct mtd_info *cfi_cmdset_0002(struct map_info *, int);
@@ -189,7 +192,7 @@ static void fixup_use_write_buffers(struct mtd_info *mtd)
189 struct cfi_private *cfi = map->fldrv_priv; 192 struct cfi_private *cfi = map->fldrv_priv;
190 if (cfi->cfiq->BufWriteTimeoutTyp) { 193 if (cfi->cfiq->BufWriteTimeoutTyp) {
191 pr_debug("Using buffer write method\n" ); 194 pr_debug("Using buffer write method\n" );
192 mtd->write = cfi_amdstd_write_buffers; 195 mtd->_write = cfi_amdstd_write_buffers;
193 } 196 }
194} 197}
195 198
@@ -228,8 +231,8 @@ static void fixup_convert_atmel_pri(struct mtd_info *mtd)
228static void fixup_use_secsi(struct mtd_info *mtd) 231static void fixup_use_secsi(struct mtd_info *mtd)
229{ 232{
230 /* Setup for chips with a secsi area */ 233 /* Setup for chips with a secsi area */
231 mtd->read_user_prot_reg = cfi_amdstd_secsi_read; 234 mtd->_read_user_prot_reg = cfi_amdstd_secsi_read;
232 mtd->read_fact_prot_reg = cfi_amdstd_secsi_read; 235 mtd->_read_fact_prot_reg = cfi_amdstd_secsi_read;
233} 236}
234 237
235static void fixup_use_erase_chip(struct mtd_info *mtd) 238static void fixup_use_erase_chip(struct mtd_info *mtd)
@@ -238,7 +241,7 @@ static void fixup_use_erase_chip(struct mtd_info *mtd)
238 struct cfi_private *cfi = map->fldrv_priv; 241 struct cfi_private *cfi = map->fldrv_priv;
239 if ((cfi->cfiq->NumEraseRegions == 1) && 242 if ((cfi->cfiq->NumEraseRegions == 1) &&
240 ((cfi->cfiq->EraseRegionInfo[0] & 0xffff) == 0)) { 243 ((cfi->cfiq->EraseRegionInfo[0] & 0xffff) == 0)) {
241 mtd->erase = cfi_amdstd_erase_chip; 244 mtd->_erase = cfi_amdstd_erase_chip;
242 } 245 }
243 246
244} 247}
@@ -249,8 +252,8 @@ static void fixup_use_erase_chip(struct mtd_info *mtd)
249 */ 252 */
250static void fixup_use_atmel_lock(struct mtd_info *mtd) 253static void fixup_use_atmel_lock(struct mtd_info *mtd)
251{ 254{
252 mtd->lock = cfi_atmel_lock; 255 mtd->_lock = cfi_atmel_lock;
253 mtd->unlock = cfi_atmel_unlock; 256 mtd->_unlock = cfi_atmel_unlock;
254 mtd->flags |= MTD_POWERUP_LOCK; 257 mtd->flags |= MTD_POWERUP_LOCK;
255} 258}
256 259
@@ -429,12 +432,12 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
429 mtd->type = MTD_NORFLASH; 432 mtd->type = MTD_NORFLASH;
430 433
431 /* Fill in the default mtd operations */ 434 /* Fill in the default mtd operations */
432 mtd->erase = cfi_amdstd_erase_varsize; 435 mtd->_erase = cfi_amdstd_erase_varsize;
433 mtd->write = cfi_amdstd_write_words; 436 mtd->_write = cfi_amdstd_write_words;
434 mtd->read = cfi_amdstd_read; 437 mtd->_read = cfi_amdstd_read;
435 mtd->sync = cfi_amdstd_sync; 438 mtd->_sync = cfi_amdstd_sync;
436 mtd->suspend = cfi_amdstd_suspend; 439 mtd->_suspend = cfi_amdstd_suspend;
437 mtd->resume = cfi_amdstd_resume; 440 mtd->_resume = cfi_amdstd_resume;
438 mtd->flags = MTD_CAP_NORFLASH; 441 mtd->flags = MTD_CAP_NORFLASH;
439 mtd->name = map->name; 442 mtd->name = map->name;
440 mtd->writesize = 1; 443 mtd->writesize = 1;
@@ -443,6 +446,7 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
443 pr_debug("MTD %s(): write buffer size %d\n", __func__, 446 pr_debug("MTD %s(): write buffer size %d\n", __func__,
444 mtd->writebufsize); 447 mtd->writebufsize);
445 448
449 mtd->_panic_write = cfi_amdstd_panic_write;
446 mtd->reboot_notifier.notifier_call = cfi_amdstd_reboot; 450 mtd->reboot_notifier.notifier_call = cfi_amdstd_reboot;
447 451
448 if (cfi->cfi_mode==CFI_MODE_CFI){ 452 if (cfi->cfi_mode==CFI_MODE_CFI){
@@ -770,8 +774,6 @@ static void put_chip(struct map_info *map, struct flchip *chip, unsigned long ad
770 774
771 case FL_READY: 775 case FL_READY:
772 case FL_STATUS: 776 case FL_STATUS:
773 /* We should really make set_vpp() count, rather than doing this */
774 DISABLE_VPP(map);
775 break; 777 break;
776 default: 778 default:
777 printk(KERN_ERR "MTD: put_chip() called with oldstate %d!!\n", chip->oldstate); 779 printk(KERN_ERR "MTD: put_chip() called with oldstate %d!!\n", chip->oldstate);
@@ -1013,13 +1015,9 @@ static int cfi_amdstd_read (struct mtd_info *mtd, loff_t from, size_t len, size_
1013 int ret = 0; 1015 int ret = 0;
1014 1016
1015 /* ofs: offset within the first chip that the first read should start */ 1017 /* ofs: offset within the first chip that the first read should start */
1016
1017 chipnum = (from >> cfi->chipshift); 1018 chipnum = (from >> cfi->chipshift);
1018 ofs = from - (chipnum << cfi->chipshift); 1019 ofs = from - (chipnum << cfi->chipshift);
1019 1020
1020
1021 *retlen = 0;
1022
1023 while (len) { 1021 while (len) {
1024 unsigned long thislen; 1022 unsigned long thislen;
1025 1023
@@ -1097,16 +1095,11 @@ static int cfi_amdstd_secsi_read (struct mtd_info *mtd, loff_t from, size_t len,
1097 int chipnum; 1095 int chipnum;
1098 int ret = 0; 1096 int ret = 0;
1099 1097
1100
1101 /* ofs: offset within the first chip that the first read should start */ 1098 /* ofs: offset within the first chip that the first read should start */
1102
1103 /* 8 secsi bytes per chip */ 1099 /* 8 secsi bytes per chip */
1104 chipnum=from>>3; 1100 chipnum=from>>3;
1105 ofs=from & 7; 1101 ofs=from & 7;
1106 1102
1107
1108 *retlen = 0;
1109
1110 while (len) { 1103 while (len) {
1111 unsigned long thislen; 1104 unsigned long thislen;
1112 1105
@@ -1234,6 +1227,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1234 xip_enable(map, chip, adr); 1227 xip_enable(map, chip, adr);
1235 op_done: 1228 op_done:
1236 chip->state = FL_READY; 1229 chip->state = FL_READY;
1230 DISABLE_VPP(map);
1237 put_chip(map, chip, adr); 1231 put_chip(map, chip, adr);
1238 mutex_unlock(&chip->mutex); 1232 mutex_unlock(&chip->mutex);
1239 1233
@@ -1251,10 +1245,6 @@ static int cfi_amdstd_write_words(struct mtd_info *mtd, loff_t to, size_t len,
1251 unsigned long ofs, chipstart; 1245 unsigned long ofs, chipstart;
1252 DECLARE_WAITQUEUE(wait, current); 1246 DECLARE_WAITQUEUE(wait, current);
1253 1247
1254 *retlen = 0;
1255 if (!len)
1256 return 0;
1257
1258 chipnum = to >> cfi->chipshift; 1248 chipnum = to >> cfi->chipshift;
1259 ofs = to - (chipnum << cfi->chipshift); 1249 ofs = to - (chipnum << cfi->chipshift);
1260 chipstart = cfi->chips[chipnum].start; 1250 chipstart = cfi->chips[chipnum].start;
@@ -1476,6 +1466,7 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1476 ret = -EIO; 1466 ret = -EIO;
1477 op_done: 1467 op_done:
1478 chip->state = FL_READY; 1468 chip->state = FL_READY;
1469 DISABLE_VPP(map);
1479 put_chip(map, chip, adr); 1470 put_chip(map, chip, adr);
1480 mutex_unlock(&chip->mutex); 1471 mutex_unlock(&chip->mutex);
1481 1472
@@ -1493,10 +1484,6 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
1493 int chipnum; 1484 int chipnum;
1494 unsigned long ofs; 1485 unsigned long ofs;
1495 1486
1496 *retlen = 0;
1497 if (!len)
1498 return 0;
1499
1500 chipnum = to >> cfi->chipshift; 1487 chipnum = to >> cfi->chipshift;
1501 ofs = to - (chipnum << cfi->chipshift); 1488 ofs = to - (chipnum << cfi->chipshift);
1502 1489
@@ -1562,6 +1549,238 @@ static int cfi_amdstd_write_buffers(struct mtd_info *mtd, loff_t to, size_t len,
1562 return 0; 1549 return 0;
1563} 1550}
1564 1551
1552/*
1553 * Wait for the flash chip to become ready to write data
1554 *
1555 * This is only called during the panic_write() path. When panic_write()
1556 * is called, the kernel is in the process of a panic, and will soon be
1557 * dead. Therefore we don't take any locks, and attempt to get access
1558 * to the chip as soon as possible.
1559 */
1560static int cfi_amdstd_panic_wait(struct map_info *map, struct flchip *chip,
1561 unsigned long adr)
1562{
1563 struct cfi_private *cfi = map->fldrv_priv;
1564 int retries = 10;
1565 int i;
1566
1567 /*
1568 * If the driver thinks the chip is idle, and no toggle bits
1569 * are changing, then the chip is actually idle for sure.
1570 */
1571 if (chip->state == FL_READY && chip_ready(map, adr))
1572 return 0;
1573
1574 /*
1575 * Try several times to reset the chip and then wait for it
1576 * to become idle. The upper limit of a few milliseconds of
1577 * delay isn't a big problem: the kernel is dying anyway. It
1578 * is more important to save the messages.
1579 */
1580 while (retries > 0) {
1581 const unsigned long timeo = (HZ / 1000) + 1;
1582
1583 /* send the reset command */
1584 map_write(map, CMD(0xF0), chip->start);
1585
1586 /* wait for the chip to become ready */
1587 for (i = 0; i < jiffies_to_usecs(timeo); i++) {
1588 if (chip_ready(map, adr))
1589 return 0;
1590
1591 udelay(1);
1592 }
1593 }
1594
1595 /* the chip never became ready */
1596 return -EBUSY;
1597}
1598
1599/*
1600 * Write out one word of data to a single flash chip during a kernel panic
1601 *
1602 * This is only called during the panic_write() path. When panic_write()
1603 * is called, the kernel is in the process of a panic, and will soon be
1604 * dead. Therefore we don't take any locks, and attempt to get access
1605 * to the chip as soon as possible.
1606 *
1607 * The implementation of this routine is intentionally similar to
1608 * do_write_oneword(), in order to ease code maintenance.
1609 */
1610static int do_panic_write_oneword(struct map_info *map, struct flchip *chip,
1611 unsigned long adr, map_word datum)
1612{
1613 const unsigned long uWriteTimeout = (HZ / 1000) + 1;
1614 struct cfi_private *cfi = map->fldrv_priv;
1615 int retry_cnt = 0;
1616 map_word oldd;
1617 int ret = 0;
1618 int i;
1619
1620 adr += chip->start;
1621
1622 ret = cfi_amdstd_panic_wait(map, chip, adr);
1623 if (ret)
1624 return ret;
1625
1626 pr_debug("MTD %s(): PANIC WRITE 0x%.8lx(0x%.8lx)\n",
1627 __func__, adr, datum.x[0]);
1628
1629 /*
1630 * Check for a NOP for the case when the datum to write is already
1631 * present - it saves time and works around buggy chips that corrupt
1632 * data at other locations when 0xff is written to a location that
1633 * already contains 0xff.
1634 */
1635 oldd = map_read(map, adr);
1636 if (map_word_equal(map, oldd, datum)) {
1637 pr_debug("MTD %s(): NOP\n", __func__);
1638 goto op_done;
1639 }
1640
1641 ENABLE_VPP(map);
1642
1643retry:
1644 cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
1645 cfi_send_gen_cmd(0x55, cfi->addr_unlock2, chip->start, map, cfi, cfi->device_type, NULL);
1646 cfi_send_gen_cmd(0xA0, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL);
1647 map_write(map, datum, adr);
1648
1649 for (i = 0; i < jiffies_to_usecs(uWriteTimeout); i++) {
1650 if (chip_ready(map, adr))
1651 break;
1652
1653 udelay(1);
1654 }
1655
1656 if (!chip_good(map, adr, datum)) {
1657 /* reset on all failures. */
1658 map_write(map, CMD(0xF0), chip->start);
1659 /* FIXME - should have reset delay before continuing */
1660
1661 if (++retry_cnt <= MAX_WORD_RETRIES)
1662 goto retry;
1663
1664 ret = -EIO;
1665 }
1666
1667op_done:
1668 DISABLE_VPP(map);
1669 return ret;
1670}
1671
1672/*
1673 * Write out some data during a kernel panic
1674 *
1675 * This is used by the mtdoops driver to save the dying messages from a
1676 * kernel which has panic'd.
1677 *
1678 * This routine ignores all of the locking used throughout the rest of the
1679 * driver, in order to ensure that the data gets written out no matter what
1680 * state this driver (and the flash chip itself) was in when the kernel crashed.
1681 *
1682 * The implementation of this routine is intentionally similar to
1683 * cfi_amdstd_write_words(), in order to ease code maintenance.
1684 */
1685static int cfi_amdstd_panic_write(struct mtd_info *mtd, loff_t to, size_t len,
1686 size_t *retlen, const u_char *buf)
1687{
1688 struct map_info *map = mtd->priv;
1689 struct cfi_private *cfi = map->fldrv_priv;
1690 unsigned long ofs, chipstart;
1691 int ret = 0;
1692 int chipnum;
1693
1694 chipnum = to >> cfi->chipshift;
1695 ofs = to - (chipnum << cfi->chipshift);
1696 chipstart = cfi->chips[chipnum].start;
1697
1698 /* If it's not bus aligned, do the first byte write */
1699 if (ofs & (map_bankwidth(map) - 1)) {
1700 unsigned long bus_ofs = ofs & ~(map_bankwidth(map) - 1);
1701 int i = ofs - bus_ofs;
1702 int n = 0;
1703 map_word tmp_buf;
1704
1705 ret = cfi_amdstd_panic_wait(map, &cfi->chips[chipnum], bus_ofs);
1706 if (ret)
1707 return ret;
1708
1709 /* Load 'tmp_buf' with old contents of flash */
1710 tmp_buf = map_read(map, bus_ofs + chipstart);
1711
1712 /* Number of bytes to copy from buffer */
1713 n = min_t(int, len, map_bankwidth(map) - i);
1714
1715 tmp_buf = map_word_load_partial(map, tmp_buf, buf, i, n);
1716
1717 ret = do_panic_write_oneword(map, &cfi->chips[chipnum],
1718 bus_ofs, tmp_buf);
1719 if (ret)
1720 return ret;
1721
1722 ofs += n;
1723 buf += n;
1724 (*retlen) += n;
1725 len -= n;
1726
1727 if (ofs >> cfi->chipshift) {
1728 chipnum++;
1729 ofs = 0;
1730 if (chipnum == cfi->numchips)
1731 return 0;
1732 }
1733 }
1734
1735 /* We are now aligned, write as much as possible */
1736 while (len >= map_bankwidth(map)) {
1737 map_word datum;
1738
1739 datum = map_word_load(map, buf);
1740
1741 ret = do_panic_write_oneword(map, &cfi->chips[chipnum],
1742 ofs, datum);
1743 if (ret)
1744 return ret;
1745
1746 ofs += map_bankwidth(map);
1747 buf += map_bankwidth(map);
1748 (*retlen) += map_bankwidth(map);
1749 len -= map_bankwidth(map);
1750
1751 if (ofs >> cfi->chipshift) {
1752 chipnum++;
1753 ofs = 0;
1754 if (chipnum == cfi->numchips)
1755 return 0;
1756
1757 chipstart = cfi->chips[chipnum].start;
1758 }
1759 }
1760
1761 /* Write the trailing bytes if any */
1762 if (len & (map_bankwidth(map) - 1)) {
1763 map_word tmp_buf;
1764
1765 ret = cfi_amdstd_panic_wait(map, &cfi->chips[chipnum], ofs);
1766 if (ret)
1767 return ret;
1768
1769 tmp_buf = map_read(map, ofs + chipstart);
1770
1771 tmp_buf = map_word_load_partial(map, tmp_buf, buf, 0, len);
1772
1773 ret = do_panic_write_oneword(map, &cfi->chips[chipnum],
1774 ofs, tmp_buf);
1775 if (ret)
1776 return ret;
1777
1778 (*retlen) += len;
1779 }
1780
1781 return 0;
1782}
1783
1565 1784
1566/* 1785/*
1567 * Handle devices with one erase region, that only implement 1786 * Handle devices with one erase region, that only implement
@@ -1649,6 +1868,7 @@ static int __xipram do_erase_chip(struct map_info *map, struct flchip *chip)
1649 1868
1650 chip->state = FL_READY; 1869 chip->state = FL_READY;
1651 xip_enable(map, chip, adr); 1870 xip_enable(map, chip, adr);
1871 DISABLE_VPP(map);
1652 put_chip(map, chip, adr); 1872 put_chip(map, chip, adr);
1653 mutex_unlock(&chip->mutex); 1873 mutex_unlock(&chip->mutex);
1654 1874
@@ -1739,6 +1959,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1739 } 1959 }
1740 1960
1741 chip->state = FL_READY; 1961 chip->state = FL_READY;
1962 DISABLE_VPP(map);
1742 put_chip(map, chip, adr); 1963 put_chip(map, chip, adr);
1743 mutex_unlock(&chip->mutex); 1964 mutex_unlock(&chip->mutex);
1744 return ret; 1965 return ret;
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
index 85e80180b65b..096993f9711e 100644
--- a/drivers/mtd/chips/cfi_cmdset_0020.c
+++ b/drivers/mtd/chips/cfi_cmdset_0020.c
@@ -228,15 +228,15 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
228 } 228 }
229 229
230 /* Also select the correct geometry setup too */ 230 /* Also select the correct geometry setup too */
231 mtd->erase = cfi_staa_erase_varsize; 231 mtd->_erase = cfi_staa_erase_varsize;
232 mtd->read = cfi_staa_read; 232 mtd->_read = cfi_staa_read;
233 mtd->write = cfi_staa_write_buffers; 233 mtd->_write = cfi_staa_write_buffers;
234 mtd->writev = cfi_staa_writev; 234 mtd->_writev = cfi_staa_writev;
235 mtd->sync = cfi_staa_sync; 235 mtd->_sync = cfi_staa_sync;
236 mtd->lock = cfi_staa_lock; 236 mtd->_lock = cfi_staa_lock;
237 mtd->unlock = cfi_staa_unlock; 237 mtd->_unlock = cfi_staa_unlock;
238 mtd->suspend = cfi_staa_suspend; 238 mtd->_suspend = cfi_staa_suspend;
239 mtd->resume = cfi_staa_resume; 239 mtd->_resume = cfi_staa_resume;
240 mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE; 240 mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE;
241 mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */ 241 mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */
242 mtd->writebufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize; 242 mtd->writebufsize = cfi_interleave(cfi) << cfi->cfiq->MaxBufWriteSize;
@@ -394,8 +394,6 @@ static int cfi_staa_read (struct mtd_info *mtd, loff_t from, size_t len, size_t
394 chipnum = (from >> cfi->chipshift); 394 chipnum = (from >> cfi->chipshift);
395 ofs = from - (chipnum << cfi->chipshift); 395 ofs = from - (chipnum << cfi->chipshift);
396 396
397 *retlen = 0;
398
399 while (len) { 397 while (len) {
400 unsigned long thislen; 398 unsigned long thislen;
401 399
@@ -617,10 +615,6 @@ static int cfi_staa_write_buffers (struct mtd_info *mtd, loff_t to,
617 int chipnum; 615 int chipnum;
618 unsigned long ofs; 616 unsigned long ofs;
619 617
620 *retlen = 0;
621 if (!len)
622 return 0;
623
624 chipnum = to >> cfi->chipshift; 618 chipnum = to >> cfi->chipshift;
625 ofs = to - (chipnum << cfi->chipshift); 619 ofs = to - (chipnum << cfi->chipshift);
626 620
@@ -904,12 +898,6 @@ static int cfi_staa_erase_varsize(struct mtd_info *mtd,
904 int i, first; 898 int i, first;
905 struct mtd_erase_region_info *regions = mtd->eraseregions; 899 struct mtd_erase_region_info *regions = mtd->eraseregions;
906 900
907 if (instr->addr > mtd->size)
908 return -EINVAL;
909
910 if ((instr->len + instr->addr) > mtd->size)
911 return -EINVAL;
912
913 /* Check that both start and end of the requested erase are 901 /* Check that both start and end of the requested erase are
914 * aligned with the erasesize at the appropriate addresses. 902 * aligned with the erasesize at the appropriate addresses.
915 */ 903 */
@@ -1155,9 +1143,6 @@ static int cfi_staa_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
1155 if (len & (mtd->erasesize -1)) 1143 if (len & (mtd->erasesize -1))
1156 return -EINVAL; 1144 return -EINVAL;
1157 1145
1158 if ((len + ofs) > mtd->size)
1159 return -EINVAL;
1160
1161 chipnum = ofs >> cfi->chipshift; 1146 chipnum = ofs >> cfi->chipshift;
1162 adr = ofs - (chipnum << cfi->chipshift); 1147 adr = ofs - (chipnum << cfi->chipshift);
1163 1148
diff --git a/drivers/mtd/chips/cfi_util.c b/drivers/mtd/chips/cfi_util.c
index 8e464054a631..f992418f40a8 100644
--- a/drivers/mtd/chips/cfi_util.c
+++ b/drivers/mtd/chips/cfi_util.c
@@ -173,12 +173,6 @@ int cfi_varsize_frob(struct mtd_info *mtd, varsize_frob_t frob,
173 int i, first; 173 int i, first;
174 struct mtd_erase_region_info *regions = mtd->eraseregions; 174 struct mtd_erase_region_info *regions = mtd->eraseregions;
175 175
176 if (ofs > mtd->size)
177 return -EINVAL;
178
179 if ((len + ofs) > mtd->size)
180 return -EINVAL;
181
182 /* Check that both start and end of the requested erase are 176 /* Check that both start and end of the requested erase are
183 * aligned with the erasesize at the appropriate addresses. 177 * aligned with the erasesize at the appropriate addresses.
184 */ 178 */
diff --git a/drivers/mtd/chips/fwh_lock.h b/drivers/mtd/chips/fwh_lock.h
index 89c6595454a5..800b0e853e86 100644
--- a/drivers/mtd/chips/fwh_lock.h
+++ b/drivers/mtd/chips/fwh_lock.h
@@ -101,7 +101,7 @@ static void fixup_use_fwh_lock(struct mtd_info *mtd)
101{ 101{
102 printk(KERN_NOTICE "using fwh lock/unlock method\n"); 102 printk(KERN_NOTICE "using fwh lock/unlock method\n");
103 /* Setup for the chips with the fwh lock method */ 103 /* Setup for the chips with the fwh lock method */
104 mtd->lock = fwh_lock_varsize; 104 mtd->_lock = fwh_lock_varsize;
105 mtd->unlock = fwh_unlock_varsize; 105 mtd->_unlock = fwh_unlock_varsize;
106} 106}
107#endif /* FWH_LOCK_H */ 107#endif /* FWH_LOCK_H */
diff --git a/drivers/mtd/chips/map_absent.c b/drivers/mtd/chips/map_absent.c
index f2b872946871..f7a5bca92aef 100644
--- a/drivers/mtd/chips/map_absent.c
+++ b/drivers/mtd/chips/map_absent.c
@@ -55,10 +55,10 @@ static struct mtd_info *map_absent_probe(struct map_info *map)
55 mtd->name = map->name; 55 mtd->name = map->name;
56 mtd->type = MTD_ABSENT; 56 mtd->type = MTD_ABSENT;
57 mtd->size = map->size; 57 mtd->size = map->size;
58 mtd->erase = map_absent_erase; 58 mtd->_erase = map_absent_erase;
59 mtd->read = map_absent_read; 59 mtd->_read = map_absent_read;
60 mtd->write = map_absent_write; 60 mtd->_write = map_absent_write;
61 mtd->sync = map_absent_sync; 61 mtd->_sync = map_absent_sync;
62 mtd->flags = 0; 62 mtd->flags = 0;
63 mtd->erasesize = PAGE_SIZE; 63 mtd->erasesize = PAGE_SIZE;
64 mtd->writesize = 1; 64 mtd->writesize = 1;
@@ -70,13 +70,11 @@ static struct mtd_info *map_absent_probe(struct map_info *map)
70 70
71static int map_absent_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf) 71static int map_absent_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
72{ 72{
73 *retlen = 0;
74 return -ENODEV; 73 return -ENODEV;
75} 74}
76 75
77static int map_absent_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) 76static int map_absent_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
78{ 77{
79 *retlen = 0;
80 return -ENODEV; 78 return -ENODEV;
81} 79}
82 80
diff --git a/drivers/mtd/chips/map_ram.c b/drivers/mtd/chips/map_ram.c
index 67640ccb2d41..991c2a1c05d3 100644
--- a/drivers/mtd/chips/map_ram.c
+++ b/drivers/mtd/chips/map_ram.c
@@ -64,11 +64,11 @@ static struct mtd_info *map_ram_probe(struct map_info *map)
64 mtd->name = map->name; 64 mtd->name = map->name;
65 mtd->type = MTD_RAM; 65 mtd->type = MTD_RAM;
66 mtd->size = map->size; 66 mtd->size = map->size;
67 mtd->erase = mapram_erase; 67 mtd->_erase = mapram_erase;
68 mtd->get_unmapped_area = mapram_unmapped_area; 68 mtd->_get_unmapped_area = mapram_unmapped_area;
69 mtd->read = mapram_read; 69 mtd->_read = mapram_read;
70 mtd->write = mapram_write; 70 mtd->_write = mapram_write;
71 mtd->sync = mapram_nop; 71 mtd->_sync = mapram_nop;
72 mtd->flags = MTD_CAP_RAM; 72 mtd->flags = MTD_CAP_RAM;
73 mtd->writesize = 1; 73 mtd->writesize = 1;
74 74
@@ -122,14 +122,10 @@ static int mapram_erase (struct mtd_info *mtd, struct erase_info *instr)
122 unsigned long i; 122 unsigned long i;
123 123
124 allff = map_word_ff(map); 124 allff = map_word_ff(map);
125
126 for (i=0; i<instr->len; i += map_bankwidth(map)) 125 for (i=0; i<instr->len; i += map_bankwidth(map))
127 map_write(map, allff, instr->addr + i); 126 map_write(map, allff, instr->addr + i);
128
129 instr->state = MTD_ERASE_DONE; 127 instr->state = MTD_ERASE_DONE;
130
131 mtd_erase_callback(instr); 128 mtd_erase_callback(instr);
132
133 return 0; 129 return 0;
134} 130}
135 131
diff --git a/drivers/mtd/chips/map_rom.c b/drivers/mtd/chips/map_rom.c
index 593f73d480d2..47a43cf7e5c6 100644
--- a/drivers/mtd/chips/map_rom.c
+++ b/drivers/mtd/chips/map_rom.c
@@ -41,11 +41,11 @@ static struct mtd_info *map_rom_probe(struct map_info *map)
41 mtd->name = map->name; 41 mtd->name = map->name;
42 mtd->type = MTD_ROM; 42 mtd->type = MTD_ROM;
43 mtd->size = map->size; 43 mtd->size = map->size;
44 mtd->get_unmapped_area = maprom_unmapped_area; 44 mtd->_get_unmapped_area = maprom_unmapped_area;
45 mtd->read = maprom_read; 45 mtd->_read = maprom_read;
46 mtd->write = maprom_write; 46 mtd->_write = maprom_write;
47 mtd->sync = maprom_nop; 47 mtd->_sync = maprom_nop;
48 mtd->erase = maprom_erase; 48 mtd->_erase = maprom_erase;
49 mtd->flags = MTD_CAP_ROM; 49 mtd->flags = MTD_CAP_ROM;
50 mtd->erasesize = map->size; 50 mtd->erasesize = map->size;
51 mtd->writesize = 1; 51 mtd->writesize = 1;
@@ -85,8 +85,7 @@ static void maprom_nop(struct mtd_info *mtd)
85 85
86static int maprom_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf) 86static int maprom_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
87{ 87{
88 printk(KERN_NOTICE "maprom_write called\n"); 88 return -EROFS;
89 return -EIO;
90} 89}
91 90
92static int maprom_erase (struct mtd_info *mtd, struct erase_info *info) 91static int maprom_erase (struct mtd_info *mtd, struct erase_info *info)