diff mbox series

[v2,1/2] mtd: spi-nor: Respect flash's hwcaps in spi_nor_adjust_hwcaps()

Message ID 20210730072017.660331-1-bmeng.cn@gmail.com
State Accepted
Commit 87e7219f9c6a30709ddf97b602983386f1b4cccf
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series [v2,1/2] mtd: spi-nor: Respect flash's hwcaps in spi_nor_adjust_hwcaps() | expand

Commit Message

Bin Meng July 30, 2021, 7:20 a.m. UTC
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>

---

Changes in v2:
- Update comments per Pratyush's review

 drivers/mtd/spi/spi-nor-core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Jagan Teki Aug. 3, 2021, 6:24 a.m. UTC | #1
On Fri, Jul 30, 2021 at 12:50 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> 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>
>
> ---

Applied to u-boot-spi/master
diff mbox series

Patch

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 99e2f16349..c8c3bdd890 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -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;