mtd: rawnand: Provide a helper to get chip->data_buf
We plan to move cache related fields to a pagecache struct in nand_chip but some drivers access ->pagebuf directly to invalidate the cache before they start using ->data_buf. Let's provide an helper that returns a pointer to ->data_buf after invalidating the cache. Signed-off-by: Boris Brezillon <bbrezillon@kernel.org> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
This commit is contained in:

committed by
Miquel Raynal

parent
a7ab085d7c
commit
eeab717483
@@ -1083,12 +1083,11 @@ static int marvell_nfc_hw_ecc_hmg_read_page(struct nand_chip *chip, u8 *buf,
|
||||
*/
|
||||
static int marvell_nfc_hw_ecc_hmg_read_oob_raw(struct nand_chip *chip, int page)
|
||||
{
|
||||
/* Invalidate page cache */
|
||||
chip->pagebuf = -1;
|
||||
u8 *buf = nand_get_data_buf(chip);
|
||||
|
||||
marvell_nfc_select_target(chip, chip->cur_cs);
|
||||
return marvell_nfc_hw_ecc_hmg_do_read_page(chip, chip->data_buf,
|
||||
chip->oob_poi, true, page);
|
||||
return marvell_nfc_hw_ecc_hmg_do_read_page(chip, buf, chip->oob_poi,
|
||||
true, page);
|
||||
}
|
||||
|
||||
/* Hamming write helpers */
|
||||
@@ -1179,15 +1178,13 @@ static int marvell_nfc_hw_ecc_hmg_write_oob_raw(struct nand_chip *chip,
|
||||
int page)
|
||||
{
|
||||
struct mtd_info *mtd = nand_to_mtd(chip);
|
||||
u8 *buf = nand_get_data_buf(chip);
|
||||
|
||||
/* Invalidate page cache */
|
||||
chip->pagebuf = -1;
|
||||
|
||||
memset(chip->data_buf, 0xFF, mtd->writesize);
|
||||
memset(buf, 0xFF, mtd->writesize);
|
||||
|
||||
marvell_nfc_select_target(chip, chip->cur_cs);
|
||||
return marvell_nfc_hw_ecc_hmg_do_write_page(chip, chip->data_buf,
|
||||
chip->oob_poi, true, page);
|
||||
return marvell_nfc_hw_ecc_hmg_do_write_page(chip, buf, chip->oob_poi,
|
||||
true, page);
|
||||
}
|
||||
|
||||
/* BCH read helpers */
|
||||
@@ -1434,18 +1431,16 @@ static int marvell_nfc_hw_ecc_bch_read_page(struct nand_chip *chip,
|
||||
|
||||
static int marvell_nfc_hw_ecc_bch_read_oob_raw(struct nand_chip *chip, int page)
|
||||
{
|
||||
/* Invalidate page cache */
|
||||
chip->pagebuf = -1;
|
||||
u8 *buf = nand_get_data_buf(chip);
|
||||
|
||||
return chip->ecc.read_page_raw(chip, chip->data_buf, true, page);
|
||||
return chip->ecc.read_page_raw(chip, buf, true, page);
|
||||
}
|
||||
|
||||
static int marvell_nfc_hw_ecc_bch_read_oob(struct nand_chip *chip, int page)
|
||||
{
|
||||
/* Invalidate page cache */
|
||||
chip->pagebuf = -1;
|
||||
u8 *buf = nand_get_data_buf(chip);
|
||||
|
||||
return chip->ecc.read_page(chip, chip->data_buf, true, page);
|
||||
return chip->ecc.read_page(chip, buf, true, page);
|
||||
}
|
||||
|
||||
/* BCH write helpers */
|
||||
@@ -1619,25 +1614,21 @@ static int marvell_nfc_hw_ecc_bch_write_oob_raw(struct nand_chip *chip,
|
||||
int page)
|
||||
{
|
||||
struct mtd_info *mtd = nand_to_mtd(chip);
|
||||
u8 *buf = nand_get_data_buf(chip);
|
||||
|
||||
/* Invalidate page cache */
|
||||
chip->pagebuf = -1;
|
||||
memset(buf, 0xFF, mtd->writesize);
|
||||
|
||||
memset(chip->data_buf, 0xFF, mtd->writesize);
|
||||
|
||||
return chip->ecc.write_page_raw(chip, chip->data_buf, true, page);
|
||||
return chip->ecc.write_page_raw(chip, buf, true, page);
|
||||
}
|
||||
|
||||
static int marvell_nfc_hw_ecc_bch_write_oob(struct nand_chip *chip, int page)
|
||||
{
|
||||
struct mtd_info *mtd = nand_to_mtd(chip);
|
||||
u8 *buf = nand_get_data_buf(chip);
|
||||
|
||||
/* Invalidate page cache */
|
||||
chip->pagebuf = -1;
|
||||
memset(buf, 0xFF, mtd->writesize);
|
||||
|
||||
memset(chip->data_buf, 0xFF, mtd->writesize);
|
||||
|
||||
return chip->ecc.write_page(chip, chip->data_buf, true, page);
|
||||
return chip->ecc.write_page(chip, buf, true, page);
|
||||
}
|
||||
|
||||
/* NAND framework ->exec_op() hooks and related helpers */
|
||||
|
Reference in New Issue
Block a user