From 2865ed0e2c718387457b30a293fe46333694168f Mon Sep 17 00:00:00 2001 From: Takahiro Kuwano Date: Tue, 20 Feb 2024 17:34:08 +0900 Subject: mtd: spi-nor: core: get rid of SNOR_OVERLAID_REGION flag 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 Reviewed-by: Michael Walle Link: https://lore.kernel.org/r/076416d5dc8328dec72d31db12b9bec96bf0ac66.1708404584.git.Takahiro.Kuwano@infineon.com Signed-off-by: Tudor Ambarus --- 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(-) (limited to 'drivers/mtd') diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 8dcfb8649f01..898472538dae 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -1557,8 +1557,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. */ @@ -1595,7 +1594,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; @@ -1653,7 +1652,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 38be40a4647b..442786685515 100644 --- a/drivers/mtd/spi-nor/core.h +++ b/drivers/mtd/spi-nor/core.h @@ -245,19 +245,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 db050a1f1f37..fa6956144d2e 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 8d83580207d5..5b1117265bd2 100644 --- a/drivers/mtd/spi-nor/sfdp.c +++ b/drivers/mtd/spi-nor/sfdp.c @@ -800,11 +800,6 @@ out: 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 @@ -822,7 +817,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; } } -- cgit v1.2.3-58-ga151