Commit fcd052457434d1f86c4e6d5f90d838210ab87d8b

Authored by Nikita Kiryanov
Committed by Scott Wood
1 parent eb237a15bd

mtd: nand: omap: fix ecc ops assignment when changing ecc

If we change to software ecc and then back to hardware ecc, the nand ecc ops
pointers are populated with incorrect function pointers. This is related to the
way nand_scan_tail() handles assigning functions to ecc ops:

If we are switching to software ecc/no ecc, it assigns default functions to the
ecc ops pointers unconditionally, but if we are switching to hardware ecc,
the default hardware ecc functions are assigned to ops pointers only if these
pointers are NULL (so that drivers could set their own functions). In the case
of omap_gpmc.c driver, when we switch to sw ecc, sw ecc functions are
assigned to ecc ops by nand_scan_tail(), and when we later switch to hw ecc,
the ecc ops pointers are not NULL, so nand_scan_tail() does not overwrite
them with hw ecc functions.
The result: sw ecc functions used to write hw ecc data.

Clear the ecc ops pointers in omap_gpmc.c when switching ecc types, so that
ops which were not assigned by the driver will get the correct default values
from nand_scan_tail().

Cc: Scott Wood <scottwood@freescale.com>
Cc: Pekon Gupta <pekon@ti.com>
Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>

Showing 1 changed file with 3 additions and 0 deletions Side-by-side Diff

drivers/mtd/nand/omap_gpmc.c
... ... @@ -791,6 +791,7 @@
791 791 bch_priv.control = NULL;
792 792 bch_priv.type = 0;
793 793 /* populate ecc specific fields */
  794 + memset(&nand->ecc, 0, sizeof(struct nand_ecc_ctrl));
794 795 nand->ecc.mode = NAND_ECC_HW;
795 796 nand->ecc.strength = 1;
796 797 nand->ecc.size = SECTOR_BYTES;
... ... @@ -829,6 +830,7 @@
829 830 }
830 831 bch_priv.type = ECC_BCH8;
831 832 /* populate ecc specific fields */
  833 + memset(&nand->ecc, 0, sizeof(struct nand_ecc_ctrl));
832 834 nand->ecc.mode = NAND_ECC_HW;
833 835 nand->ecc.strength = 8;
834 836 nand->ecc.size = SECTOR_BYTES;
... ... @@ -871,6 +873,7 @@
871 873 elm_init();
872 874 bch_priv.type = ECC_BCH8;
873 875 /* populate ecc specific fields */
  876 + memset(&nand->ecc, 0, sizeof(struct nand_ecc_ctrl));
874 877 nand->ecc.mode = NAND_ECC_HW;
875 878 nand->ecc.strength = 8;
876 879 nand->ecc.size = SECTOR_BYTES;