Skip to content

Commit

Permalink
mtd: nand: denali: rename misleading dma_buf to tmp_buf
Browse files Browse the repository at this point in the history
The "dma_buf" is not used for a DMA bounce buffer, but for arranging
the transferred data for the syndrome page layout.  In fact, it is
used in the PIO mode as well, so "dma_buf" is a misleading name.
Rename it to "tmp_buf".

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
  • Loading branch information
Masahiro Yamada authored and Boris Brezillon committed Nov 30, 2017
1 parent c9e916a commit 8a8c8ba
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions drivers/mtd/nand/denali.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,12 +710,12 @@ static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
int ecc_steps = chip->ecc.steps;
int ecc_size = chip->ecc.size;
int ecc_bytes = chip->ecc.bytes;
void *dma_buf = denali->buf;
void *tmp_buf = denali->buf;
int oob_skip = denali->oob_skip_bytes;
size_t size = writesize + oobsize;
int ret, i, pos, len;

ret = denali_data_xfer(denali, dma_buf, size, page, 1, 0);
ret = denali_data_xfer(denali, tmp_buf, size, page, 1, 0);
if (ret)
return ret;

Expand All @@ -730,11 +730,11 @@ static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
else if (pos + len > writesize)
len = writesize - pos;

memcpy(buf, dma_buf + pos, len);
memcpy(buf, tmp_buf + pos, len);
buf += len;
if (len < ecc_size) {
len = ecc_size - len;
memcpy(buf, dma_buf + writesize + oob_skip,
memcpy(buf, tmp_buf + writesize + oob_skip,
len);
buf += len;
}
Expand All @@ -745,7 +745,7 @@ static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
uint8_t *oob = chip->oob_poi;

/* BBM at the beginning of the OOB area */
memcpy(oob, dma_buf + writesize, oob_skip);
memcpy(oob, tmp_buf + writesize, oob_skip);
oob += oob_skip;

/* OOB ECC */
Expand All @@ -758,19 +758,19 @@ static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
else if (pos + len > writesize)
len = writesize - pos;

memcpy(oob, dma_buf + pos, len);
memcpy(oob, tmp_buf + pos, len);
oob += len;
if (len < ecc_bytes) {
len = ecc_bytes - len;
memcpy(oob, dma_buf + writesize + oob_skip,
memcpy(oob, tmp_buf + writesize + oob_skip,
len);
oob += len;
}
}

/* OOB free */
len = oobsize - (oob - chip->oob_poi);
memcpy(oob, dma_buf + size - len, len);
memcpy(oob, tmp_buf + size - len, len);
}

return 0;
Expand Down Expand Up @@ -841,7 +841,7 @@ static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
int ecc_steps = chip->ecc.steps;
int ecc_size = chip->ecc.size;
int ecc_bytes = chip->ecc.bytes;
void *dma_buf = denali->buf;
void *tmp_buf = denali->buf;
int oob_skip = denali->oob_skip_bytes;
size_t size = writesize + oobsize;
int i, pos, len;
Expand All @@ -851,7 +851,7 @@ static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
* This simplifies the logic.
*/
if (!buf || !oob_required)
memset(dma_buf, 0xff, size);
memset(tmp_buf, 0xff, size);

/* Arrange the buffer for syndrome payload/ecc layout */
if (buf) {
Expand All @@ -864,11 +864,11 @@ static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
else if (pos + len > writesize)
len = writesize - pos;

memcpy(dma_buf + pos, buf, len);
memcpy(tmp_buf + pos, buf, len);
buf += len;
if (len < ecc_size) {
len = ecc_size - len;
memcpy(dma_buf + writesize + oob_skip, buf,
memcpy(tmp_buf + writesize + oob_skip, buf,
len);
buf += len;
}
Expand All @@ -879,7 +879,7 @@ static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
const uint8_t *oob = chip->oob_poi;

/* BBM at the beginning of the OOB area */
memcpy(dma_buf + writesize, oob, oob_skip);
memcpy(tmp_buf + writesize, oob, oob_skip);
oob += oob_skip;

/* OOB ECC */
Expand All @@ -892,22 +892,22 @@ static int denali_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
else if (pos + len > writesize)
len = writesize - pos;

memcpy(dma_buf + pos, oob, len);
memcpy(tmp_buf + pos, oob, len);
oob += len;
if (len < ecc_bytes) {
len = ecc_bytes - len;
memcpy(dma_buf + writesize + oob_skip, oob,
memcpy(tmp_buf + writesize + oob_skip, oob,
len);
oob += len;
}
}

/* OOB free */
len = oobsize - (oob - chip->oob_poi);
memcpy(dma_buf + size - len, oob, len);
memcpy(tmp_buf + size - len, oob, len);
}

return denali_data_xfer(denali, dma_buf, size, page, 1, 1);
return denali_data_xfer(denali, tmp_buf, size, page, 1, 1);
}

static int denali_write_page(struct mtd_info *mtd, struct nand_chip *chip,
Expand Down

0 comments on commit 8a8c8ba

Please sign in to comment.