]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mtd: spi-nor: Respect flash's hwcaps in spi_nor_adjust_hwcaps()
authorBin Meng <bmeng.cn@gmail.com>
Fri, 30 Jul 2021 07:20:16 +0000 (15:20 +0800)
committerJagan Teki <jagan@amarulasolutions.com>
Tue, 3 Aug 2021 06:23:16 +0000 (11:53 +0530)
The smart spi_nor_adjust_hwcaps() does not respect the SPI flash's
hwcaps, and only looks to the controller on what can be supported.

The flash's hwcaps needs to be AND'ed before checking.

Fixes: 71025f013ccb ("mtd: spi-nor-core: Rework hwcaps selection")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
drivers/mtd/spi/spi-nor-core.c

index 99e2f16349a21ea2aedfd41ed135fe1fa5f56137..c8c3bdd89002547c5f720f2f9ac84b7fa179339f 100644 (file)
@@ -2858,10 +2858,11 @@ spi_nor_adjust_hwcaps(struct spi_nor *nor,
        unsigned int cap;
 
        /*
-        * Enable all caps by default. We will mask them after checking what's
-        * really supported using spi_mem_supports_op().
+        * Start by assuming the controller supports every capability.
+        * We will mask them after checking what's really supported
+        * using spi_mem_supports_op().
         */
-       *hwcaps = SNOR_HWCAPS_ALL;
+       *hwcaps = SNOR_HWCAPS_ALL & params->hwcaps.mask;
 
        /* X-X-X modes are not supported yet, mask them all. */
        *hwcaps &= ~SNOR_HWCAPS_X_X_X;