Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eeab7174 authored by Boris Brezillon's avatar Boris Brezillon Committed by Miquel Raynal
Browse files

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: default avatarBoris Brezillon <bbrezillon@kernel.org>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: default avatarFrieder Schrempf <frieder.schrempf@kontron.de>
parent a7ab085d
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -1676,11 +1676,8 @@ static int brcmstb_nand_verify_erased_page(struct mtd_info *mtd,
	int page = addr >> chip->page_shift;
	int ret;

	if (!buf) {
		buf = chip->data_buf;
		/* Invalidate page cache */
		chip->pagebuf = -1;
	}
	if (!buf)
		buf = nand_get_data_buf(chip);

	sas = mtd->oobsize / chip->ecc.steps;

+2 −2
Original line number Diff line number Diff line
@@ -1602,7 +1602,7 @@ static int mx23_check_transcription_stamp(struct gpmi_nand_data *this)
	unsigned int search_area_size_in_strides;
	unsigned int stride;
	unsigned int page;
	uint8_t *buffer = chip->data_buf;
	u8 *buffer = nand_get_data_buf(chip);
	int saved_chip_number;
	int found_an_ncb_fingerprint = false;

@@ -1664,7 +1664,7 @@ static int mx23_write_transcription_stamp(struct gpmi_nand_data *this)
	unsigned int block;
	unsigned int stride;
	unsigned int page;
	uint8_t      *buffer = chip->data_buf;
	u8 *buffer = nand_get_data_buf(chip);
	int saved_chip_number;
	int status;

+17 −26
Original line number Diff line number Diff line
@@ -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(chip->data_buf, 0xFF, mtd->writesize);
	memset(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(chip->data_buf, 0xFF, mtd->writesize);
	memset(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 */
+3 −4
Original line number Diff line number Diff line
@@ -4004,10 +4004,9 @@ static int nand_do_write_ops(struct nand_chip *chip, loff_t to,
					 __func__, buf);
			if (part_pagewr)
				bytes = min_t(int, bytes - column, writelen);
			chip->pagebuf = -1;
			memset(chip->data_buf, 0xff, mtd->writesize);
			memcpy(&chip->data_buf[column], buf, bytes);
			wbuf = chip->data_buf;
			wbuf = nand_get_data_buf(chip);
			memset(wbuf, 0xff, mtd->writesize);
			memcpy(&wbuf[column], buf, bytes);
		}

		if (unlikely(oob)) {
+3 −1
Original line number Diff line number Diff line
@@ -901,7 +901,9 @@ static int write_bbt(struct nand_chip *this, uint8_t *buf,
static inline int nand_memory_bbt(struct nand_chip *this,
				  struct nand_bbt_descr *bd)
{
	return create_bbt(this, this->data_buf, bd, -1);
	u8 *pagebuf = nand_get_data_buf(this);

	return create_bbt(this, pagebuf, bd, -1);
}

/**
Loading