diff options
author | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-23 11:21:03 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@cruncher.tec.linutronix.de> | 2006-05-23 11:21:03 -0400 |
commit | 9223a456da8ed357bf7e0b128c853e2c8bd54614 (patch) | |
tree | 50cb225c4ba9c610ae4cb67231b319e78e935ac4 /drivers/mtd/nand/nand_base.c | |
parent | 2528e8cdf376d7da24647c442ec1e88c360d76ca (diff) |
[MTD] Remove read/write _ecc variants
MTD clients are agnostic of FLASH which needs ECC suppport.
Remove the functions and fixup the callers.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/nand/nand_base.c')
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 122 |
1 files changed, 60 insertions, 62 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index da2f4d16e506..d796eb508b4f 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -139,16 +139,10 @@ static int nand_verify_buf(struct mtd_info *mtd, const uint8_t *buf, int len); | |||
139 | 139 | ||
140 | static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, | 140 | static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, |
141 | size_t *retlen, uint8_t *buf); | 141 | size_t *retlen, uint8_t *buf); |
142 | static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, | ||
143 | size_t *retlen, uint8_t *buf, uint8_t *eccbuf, | ||
144 | struct nand_oobinfo *oobsel); | ||
145 | static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, | 142 | static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, |
146 | size_t *retlen, uint8_t *buf); | 143 | size_t *retlen, uint8_t *buf); |
147 | static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, | 144 | static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, |
148 | size_t *retlen, const uint8_t *buf); | 145 | size_t *retlen, const uint8_t *buf); |
149 | static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | ||
150 | size_t *retlen, const uint8_t *buf, uint8_t *eccbuf, | ||
151 | struct nand_oobinfo *oobsel); | ||
152 | static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, | 146 | static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, |
153 | size_t *retlen, const uint8_t *buf); | 147 | size_t *retlen, const uint8_t *buf); |
154 | static int nand_erase(struct mtd_info *mtd, struct erase_info *instr); | 148 | static int nand_erase(struct mtd_info *mtd, struct erase_info *instr); |
@@ -1080,27 +1074,6 @@ static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retl | |||
1080 | } | 1074 | } |
1081 | 1075 | ||
1082 | /** | 1076 | /** |
1083 | * nand_read_ecc - [MTD Interface] MTD compability function for nand_do_read_ecc | ||
1084 | * @mtd: MTD device structure | ||
1085 | * @from: offset to read from | ||
1086 | * @len: number of bytes to read | ||
1087 | * @retlen: pointer to variable to store the number of read bytes | ||
1088 | * @buf: the databuffer to put data | ||
1089 | * @oob_buf: filesystem supplied oob data buffer | ||
1090 | * @oobsel: oob selection structure | ||
1091 | * | ||
1092 | * This function simply calls nand_do_read_ecc with flags = 0xff | ||
1093 | */ | ||
1094 | static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, | ||
1095 | size_t *retlen, uint8_t *buf, uint8_t *oob_buf, struct nand_oobinfo *oobsel) | ||
1096 | { | ||
1097 | /* use userspace supplied oobinfo, if zero */ | ||
1098 | if (oobsel == NULL) | ||
1099 | oobsel = &mtd->oobinfo; | ||
1100 | return nand_do_read_ecc(mtd, from, len, retlen, buf, oob_buf, oobsel, 0xff); | ||
1101 | } | ||
1102 | |||
1103 | /** | ||
1104 | * nand_do_read_ecc - [MTD Interface] Read data with ECC | 1077 | * nand_do_read_ecc - [MTD Interface] Read data with ECC |
1105 | * @mtd: MTD device structure | 1078 | * @mtd: MTD device structure |
1106 | * @from: offset to read from | 1079 | * @from: offset to read from |
@@ -1524,6 +1497,55 @@ int nand_read_raw(struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, s | |||
1524 | } | 1497 | } |
1525 | 1498 | ||
1526 | /** | 1499 | /** |
1500 | * nand_write_raw - [GENERIC] Write raw data including oob | ||
1501 | * @mtd: MTD device structure | ||
1502 | * @buf: source buffer | ||
1503 | * @to: offset to write to | ||
1504 | * @len: number of bytes to write | ||
1505 | * @buf: source buffer | ||
1506 | * @oob: oob buffer | ||
1507 | * | ||
1508 | * Write raw data including oob | ||
1509 | */ | ||
1510 | int nand_write_raw(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, | ||
1511 | uint8_t *buf, uint8_t *oob) | ||
1512 | { | ||
1513 | struct nand_chip *this = mtd->priv; | ||
1514 | int page = (int)(to >> this->page_shift); | ||
1515 | int chip = (int)(to >> this->chip_shift); | ||
1516 | int ret; | ||
1517 | |||
1518 | *retlen = 0; | ||
1519 | |||
1520 | /* Do not allow writes past end of device */ | ||
1521 | if ((to + len) > mtd->size) { | ||
1522 | DEBUG(MTD_DEBUG_LEVEL0, "nand_read_raw: Attempt write " | ||
1523 | "beyond end of device\n"); | ||
1524 | return -EINVAL; | ||
1525 | } | ||
1526 | |||
1527 | /* Grab the lock and see if the device is available */ | ||
1528 | nand_get_device(this, mtd, FL_WRITING); | ||
1529 | |||
1530 | this->select_chip(mtd, chip); | ||
1531 | this->data_poi = buf; | ||
1532 | |||
1533 | while (len != *retlen) { | ||
1534 | ret = nand_write_page(mtd, this, page, oob, &mtd->oobinfo, 0); | ||
1535 | if (ret) | ||
1536 | return ret; | ||
1537 | page++; | ||
1538 | *retlen += mtd->writesize; | ||
1539 | this->data_poi += mtd->writesize; | ||
1540 | oob += mtd->oobsize; | ||
1541 | } | ||
1542 | |||
1543 | /* Deselect and wake up anyone waiting on the device */ | ||
1544 | nand_release_device(mtd); | ||
1545 | return 0; | ||
1546 | } | ||
1547 | |||
1548 | /** | ||
1527 | * nand_prepare_oobbuf - [GENERIC] Prepare the out of band buffer | 1549 | * nand_prepare_oobbuf - [GENERIC] Prepare the out of band buffer |
1528 | * @mtd: MTD device structure | 1550 | * @mtd: MTD device structure |
1529 | * @fsbuf: buffer given by fs driver | 1551 | * @fsbuf: buffer given by fs driver |
@@ -1585,57 +1607,39 @@ static uint8_t *nand_prepare_oobbuf(struct mtd_info *mtd, uint8_t *fsbuf, struct | |||
1585 | #define NOTALIGNED(x) (x & (mtd->writesize-1)) != 0 | 1607 | #define NOTALIGNED(x) (x & (mtd->writesize-1)) != 0 |
1586 | 1608 | ||
1587 | /** | 1609 | /** |
1588 | * nand_write - [MTD Interface] compability function for nand_write_ecc | 1610 | * nand_write - [MTD Interface] NAND write with ECC |
1589 | * @mtd: MTD device structure | ||
1590 | * @to: offset to write to | ||
1591 | * @len: number of bytes to write | ||
1592 | * @retlen: pointer to variable to store the number of written bytes | ||
1593 | * @buf: the data to write | ||
1594 | * | ||
1595 | * This function simply calls nand_write_ecc with oob buffer and oobsel = NULL | ||
1596 | * | ||
1597 | */ | ||
1598 | static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const uint8_t *buf) | ||
1599 | { | ||
1600 | return (nand_write_ecc(mtd, to, len, retlen, buf, NULL, NULL)); | ||
1601 | } | ||
1602 | |||
1603 | /** | ||
1604 | * nand_write_ecc - [MTD Interface] NAND write with ECC | ||
1605 | * @mtd: MTD device structure | 1611 | * @mtd: MTD device structure |
1606 | * @to: offset to write to | 1612 | * @to: offset to write to |
1607 | * @len: number of bytes to write | 1613 | * @len: number of bytes to write |
1608 | * @retlen: pointer to variable to store the number of written bytes | 1614 | * @retlen: pointer to variable to store the number of written bytes |
1609 | * @buf: the data to write | 1615 | * @buf: the data to write |
1610 | * @eccbuf: filesystem supplied oob data buffer | ||
1611 | * @oobsel: oob selection structure | ||
1612 | * | 1616 | * |
1613 | * NAND write with ECC | 1617 | * NAND write with ECC |
1614 | */ | 1618 | */ |
1615 | static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | 1619 | static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, |
1616 | size_t *retlen, const uint8_t *buf, uint8_t *eccbuf, | 1620 | size_t *retlen, const uint8_t *buf) |
1617 | struct nand_oobinfo *oobsel) | ||
1618 | { | 1621 | { |
1619 | int startpage, page, ret = -EIO, oob = 0, written = 0, chipnr; | 1622 | int startpage, page, ret = -EIO, oob = 0, written = 0, chipnr; |
1620 | int autoplace = 0, numpages, totalpages; | 1623 | int autoplace = 0, numpages, totalpages; |
1621 | struct nand_chip *this = mtd->priv; | 1624 | struct nand_chip *this = mtd->priv; |
1622 | uint8_t *oobbuf, *bufstart; | 1625 | uint8_t *oobbuf, *bufstart, *eccbuf = NULL; |
1623 | int ppblock = (1 << (this->phys_erase_shift - this->page_shift)); | 1626 | int ppblock = (1 << (this->phys_erase_shift - this->page_shift)); |
1627 | struct nand_oobinfo *oobsel = &mtd->oobinfo; | ||
1624 | 1628 | ||
1625 | DEBUG(MTD_DEBUG_LEVEL3, "nand_write_ecc: to = 0x%08x, len = %i\n", (unsigned int)to, (int)len); | 1629 | DEBUG(MTD_DEBUG_LEVEL3, "nand_write: to = 0x%08x, len = %i\n", (unsigned int)to, (int)len); |
1626 | 1630 | ||
1627 | /* Initialize retlen, in case of early exit */ | 1631 | /* Initialize retlen, in case of early exit */ |
1628 | *retlen = 0; | 1632 | *retlen = 0; |
1629 | 1633 | ||
1630 | /* Do not allow write past end of device */ | 1634 | /* Do not allow write past end of device */ |
1631 | if ((to + len) > mtd->size) { | 1635 | if ((to + len) > mtd->size) { |
1632 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: Attempt to write past end of page\n"); | 1636 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write: Attempt to write past end of page\n"); |
1633 | return -EINVAL; | 1637 | return -EINVAL; |
1634 | } | 1638 | } |
1635 | 1639 | ||
1636 | /* reject writes, which are not page aligned */ | 1640 | /* reject writes, which are not page aligned */ |
1637 | if (NOTALIGNED(to) || NOTALIGNED(len)) { | 1641 | if (NOTALIGNED(to) || NOTALIGNED(len)) { |
1638 | printk(KERN_NOTICE "nand_write_ecc: Attempt to write not page aligned data\n"); | 1642 | printk(KERN_NOTICE "nand_write: Attempt to write not page aligned data\n"); |
1639 | return -EINVAL; | 1643 | return -EINVAL; |
1640 | } | 1644 | } |
1641 | 1645 | ||
@@ -1651,10 +1655,6 @@ static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
1651 | if (nand_check_wp(mtd)) | 1655 | if (nand_check_wp(mtd)) |
1652 | goto out; | 1656 | goto out; |
1653 | 1657 | ||
1654 | /* if oobsel is NULL, use chip defaults */ | ||
1655 | if (oobsel == NULL) | ||
1656 | oobsel = &mtd->oobinfo; | ||
1657 | |||
1658 | /* Autoplace of oob data ? Use the default placement scheme */ | 1658 | /* Autoplace of oob data ? Use the default placement scheme */ |
1659 | if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) { | 1659 | if (oobsel->useecc == MTD_NANDECC_AUTOPLACE) { |
1660 | oobsel = this->autooob; | 1660 | oobsel = this->autooob; |
@@ -1689,7 +1689,7 @@ static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
1689 | */ | 1689 | */ |
1690 | ret = nand_write_page(mtd, this, page, &oobbuf[oob], oobsel, (--numpages > 0)); | 1690 | ret = nand_write_page(mtd, this, page, &oobbuf[oob], oobsel, (--numpages > 0)); |
1691 | if (ret) { | 1691 | if (ret) { |
1692 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: write_page failed %d\n", ret); | 1692 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write: write_page failed %d\n", ret); |
1693 | goto out; | 1693 | goto out; |
1694 | } | 1694 | } |
1695 | /* Next oob page */ | 1695 | /* Next oob page */ |
@@ -1712,7 +1712,7 @@ static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
1712 | ret = nand_verify_pages(mtd, this, startpage, page - startpage, | 1712 | ret = nand_verify_pages(mtd, this, startpage, page - startpage, |
1713 | oobbuf, oobsel, chipnr, (eccbuf != NULL)); | 1713 | oobbuf, oobsel, chipnr, (eccbuf != NULL)); |
1714 | if (ret) { | 1714 | if (ret) { |
1715 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); | 1715 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write: verify_pages failed %d\n", ret); |
1716 | goto out; | 1716 | goto out; |
1717 | } | 1717 | } |
1718 | *retlen = written; | 1718 | *retlen = written; |
@@ -1741,7 +1741,7 @@ static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | |||
1741 | if (!ret) | 1741 | if (!ret) |
1742 | *retlen = written; | 1742 | *retlen = written; |
1743 | else | 1743 | else |
1744 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write_ecc: verify_pages failed %d\n", ret); | 1744 | DEBUG(MTD_DEBUG_LEVEL0, "nand_write: verify_pages failed %d\n", ret); |
1745 | 1745 | ||
1746 | out: | 1746 | out: |
1747 | /* Deselect and wake up anyone waiting on the device */ | 1747 | /* Deselect and wake up anyone waiting on the device */ |
@@ -2527,8 +2527,6 @@ int nand_scan(struct mtd_info *mtd, int maxchips) | |||
2527 | mtd->unpoint = NULL; | 2527 | mtd->unpoint = NULL; |
2528 | mtd->read = nand_read; | 2528 | mtd->read = nand_read; |
2529 | mtd->write = nand_write; | 2529 | mtd->write = nand_write; |
2530 | mtd->read_ecc = nand_read_ecc; | ||
2531 | mtd->write_ecc = nand_write_ecc; | ||
2532 | mtd->read_oob = nand_read_oob; | 2530 | mtd->read_oob = nand_read_oob; |
2533 | mtd->write_oob = nand_write_oob; | 2531 | mtd->write_oob = nand_write_oob; |
2534 | mtd->sync = nand_sync; | 2532 | mtd->sync = nand_sync; |