diff mbox series

[v4,3/4] mtd: spi-nor: core: get rid of SNOR_OVERLAID_REGION flag

Message ID 076416d5dc8328dec72d31db12b9bec96bf0ac66.1708404584.git.Takahiro.Kuwano@infineon.com
State Accepted
Delegated to: Ambarus Tudor
Headers show
Series mtd: spi-nor: core: set mtd->eraseregions for non-uniform erase map | expand

Commit Message

Takahiro Kuwano Feb. 20, 2024, 8:34 a.m. UTC
From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>

Only SNOR_OVERLAID_REGION is defined for flags in the spi_nor_erase_region
structure. It can be replaced by a boolean parameter.

Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
---
 drivers/mtd/spi-nor/core.c    | 7 +++----
 drivers/mtd/spi-nor/core.h    | 6 ++----
 drivers/mtd/spi-nor/debugfs.c | 5 ++---
 drivers/mtd/spi-nor/sfdp.c    | 7 +------
 4 files changed, 8 insertions(+), 17 deletions(-)

Comments

Michael Walle Feb. 23, 2024, 10:19 a.m. UTC | #1
On Tue Feb 20, 2024 at 9:34 AM CET, tkuw584924 wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
>
> Only SNOR_OVERLAID_REGION is defined for flags in the spi_nor_erase_region
> structure. It can be replaced by a boolean parameter.
>
> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Reviewed-by: Michael Walle <mwalle@kernel.org>

-michael
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index d9a0c0e31950..21775d5eccd5 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1549,8 +1549,7 @@  spi_nor_find_best_erase_type(const struct spi_nor_erase_map *map,
 			continue;
 
 		/* Alignment is not mandatory for overlaid regions */
-		if (region->flags & SNOR_OVERLAID_REGION &&
-		    region->size <= len)
+		if (region->overlaid && region->size <= len)
 			return erase;
 
 		/* Don't erase more than what the user has asked for. */
@@ -1592,7 +1591,7 @@  spi_nor_init_erase_cmd(const struct spi_nor_erase_region *region,
 	cmd->opcode = erase->opcode;
 	cmd->count = 1;
 
-	if (region->flags & SNOR_OVERLAID_REGION)
+	if (region->overlaid)
 		cmd->size = region->size;
 	else
 		cmd->size = erase->size;
@@ -1650,7 +1649,7 @@  static int spi_nor_init_erase_cmd_list(struct spi_nor *nor,
 				goto destroy_erase_cmd_list;
 
 			if (prev_erase != erase || erase->size != cmd->size ||
-			    region->flags & SNOR_OVERLAID_REGION) {
+			    region->overlaid) {
 				cmd = spi_nor_init_erase_cmd(region, erase);
 				if (IS_ERR(cmd)) {
 					ret = PTR_ERR(cmd);
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index 1668d79f55bc..77ae2edf513f 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -238,19 +238,17 @@  struct spi_nor_erase_command {
  *			inside this region. The erase types are sorted in
  *			ascending order with the smallest Erase Type size being
  *			at BIT(0).
- * @flags:		flags to determine if this region is overlaid.
+ * @overlaid:		determine if this region is overlaid.
  */
 struct spi_nor_erase_region {
 	u64		offset;
 	u64		size;
 	u8		erase_mask;
-	u8		flags;
+	bool		overlaid;
 };
 
 #define SNOR_ERASE_TYPE_MAX	4
 
-#define SNOR_OVERLAID_REGION	BIT(0)
-
 /**
  * struct spi_nor_erase_map - Structure to describe the SPI NOR erase map
  * @regions:		array of erase regions. The regions are consecutive in
diff --git a/drivers/mtd/spi-nor/debugfs.c b/drivers/mtd/spi-nor/debugfs.c
index 0832b5893d6b..c9a344e0f96f 100644
--- a/drivers/mtd/spi-nor/debugfs.c
+++ b/drivers/mtd/spi-nor/debugfs.c
@@ -142,13 +142,12 @@  static int spi_nor_params_show(struct seq_file *s, void *data)
 	}
 
 	seq_puts(s, "\nsector map\n");
-	seq_puts(s, " region (in hex)   | erase mask | flags\n");
+	seq_puts(s, " region (in hex)   | erase mask | overlaid\n");
 	seq_puts(s, " ------------------+------------+----------\n");
 	for (i = 0; i < erase_map->n_regions; i++) {
 		u64 start = region[i].offset;
 		u64 end = start + region[i].size - 1;
 		u8 erase_mask = region[i].erase_mask;
-		u8 flags = region[i].flags;
 
 		seq_printf(s, " %08llx-%08llx |     [%c%c%c%c] | %s\n",
 			   start, end,
@@ -156,7 +155,7 @@  static int spi_nor_params_show(struct seq_file *s, void *data)
 			   erase_mask & BIT(1) ? '1' : ' ',
 			   erase_mask & BIT(2) ? '2' : ' ',
 			   erase_mask & BIT(3) ? '3' : ' ',
-			   flags & SNOR_OVERLAID_REGION ? "overlaid" : "");
+			   region[i].overlaid ? "yes" : "no");
 	}
 
 	return 0;
diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
index c4721d7dc97a..248e1e071fed 100644
--- a/drivers/mtd/spi-nor/sfdp.c
+++ b/drivers/mtd/spi-nor/sfdp.c
@@ -773,11 +773,6 @@  static const u32 *spi_nor_get_map_in_use(struct spi_nor *nor, const u32 *smpt,
 	return ret;
 }
 
-static void spi_nor_region_mark_overlay(struct spi_nor_erase_region *region)
-{
-	region->flags |= SNOR_OVERLAID_REGION;
-}
-
 /**
  * spi_nor_region_check_overlay() - set overlay bit when the region is overlaid
  * @region:	pointer to a structure that describes a SPI NOR erase region
@@ -795,7 +790,7 @@  spi_nor_region_check_overlay(struct spi_nor_erase_region *region,
 		if (!(erase[i].size && erase_type & BIT(erase[i].idx)))
 			continue;
 		if (region->size & erase[i].size_mask) {
-			spi_nor_region_mark_overlay(region);
+			region->overlaid = true;
 			return;
 		}
 	}