mtd: rawnand: Use nanddev_get/set_ecc_requirements() when relevant
[linux-2.6-microblaze.git] / drivers / mtd / nand / raw / nand_onfi.c
index be34566..45649e0 100644 (file)
@@ -34,6 +34,8 @@ u16 onfi_crc16(u16 crc, u8 const *p, size_t len)
 static int nand_flash_detect_ext_param_page(struct nand_chip *chip,
                                            struct nand_onfi_params *p)
 {
+       struct nand_device *base = &chip->base;
+       struct nand_ecc_props requirements;
        struct onfi_ext_param_page *ep;
        struct onfi_ext_section *s;
        struct onfi_ext_ecc_info *ecc;
@@ -94,8 +96,10 @@ static int nand_flash_detect_ext_param_page(struct nand_chip *chip,
                goto ext_out;
        }
 
-       chip->base.eccreq.strength = ecc->ecc_bits;
-       chip->base.eccreq.step_size = 1 << ecc->codeword_size;
+       requirements.strength = ecc->ecc_bits;
+       requirements.step_size = 1 << ecc->codeword_size;
+       nanddev_set_ecc_requirements(base, &requirements);
+
        ret = 0;
 
 ext_out:
@@ -139,6 +143,7 @@ static void nand_bit_wise_majority(const void **srcbufs,
  */
 int nand_onfi_detect(struct nand_chip *chip)
 {
+       struct nand_device *base = &chip->base;
        struct mtd_info *mtd = nand_to_mtd(chip);
        struct nand_memory_organization *memorg;
        struct nand_onfi_params *p = NULL, *pbuf;
@@ -265,8 +270,12 @@ int nand_onfi_detect(struct nand_chip *chip)
                chip->options |= NAND_BUSWIDTH_16;
 
        if (p->ecc_bits != 0xff) {
-               chip->base.eccreq.strength = p->ecc_bits;
-               chip->base.eccreq.step_size = 512;
+               struct nand_ecc_props requirements = {
+                       .strength = p->ecc_bits,
+                       .step_size = 512,
+               };
+
+               nanddev_set_ecc_requirements(base, &requirements);
        } else if (onfi_version >= 21 &&
                (le16_to_cpu(p->features) & ONFI_FEATURE_EXT_PARAM_PAGE)) {