At the moment a mixture of ifdef(CONFIG_IS_ENABLED) and
CONFIG_IS_ENABLED(SPI_FLASH_BAR) is used in the spi-nor framework.
This leads to misbehaviour in the SPL as there is no Kconfig option
CONFIG_SPL_SPI_FLASH_BAR. This commit standardizes the use of
CONFIG_SPI_FLASH to get SPLs that load U-Boot proper from the
SPI flash to work again.

Fixes: 9bb02f7 (mtd: spi-nor: Fix the spi_nor_read() when config 
SPI_STACKED_PARALLEL is enabled)
Signed-off-by: Bernhard Messerklinger <bernhard.messerklin...@br-automation.com>
---

 drivers/mtd/spi/spi-nor-core.c | 22 +++++++++++-----------
 include/linux/mtd/spi-nor.h    |  2 +-
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 6f352c5c0e2..a8865bbd37c 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -655,7 +655,7 @@ static struct spi_nor *mtd_to_spi_nor(struct mtd_info *mtd)
        return mtd->priv;
 }
 
-#ifndef CONFIG_SPI_FLASH_BAR
+#if !CONFIG_IS_ENABLED(SPI_FLASH_BAR)
 static u8 spi_nor_convert_opcode(u8 opcode, const u8 table[][2], size_t size)
 {
        size_t i;
@@ -739,7 +739,7 @@ static void spi_nor_set_4byte_opcodes(struct spi_nor *nor,
        nor->program_opcode = spi_nor_convert_3to4_program(nor->program_opcode);
        nor->erase_opcode = spi_nor_convert_3to4_erase(nor->erase_opcode);
 }
-#endif /* !CONFIG_SPI_FLASH_BAR */
+#endif /* !CONFIG_IS_ENABLED(SPI_FLASH_BAR) */
 
 /* Enable/disable 4-byte addressing mode. */
 static int set_4byte(struct spi_nor *nor, const struct flash_info *info,
@@ -930,7 +930,7 @@ static int spi_nor_erase_chip_wait_till_ready(struct 
spi_nor *nor, unsigned long
        return spi_nor_wait_till_ready_with_timeout(nor, timeout);
 }
 
-#ifdef CONFIG_SPI_FLASH_BAR
+#if CONFIG_IS_ENABLED(SPI_FLASH_BAR)
 /*
  * This "clean_bar" is necessary in a situation when one was accessing
  * spi flash memory > 16 MiB by using Bank Address Register's BA24 bit.
@@ -1141,7 +1141,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct 
erase_info *instr)
                                        nor->spi->flags &= ~SPI_XFER_U_PAGE;
                        }
                }
-#ifdef CONFIG_SPI_FLASH_BAR
+#if CONFIG_IS_ENABLED(SPI_FLASH_BAR)
                ret = write_bar(nor, offset);
                if (ret < 0)
                        goto erase_err;
@@ -1175,7 +1175,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct 
erase_info *instr)
 
        addr_known = false;
 erase_err:
-#ifdef CONFIG_SPI_FLASH_BAR
+#if CONFIG_IS_ENABLED(SPI_FLASH_BAR)
        err = clean_bar(nor);
        if (!ret)
                ret = err;
@@ -1630,7 +1630,7 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t 
from, size_t len,
                                offset /= 2;
                }
 
-#ifdef CONFIG_SPI_FLASH_BAR
+#if CONFIG_IS_ENABLED(SPI_FLASH_BAR)
                ret = write_bar(nor, offset);
                if (ret < 0)
                        return log_ret(ret);
@@ -1667,7 +1667,7 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t 
from, size_t len,
        ret = 0;
 
 read_err:
-#ifdef CONFIG_SPI_FLASH_BAR
+#if CONFIG_IS_ENABLED(SPI_FLASH_BAR)
        ret = clean_bar(nor);
 #endif
        return ret;
@@ -2016,7 +2016,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, 
size_t len,
                        }
                }
 
-#ifdef CONFIG_SPI_FLASH_BAR
+#if CONFIG_IS_ENABLED(SPI_FLASH_BAR)
                ret = write_bar(nor, offset);
                if (ret < 0)
                        return ret;
@@ -2090,7 +2090,7 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, 
size_t len,
        }
 
 write_err:
-#ifdef CONFIG_SPI_FLASH_BAR
+#if CONFIG_IS_ENABLED(SPI_FLASH_BAR)
        ret = clean_bar(nor);
 #endif
        return ret;
@@ -3791,7 +3791,7 @@ static int s25_s28_setup(struct spi_nor *nor, const 
struct flash_info *info,
        int ret;
        u8 cr;
 
-#ifdef CONFIG_SPI_FLASH_BAR
+#if CONFIG_IS_ENABLED(SPI_FLASH_BAR)
        return -ENOTSUPP; /* Bank Address Register is not supported */
 #endif
        /*
@@ -4577,7 +4577,7 @@ int spi_nor_scan(struct spi_nor *nor)
        if (nor->flags & (SNOR_F_HAS_PARALLEL | SNOR_F_HAS_STACKED))
                shift = 1;
        if (nor->addr_width == 3 && (mtd->size >> shift) > SZ_16M) {
-#ifndef CONFIG_SPI_FLASH_BAR
+#if !CONFIG_IS_ENABLED(SPI_FLASH_BAR)
                /* enable 4-byte addressing if the device exceeds 16MiB */
                nor->addr_width = 4;
                if (JEDEC_MFR(info) == SNOR_MFR_SPANSION ||
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index b8b207f7b5c..4eef4ab0488 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -569,7 +569,7 @@ struct spi_nor {
        u8                      rdsr_dummy;
        u8                      rdsr_addr_nbytes;
        u8                      addr_mode_nbytes;
-#ifdef CONFIG_SPI_FLASH_BAR
+#if CONFIG_IS_ENABLED(SPI_FLASH_BAR)
        u8                      bank_read_cmd;
        u8                      bank_write_cmd;
        u8                      bank_curr;
-- 
2.49.0

Reply via email to