diff options
Diffstat (limited to 'drivers/mtd/onenand')
-rw-r--r-- | drivers/mtd/onenand/onenand_base.c | 46 | ||||
-rw-r--r-- | drivers/mtd/onenand/onenand_bbt.c | 7 |
2 files changed, 43 insertions, 10 deletions
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index a0d3f011c0f2..84ec40d25438 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c | |||
@@ -671,7 +671,7 @@ out: | |||
671 | } | 671 | } |
672 | 672 | ||
673 | /** | 673 | /** |
674 | * onenand_read_oob - [MTD Interface] OneNAND read out-of-band | 674 | * onenand_do_read_oob - [MTD Interface] OneNAND read out-of-band |
675 | * @param mtd MTD device structure | 675 | * @param mtd MTD device structure |
676 | * @param from offset to read from | 676 | * @param from offset to read from |
677 | * @param len number of bytes to read | 677 | * @param len number of bytes to read |
@@ -680,8 +680,8 @@ out: | |||
680 | * | 680 | * |
681 | * OneNAND read out-of-band data from the spare area | 681 | * OneNAND read out-of-band data from the spare area |
682 | */ | 682 | */ |
683 | static int onenand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, | 683 | int onenand_do_read_oob(struct mtd_info *mtd, loff_t from, size_t len, |
684 | size_t *retlen, u_char *buf) | 684 | size_t *retlen, u_char *buf) |
685 | { | 685 | { |
686 | struct onenand_chip *this = mtd->priv; | 686 | struct onenand_chip *this = mtd->priv; |
687 | int read = 0, thislen, column; | 687 | int read = 0, thislen, column; |
@@ -744,6 +744,21 @@ out: | |||
744 | return ret; | 744 | return ret; |
745 | } | 745 | } |
746 | 746 | ||
747 | /** | ||
748 | * onenand_read_oob - [MTD Interface] NAND write data and/or out-of-band | ||
749 | * @mtd: MTD device structure | ||
750 | * @from: offset to read from | ||
751 | * @ops: oob operation description structure | ||
752 | */ | ||
753 | static int onenand_read_oob(struct mtd_info *mtd, loff_t from, | ||
754 | struct mtd_oob_ops *ops) | ||
755 | { | ||
756 | BUG_ON(ops->mode != MTD_OOB_PLACE); | ||
757 | |||
758 | return onenand_do_read_oob(mtd, from + ops->ooboffs, ops->len, | ||
759 | &ops->retlen, ops->oobbuf); | ||
760 | } | ||
761 | |||
747 | #ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE | 762 | #ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE |
748 | /** | 763 | /** |
749 | * onenand_verify_oob - [GENERIC] verify the oob contents after a write | 764 | * onenand_verify_oob - [GENERIC] verify the oob contents after a write |
@@ -894,7 +909,7 @@ out: | |||
894 | } | 909 | } |
895 | 910 | ||
896 | /** | 911 | /** |
897 | * onenand_write_oob - [MTD Interface] OneNAND write out-of-band | 912 | * onenand_do_write_oob - [Internal] OneNAND write out-of-band |
898 | * @param mtd MTD device structure | 913 | * @param mtd MTD device structure |
899 | * @param to offset to write to | 914 | * @param to offset to write to |
900 | * @param len number of bytes to write | 915 | * @param len number of bytes to write |
@@ -903,8 +918,8 @@ out: | |||
903 | * | 918 | * |
904 | * OneNAND write out-of-band | 919 | * OneNAND write out-of-band |
905 | */ | 920 | */ |
906 | static int onenand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, | 921 | static int onenand_do_write_oob(struct mtd_info *mtd, loff_t to, size_t len, |
907 | size_t *retlen, const u_char *buf) | 922 | size_t *retlen, const u_char *buf) |
908 | { | 923 | { |
909 | struct onenand_chip *this = mtd->priv; | 924 | struct onenand_chip *this = mtd->priv; |
910 | int column, ret = 0; | 925 | int column, ret = 0; |
@@ -973,6 +988,21 @@ out: | |||
973 | } | 988 | } |
974 | 989 | ||
975 | /** | 990 | /** |
991 | * onenand_write_oob - [MTD Interface] NAND write data and/or out-of-band | ||
992 | * @mtd: MTD device structure | ||
993 | * @from: offset to read from | ||
994 | * @ops: oob operation description structure | ||
995 | */ | ||
996 | static int onenand_write_oob(struct mtd_info *mtd, loff_t to, | ||
997 | struct mtd_oob_ops *ops) | ||
998 | { | ||
999 | BUG_ON(ops->mode != MTD_OOB_PLACE); | ||
1000 | |||
1001 | return onenand_do_write_oob(mtd, to + ops->ooboffs, ops->len, | ||
1002 | &ops->retlen, ops->oobbuf); | ||
1003 | } | ||
1004 | |||
1005 | /** | ||
976 | * onenand_block_checkbad - [GENERIC] Check if a block is marked bad | 1006 | * onenand_block_checkbad - [GENERIC] Check if a block is marked bad |
977 | * @param mtd MTD device structure | 1007 | * @param mtd MTD device structure |
978 | * @param ofs offset from device start | 1008 | * @param ofs offset from device start |
@@ -1138,7 +1168,7 @@ static int onenand_default_block_markbad(struct mtd_info *mtd, loff_t ofs) | |||
1138 | 1168 | ||
1139 | /* We write two bytes, so we dont have to mess with 16 bit access */ | 1169 | /* We write two bytes, so we dont have to mess with 16 bit access */ |
1140 | ofs += mtd->oobsize + (bbm->badblockpos & ~0x01); | 1170 | ofs += mtd->oobsize + (bbm->badblockpos & ~0x01); |
1141 | return mtd->write_oob(mtd, ofs , 2, &retlen, buf); | 1171 | return onenand_do_write_oob(mtd, ofs , 2, &retlen, buf); |
1142 | } | 1172 | } |
1143 | 1173 | ||
1144 | /** | 1174 | /** |
@@ -1328,7 +1358,7 @@ static int do_otp_lock(struct mtd_info *mtd, loff_t from, size_t len, | |||
1328 | this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0); | 1358 | this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0); |
1329 | this->wait(mtd, FL_OTPING); | 1359 | this->wait(mtd, FL_OTPING); |
1330 | 1360 | ||
1331 | ret = mtd->write_oob(mtd, from, len, retlen, buf); | 1361 | ret = onenand_do_write_oob(mtd, from, len, retlen, buf); |
1332 | 1362 | ||
1333 | /* Exit OTP access mode */ | 1363 | /* Exit OTP access mode */ |
1334 | this->command(mtd, ONENAND_CMD_RESET, 0, 0); | 1364 | this->command(mtd, ONENAND_CMD_RESET, 0, 0); |
diff --git a/drivers/mtd/onenand/onenand_bbt.c b/drivers/mtd/onenand/onenand_bbt.c index aafd7c2f7802..1b00dac3d7d6 100644 --- a/drivers/mtd/onenand/onenand_bbt.c +++ b/drivers/mtd/onenand/onenand_bbt.c | |||
@@ -17,6 +17,9 @@ | |||
17 | #include <linux/mtd/onenand.h> | 17 | #include <linux/mtd/onenand.h> |
18 | #include <linux/mtd/compatmac.h> | 18 | #include <linux/mtd/compatmac.h> |
19 | 19 | ||
20 | extern int onenand_do_read_oob(struct mtd_info *mtd, loff_t from, size_t len, | ||
21 | size_t *retlen, u_char *buf); | ||
22 | |||
20 | /** | 23 | /** |
21 | * check_short_pattern - [GENERIC] check if a pattern is in the buffer | 24 | * check_short_pattern - [GENERIC] check if a pattern is in the buffer |
22 | * @param buf the buffer to search | 25 | * @param buf the buffer to search |
@@ -87,8 +90,8 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr | |||
87 | 90 | ||
88 | /* No need to read pages fully, | 91 | /* No need to read pages fully, |
89 | * just read required OOB bytes */ | 92 | * just read required OOB bytes */ |
90 | ret = mtd->read_oob(mtd, from + j * mtd->writesize + bd->offs, | 93 | ret = onenand_do_read_oob(mtd, from + j * mtd->writesize + bd->offs, |
91 | readlen, &retlen, &buf[0]); | 94 | readlen, &retlen, &buf[0]); |
92 | 95 | ||
93 | if (ret) | 96 | if (ret) |
94 | return ret; | 97 | return ret; |