mtd: rawnand: onfi: Fix endianness when reading NV-DDR values
authorMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 27 May 2021 08:49:13 +0000 (10:49 +0200)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Fri, 18 Jun 2021 07:45:20 +0000 (09:45 +0200)
Without the use of le16_to_cpu(), these accesses would have been wrong
on a big-endian machine.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 45606518f961 ("mtd: rawnand: Add onfi_fill_nvddr_interface_config() helper")
Fixes: 9310668fb60a ("mtd: rawnand: Retrieve NV-DDR timing modes from the ONFI parameter page")
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20210527084913.208635-1-miquel.raynal@bootlin.com
drivers/mtd/nand/raw/nand_onfi.c

index 8e4677f..7586bef 100644 (file)
@@ -315,10 +315,10 @@ int nand_onfi_detect(struct nand_chip *chip)
        onfi->tBERS = le16_to_cpu(p->t_bers);
        onfi->tR = le16_to_cpu(p->t_r);
        onfi->tCCS = le16_to_cpu(p->t_ccs);
-       onfi->fast_tCAD = p->nvddr_nvddr2_features & BIT(0);
+       onfi->fast_tCAD = le16_to_cpu(p->nvddr_nvddr2_features) & BIT(0);
        onfi->sdr_timing_modes = le16_to_cpu(p->sdr_timing_modes);
-       if (p->features & ONFI_FEATURE_NV_DDR)
-               onfi->nvddr_timing_modes = p->nvddr_timing_modes;
+       if (le16_to_cpu(p->features) & ONFI_FEATURE_NV_DDR)
+               onfi->nvddr_timing_modes = le16_to_cpu(p->nvddr_timing_modes);
        onfi->vendor_revision = le16_to_cpu(p->vendor_revision);
        memcpy(onfi->vendor, p->vendor, sizeof(p->vendor));
        chip->parameters.onfi = onfi;