mtd: spi-nor: Get rid of duplicated argument in spi_nor_parse_sfdp()
Subsystems (2)
PATCH 1/1 mtd: spi-nor: Get rid of duplicated argument in spi_nor_parse_sfdp()
spi_nor_parse_sfdp(nor, nor->params);
passes for the second argument a member within the first argument. Drop the second argument and obtain it directly from the first, and do it across all the children functions. This is a follow up for 'commit 69a8eed58cc0 ("mtd: spi-nor: Don't copy self-pointing struct around")'
--- drivers/mtd/spi-nor/core.c | 10 ++-- drivers/mtd/spi-nor/core.h | 6 +-- drivers/mtd/spi-nor/issi.c | 3 +- drivers/mtd/spi-nor/macronix.c | 3 +- drivers/mtd/spi-nor/sfdp.c | 87 +++++++++++++--------------------- drivers/mtd/spi-nor/sfdp.h | 3 +- drivers/mtd/spi-nor/spansion.c | 12 ++--- drivers/mtd/spi-nor/winbond.c | 3 +- 8 files changed, 49 insertions(+), 78 deletions(-)
drivers/mtd/spi-nor/core.c +4 -6
@@ -2624,22 +2624,20 @@ void spi_nor_init_uniform_erase_map(struct spi_nor_erase_map *map,int spi_nor_post_bfpt_fixups (struct spi_nor *nor,const struct sfdp_parameter_header *bfpt_header, -const struct sfdp_bfpt *bfpt, -struct spi_nor_flash_parameter *params) +const struct sfdp_bfpt *bfpt) {int ret;if (nor->manufacturer && nor->manufacturer->fixups && nor->manufacturer->fixups->post_bfpt) { ret = nor->manufacturer->fixups->post_bfpt (nor, bfpt_header, - bfpt, params); + bfpt);if (ret)return ret; }if (nor->info->fixups && nor->info->fixups->post_bfpt) -return nor->info->fixups->post_bfpt (nor, bfpt_header, bfpt, - params); +return nor->info->fixups->post_bfpt (nor, bfpt_header, bfpt);return 0 ; }
@@ -2894,7 +2892,7 @@ static void spi_nor_sfdp_init_params(struct spi_nor *nor)memcpy (&sfdp_params, nor->params,sizeof (sfdp_params)); -if (spi_nor_parse_sfdp (nor, nor->params)) { +if (spi_nor_parse_sfdp (nor)) {memcpy (nor->params, &sfdp_params,sizeof (*nor->params)); nor->addr_width =0 ; nor->flags &= ~SNOR_F_4B_OPCODES ;
drivers/mtd/spi-nor/core.h +2 -4
@@ -261,8 +261,7 @@ struct spi_nor_fixups {void (*default_init)(struct spi_nor *nor);int (*post_bfpt)(struct spi_nor *nor,const struct sfdp_parameter_header *bfpt_header, -const struct sfdp_bfpt *bfpt, -struct spi_nor_flash_parameter *params); +const struct sfdp_bfpt *bfpt);void (*post_sfdp)(struct spi_nor *nor); };
@@ -470,8 +469,7 @@ void spi_nor_init_uniform_erase_map(struct spi_nor_erase_map *map,int spi_nor_post_bfpt_fixups (struct spi_nor *nor,const struct sfdp_parameter_header *bfpt_header, -const struct sfdp_bfpt *bfpt, -struct spi_nor_flash_parameter *params); +const struct sfdp_bfpt *bfpt);static struct spi_nor __maybe_unused *mtd_to_spi_nor (struct mtd_info *mtd) {
drivers/mtd/spi-nor/issi.c +1 -2
@@ -11,8 +11,7 @@static int is25lp256_post_bfpt_fixups (struct spi_nor *nor,const struct sfdp_parameter_header *bfpt_header, -const struct sfdp_bfpt *bfpt, -struct spi_nor_flash_parameter *params) +const struct sfdp_bfpt *bfpt) {/* * IS25LP256 supports 4B opcodes, but the BFPT advertises a
drivers/mtd/spi-nor/macronix.c +1 -2
@@ -11,8 +11,7 @@static int mx25l25635_post_bfpt_fixups (struct spi_nor *nor,const struct sfdp_parameter_header *bfpt_header, -const struct sfdp_bfpt *bfpt, -struct spi_nor_flash_parameter *params) +const struct sfdp_bfpt *bfpt) {/* * MX25L25635F supports 4B opcodes but MX25L25635E does not.
drivers/mtd/spi-nor/sfdp.c +34 -53
256 lines not on this page · raw message
drivers/mtd/spi-nor/sfdp.h +1 -2
@@ -107,7 +107,6 @@ struct sfdp_parameter_header { u8 id_msb; }; -int spi_nor_parse_sfdp (struct spi_nor *nor, -struct spi_nor_flash_parameter *params); +int spi_nor_parse_sfdp (struct spi_nor *nor);#endif /* __LINUX_MTD_SFDP_H */
drivers/mtd/spi-nor/spansion.c +5 -7
@@ -142,8 +142,7 @@ static void s28hs512t_post_sfdp_fixup(struct spi_nor *nor)static int s28hs512t_post_bfpt_fixup (struct spi_nor *nor,const struct sfdp_parameter_header *bfpt_header, -const struct sfdp_bfpt *bfpt, -struct spi_nor_flash_parameter *params) +const struct sfdp_bfpt *bfpt) {/* * The BFPT table advertises a 512B page size but the page size is
@@ -162,9 +161,9 @@ static int s28hs512t_post_bfpt_fixup(struct spi_nor *nor,return ret;if (nor->bouncebuf[0 ] &SPINOR_REG_CYPRESS_CFR3V_PGSZ ) - params->page_size =512 ; + nor->params->page_size =512 ;else - params->page_size =256 ; + nor->params->page_size =256 ;return 0 ; }
@@ -178,8 +177,7 @@ static struct spi_nor_fixups s28hs512t_fixups = {static int s25fs_s_post_bfpt_fixups (struct spi_nor *nor,const struct sfdp_parameter_header *bfpt_header, -const struct sfdp_bfpt *bfpt, -struct spi_nor_flash_parameter *params) +const struct sfdp_bfpt *bfpt) {/* * The S25FS-S chip family reports 512-byte pages in BFPT but
@@ -187,7 +185,7 @@ s25fs_s_post_bfpt_fixups(struct spi_nor *nor,* of 256 bytes. Overwrite the page size advertised by BFPT * to get the writes working. */ - params->page_size =256 ; + nor->params->page_size =256 ;return 0 ; }
drivers/mtd/spi-nor/winbond.c +1 -2
@@ -11,8 +11,7 @@static int w25q256_post_bfpt_fixups (struct spi_nor *nor,const struct sfdp_parameter_header *bfpt_header, -const struct sfdp_bfpt *bfpt, -struct spi_nor_flash_parameter *params) +const struct sfdp_bfpt *bfpt) {/* * W25Q256JV supports 4B opcodes but W25Q256FV does not.
Signature · 6 lines
2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Quoted 18 lines · Tudor Ambarus
spi_nor_parse_sfdp(nor, nor->params);
passes for the second argument a member within the first argument. Drop the second argument and obtain it directly from the first, and do it across all the children functions. This is a follow up for 'commit69a8eed58cc0("mtd: spi-nor: Don't copy self-pointing struct around")'Signed-off-by Tudor Ambarus <[email protected]>--- drivers/mtd/spi-nor/core.c | 10 ++-- drivers/mtd/spi-nor/core.h | 6 +-- drivers/mtd/spi-nor/issi.c | 3 +- drivers/mtd/spi-nor/macronix.c | 3 +- drivers/mtd/spi-nor/sfdp.c | 87 +++++++++++++--------------------- drivers/mtd/spi-nor/sfdp.h | 3 +- drivers/mtd/spi-nor/spansion.c | 12 ++--- drivers/mtd/spi-nor/winbond.c | 3 +- 8 files changed, 49 insertions(+), 78 deletions(-)
[...]
Quoted 49 lines
drivers/mtd/spi-nor/sfdp.c +6
-8@@ -945,13 +935,11 @@ static int spi_nor_parse_smpt(struct spi_nor *nor,* @nor: pointer to a 'struct spi_nor'. * @param_header: pointer to the 'struct sfdp_parameter_header' describing * the 4-Byte Address Instruction Table length and version. -* @params: pointer to the 'struct spi_nor_flash_parameter' to be. * * Return: 0 on success, -errno otherwise. */ static int spi_nor_parse_4bait (struct spi_nor *nor, -const struct sfdp_parameter_header *param_header, -struct spi_nor_flash_parameter *params) +const struct sfdp_parameter_header *param_header) {static const struct sfdp_4bait reads[] = { {SNOR_HWCAPS_READ ,BIT (0 ) },@@ -975,8 +963,8 @@ static int spi_nor_parse_4bait(struct spi_nor *nor, { 0u /* not used */, BIT(11) }, { 0u /* not used */, BIT(12) }, }; -struct spi_nor_pp_command *params_pp = params->page_programs; -struct spi_nor_erase_map *map = ¶ms->erase_map; +struct spi_nor_pp_command *params_pp = nor->params->page_programs; +struct spi_nor_erase_map *map = &nor->params->erase_map;struct spi_nor_erase_type *erase_type = map->erase_type;u32 *dwords;size_t len;@@ -1013,7 +1001,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,const struct sfdp_4bait *read = &reads[i]; discard_hwcaps |= read->hwcaps; -if ((params->hwcaps.mask & read->hwcaps) && +if ((nor->params->hwcaps.mask & read->hwcaps) && (dwords[0 ] & read->supported_bit)) read_hwcaps |= read->hwcaps; }@@ -1029,8 +1017,8 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,/* * The 4 Byte Address Instruction (Optional) Table is the only * SFDP table that indicates support for Page Program Commands. -* Bypass the params->hwcaps.mask and consider 4BAIT the biggest -* authority for specifying Page Program support. +* Bypass the nor->params->hwcaps.mask and consider 4BAIT the +* biggest authority for specifying Page Program support. */ discard_hwcaps |= program->hwcaps;if (dwords[0 ] & program->supported_bit)@@ -1064,12 +1052,12 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,* Discard all operations from the 4-byte instruction set which are * not supported by this memory.
drivers/mtd/spi-nor/sfdp.c static int spi_nor_parse_4bait(struct spi_nor *nor, · line 1060
Quoted 10 lines
drivers/mtd/spi-nor/sfdp.c +3
-3*/ - params->hwcaps.mask &= ~discard_hwcaps; - params->hwcaps.mask |= (read_hwcaps | pp_hwcaps); + nor->params->hwcaps.mask &= ~discard_hwcaps; + nor->params->hwcaps.mask |= (read_hwcaps | pp_hwcaps);/* Use the 4-byte address instruction set. */ for (i =0 ; i <SNOR_CMD_READ_MAX ; i++) { -struct spi_nor_read_command *read_cmd = ¶ms->reads[i]; +struct spi_nor_read_command *read_cmd = &nor->params->reads[i];
Nitpick: 'nor->params' is used in multiple places in this function. Might be worth it to make it a local variable.
Either way,
Quoted 3 lines
drivers/mtd/spi-nor/sfdp.c +0
-0read_cmd->opcode =spi_nor_convert_3to4_read (read_cmd->opcode); }
[...]
Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/