Re: [PATCH v2 2/9] mtd: spi-nor-core: Consolidate non-uniform erase helpers for S25 and S28

2024-01-29 Thread Jagan Teki
On Fri, Dec 22, 2023 at 11:16 AM  wrote:
>
> From: Takahiro Kuwano 
>
> s25_erase_non_uniform() and s28hx_t_erase_uniform() support hybrid sector
> layout (32 x 4KB sectors overlaid at bottom address) and doing same thing.
> Consolidate them into single helper named s25_s28_erase_non_uniform().
>
> Signed-off-by: Takahiro Kuwano 
> ---

Reviewed-by: Jagan Teki 


[PATCH v2 2/9] mtd: spi-nor-core: Consolidate non-uniform erase helpers for S25 and S28

2023-12-21 Thread tkuw584924
From: Takahiro Kuwano 

s25_erase_non_uniform() and s28hx_t_erase_uniform() support hybrid sector
layout (32 x 4KB sectors overlaid at bottom address) and doing same thing.
Consolidate them into single helper named s25_s28_erase_non_uniform().

Signed-off-by: Takahiro Kuwano 
---
 drivers/mtd/spi/spi-nor-core.c | 13 +++--
 include/linux/mtd/spi-nor.h|  1 -
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index a2ef65cf6f..f62a2f2008 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3344,7 +3344,7 @@ static int s25_quad_enable(struct spi_nor *nor)
return 0;
 }
 
-static int s25_erase_non_uniform(struct spi_nor *nor, loff_t addr)
+static int s25_s28_erase_non_uniform(struct spi_nor *nor, loff_t addr)
 {
/* Support 32 x 4KB sectors at bottom */
return spansion_erase_non_uniform(nor, addr, SPINOR_OP_BE_4K_4B, 0,
@@ -3385,7 +3385,7 @@ static int s25_setup(struct spi_nor *nor, const struct 
flash_info *info,
if (ret)
return ret;
if (!(cr & SPINOR_REG_CYPRESS_CFR3_UNISECT))
-   nor->erase = s25_erase_non_uniform;
+   nor->erase = s25_s28_erase_non_uniform;
 
/*
 * For the multi-die package parts, the ready() hook is needed to check
@@ -3558,13 +3558,6 @@ static int spi_nor_cypress_octal_dtr_enable(struct 
spi_nor *nor)
return 0;
 }
 
-static int s28hx_t_erase_non_uniform(struct spi_nor *nor, loff_t addr)
-{
-   /* Factory default configuration: 32 x 4 KiB sectors at bottom. */
-   return spansion_erase_non_uniform(nor, addr, SPINOR_OP_S28_SE_4K,
- 0, SZ_128K);
-}
-
 static int s28hx_t_setup(struct spi_nor *nor, const struct flash_info *info,
 const struct spi_nor_flash_parameter *params)
 {
@@ -3593,7 +3586,7 @@ static int s28hx_t_setup(struct spi_nor *nor, const 
struct flash_info *info,
return ret;
 
if (!(buf & SPINOR_REG_CYPRESS_CFR3_UNISECT))
-   nor->erase = s28hx_t_erase_non_uniform;
+   nor->erase = s25_s28_erase_non_uniform;
 
return spi_nor_default_setup(nor, info, params);
 }
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index f9a55c8e74..ebe38306a1 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -180,7 +180,6 @@
 /* For Cypress flash. */
 #define SPINOR_OP_RD_ANY_REG   0x65/* Read any register */
 #define SPINOR_OP_WR_ANY_REG   0x71/* Write any register */
-#define SPINOR_OP_S28_SE_4K0x21
 #define SPINOR_REG_CYPRESS_ARCFN   0x0006
 #define SPINOR_REG_CYPRESS_STR1V   0x0080
 #define SPINOR_REG_CYPRESS_CFR1V   0x0082
-- 
2.34.1