mtd: nand: qcom: use mtd_ooblayout_xxx() helpers where appropriate

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Mon May 23 21:59:12 PDT 2016


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=aa02fcf555c8d42836584783288b33a2a0d40481
Commit:     aa02fcf555c8d42836584783288b33a2a0d40481
Parent:     8cfc1e8b68f3e0b144f17a94709c757c6db05b82
Author:     Boris Brezillon <boris.brezillon at free-electrons.com>
AuthorDate: Fri Mar 18 17:53:31 2016 +0100
Committer:  Boris Brezillon <boris.brezillon at free-electrons.com>
CommitDate: Tue Apr 19 22:05:52 2016 +0200

    mtd: nand: qcom: use mtd_ooblayout_xxx() helpers where appropriate
    
    The mtd_ooblayout_xxx() helper functions have been added to avoid direct
    accesses to ecclayout fields, and thus ease for future reworks.
    Use these helpers in all places where the oobfree[] and eccpos[] arrays
    where directly accessed.
    
    Signed-off-by: Boris Brezillon <boris.brezillon at free-electrons.com>
    Tested-by: Archit Taneja <architt at codeaurora.org>
---
 drivers/mtd/nand/qcom_nandc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c
index f3de983..4ea2cb7 100644
--- a/drivers/mtd/nand/qcom_nandc.c
+++ b/drivers/mtd/nand/qcom_nandc.c
@@ -1436,7 +1436,6 @@ static int qcom_nandc_write_oob(struct mtd_info *mtd, struct nand_chip *chip,
 	struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
 	struct nand_ecc_ctrl *ecc = &chip->ecc;
 	u8 *oob = chip->oob_poi;
-	int free_boff;
 	int data_size, oob_size;
 	int ret, status = 0;
 
@@ -1450,12 +1449,11 @@ static int qcom_nandc_write_oob(struct mtd_info *mtd, struct nand_chip *chip,
 
 	/* calculate the data and oob size for the last codeword/step */
 	data_size = ecc->size - ((ecc->steps - 1) << 2);
-	oob_size = ecc->steps << 2;
-
-	free_boff = ecc->layout->oobfree[0].offset;
+	oob_size = mtd->oobavail;
 
 	/* override new oob content to last codeword */
-	memcpy(nandc->data_buffer + data_size, oob + free_boff, oob_size);
+	mtd_ooblayout_get_databytes(mtd, nandc->data_buffer + data_size, oob,
+				    0, mtd->oobavail);
 
 	set_address(host, host->cw_size * (ecc->steps - 1), page);
 	update_rw_regs(host, 1, false);



More information about the linux-mtd-cvs mailing list