Commit 64469073 authored by Miquel Raynal's avatar Miquel Raynal

mtd: rawnand: Rename the use_bufpoi variables

Both in nand_do_read_ops() and nand_do_write_ops() there is a boolean
called use_bufpoi which is set to true in case of unaligned request or
when there is a need for a DMA-able buffer. It basically means "use a
bounce buffer".

Depending on the value of use_bufpoi, the bufpoi variable is always
used and will either point to the original buffer or to the nand_chip
structure "internal data buffer" (this buffer is allocated with
kmalloc() on purpose so that it will be DMA-compliant).

In all cases bufpoi is used so the boolean name is misleading. Rename
use_bufpoi to be use_bouce_buf to be more accurate.
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Link: https://lore.kernel.org/linux-mtd/20200507105241.14299-6-miquel.raynal@bootlin.com
parent 2f959949
...@@ -3216,7 +3216,7 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from, ...@@ -3216,7 +3216,7 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from,
uint32_t max_oobsize = mtd_oobavail(mtd, ops); uint32_t max_oobsize = mtd_oobavail(mtd, ops);
uint8_t *bufpoi, *oob, *buf; uint8_t *bufpoi, *oob, *buf;
int use_bufpoi; int use_bounce_buf;
unsigned int max_bitflips = 0; unsigned int max_bitflips = 0;
int retry_mode = 0; int retry_mode = 0;
bool ecc_fail = false; bool ecc_fail = false;
...@@ -3240,19 +3240,19 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from, ...@@ -3240,19 +3240,19 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from,
aligned = (bytes == mtd->writesize); aligned = (bytes == mtd->writesize);
if (!aligned) if (!aligned)
use_bufpoi = 1; use_bounce_buf = 1;
else if (chip->options & NAND_USES_DMA) else if (chip->options & NAND_USES_DMA)
use_bufpoi = !virt_addr_valid(buf) || use_bounce_buf = !virt_addr_valid(buf) ||
!IS_ALIGNED((unsigned long)buf, !IS_ALIGNED((unsigned long)buf,
chip->buf_align); chip->buf_align);
else else
use_bufpoi = 0; use_bounce_buf = 0;
/* Is the current page in the buffer? */ /* Is the current page in the buffer? */
if (realpage != chip->pagecache.page || oob) { if (realpage != chip->pagecache.page || oob) {
bufpoi = use_bufpoi ? chip->data_buf : buf; bufpoi = use_bounce_buf ? chip->data_buf : buf;
if (use_bufpoi && aligned) if (use_bounce_buf && aligned)
pr_debug("%s: using read bounce buffer for buf@%p\n", pr_debug("%s: using read bounce buffer for buf@%p\n",
__func__, buf); __func__, buf);
...@@ -3273,7 +3273,7 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from, ...@@ -3273,7 +3273,7 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from,
ret = chip->ecc.read_page(chip, bufpoi, ret = chip->ecc.read_page(chip, bufpoi,
oob_required, page); oob_required, page);
if (ret < 0) { if (ret < 0) {
if (use_bufpoi) if (use_bounce_buf)
/* Invalidate page cache */ /* Invalidate page cache */
chip->pagecache.page = -1; chip->pagecache.page = -1;
break; break;
...@@ -3283,7 +3283,7 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from, ...@@ -3283,7 +3283,7 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from,
* Copy back the data in the initial buffer when reading * Copy back the data in the initial buffer when reading
* partial pages or when a bounce buffer is required. * partial pages or when a bounce buffer is required.
*/ */
if (use_bufpoi) { if (use_bounce_buf) {
if (!NAND_HAS_SUBPAGE_READ(chip) && !oob && if (!NAND_HAS_SUBPAGE_READ(chip) && !oob &&
!(mtd->ecc_stats.failed - ecc_failures) && !(mtd->ecc_stats.failed - ecc_failures) &&
(ops->mode != MTD_OPS_RAW)) { (ops->mode != MTD_OPS_RAW)) {
...@@ -4065,23 +4065,23 @@ static int nand_do_write_ops(struct nand_chip *chip, loff_t to, ...@@ -4065,23 +4065,23 @@ static int nand_do_write_ops(struct nand_chip *chip, loff_t to,
while (1) { while (1) {
int bytes = mtd->writesize; int bytes = mtd->writesize;
uint8_t *wbuf = buf; uint8_t *wbuf = buf;
int use_bufpoi; int use_bounce_buf;
int part_pagewr = (column || writelen < mtd->writesize); int part_pagewr = (column || writelen < mtd->writesize);
if (part_pagewr) if (part_pagewr)
use_bufpoi = 1; use_bounce_buf = 1;
else if (chip->options & NAND_USES_DMA) else if (chip->options & NAND_USES_DMA)
use_bufpoi = !virt_addr_valid(buf) || use_bounce_buf = !virt_addr_valid(buf) ||
!IS_ALIGNED((unsigned long)buf, !IS_ALIGNED((unsigned long)buf,
chip->buf_align); chip->buf_align);
else else
use_bufpoi = 0; use_bounce_buf = 0;
/* /*
* Copy the data from the initial buffer when doing partial page * Copy the data from the initial buffer when doing partial page
* writes or when a bounce buffer is required. * writes or when a bounce buffer is required.
*/ */
if (use_bufpoi) { if (use_bounce_buf) {
pr_debug("%s: using write bounce buffer for buf@%p\n", pr_debug("%s: using write bounce buffer for buf@%p\n",
__func__, buf); __func__, buf);
if (part_pagewr) if (part_pagewr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment