diff options
Diffstat (limited to 'drivers/mtd/chips/cfi_cmdset_0001.c')
-rw-r--r-- | drivers/mtd/chips/cfi_cmdset_0001.c | 83 |
1 files changed, 41 insertions, 42 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 | ||
88 | static int cfi_intelext_point (struct mtd_info *mtd, loff_t from, size_t len, | 88 | static 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); |
90 | static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len); | 90 | static int cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len); |
91 | 91 | ||
92 | static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode); | 92 | static int chip_ready (struct map_info *map, struct flchip *chip, unsigned long adr, int mode); |
93 | static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode); | 93 | static 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) | |||
262 | static void fixup_use_point(struct mtd_info *mtd) | 262 | static 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 | ||
1372 | static void cfi_intelext_unpoint(struct mtd_info *mtd, loff_t from, size_t len) | 1369 | static 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 | ||
1415 | static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf) | 1416 | static 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); |
2089 | out: 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; |