Skip to content

Commit a580293

Browse files
committed
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 69a8eed ("mtd: spi-nor: Don't copy self-pointing struct around")' Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Reviewed-by: Pratyush Yadav <p.yadav@ti.com> Link: https://lore.kernel.org/r/20210306095002.22983-4-tudor.ambarus@microchip.com
1 parent 8758888 commit a580293

8 files changed

Lines changed: 42 additions & 70 deletions

File tree

drivers/mtd/spi-nor/core.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2626,22 +2626,20 @@ void spi_nor_init_uniform_erase_map(struct spi_nor_erase_map *map,
26262626

26272627
int spi_nor_post_bfpt_fixups(struct spi_nor *nor,
26282628
const struct sfdp_parameter_header *bfpt_header,
2629-
const struct sfdp_bfpt *bfpt,
2630-
struct spi_nor_flash_parameter *params)
2629+
const struct sfdp_bfpt *bfpt)
26312630
{
26322631
int ret;
26332632

26342633
if (nor->manufacturer && nor->manufacturer->fixups &&
26352634
nor->manufacturer->fixups->post_bfpt) {
26362635
ret = nor->manufacturer->fixups->post_bfpt(nor, bfpt_header,
2637-
bfpt, params);
2636+
bfpt);
26382637
if (ret)
26392638
return ret;
26402639
}
26412640

26422641
if (nor->info->fixups && nor->info->fixups->post_bfpt)
2643-
return nor->info->fixups->post_bfpt(nor, bfpt_header, bfpt,
2644-
params);
2642+
return nor->info->fixups->post_bfpt(nor, bfpt_header, bfpt);
26452643

26462644
return 0;
26472645
}
@@ -2896,7 +2894,7 @@ static void spi_nor_sfdp_init_params(struct spi_nor *nor)
28962894

28972895
memcpy(&sfdp_params, nor->params, sizeof(sfdp_params));
28982896

2899-
if (spi_nor_parse_sfdp(nor, nor->params)) {
2897+
if (spi_nor_parse_sfdp(nor)) {
29002898
memcpy(nor->params, &sfdp_params, sizeof(*nor->params));
29012899
nor->addr_width = 0;
29022900
nor->flags &= ~SNOR_F_4B_OPCODES;

drivers/mtd/spi-nor/core.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ struct spi_nor_fixups {
261261
void (*default_init)(struct spi_nor *nor);
262262
int (*post_bfpt)(struct spi_nor *nor,
263263
const struct sfdp_parameter_header *bfpt_header,
264-
const struct sfdp_bfpt *bfpt,
265-
struct spi_nor_flash_parameter *params);
264+
const struct sfdp_bfpt *bfpt);
266265
void (*post_sfdp)(struct spi_nor *nor);
267266
};
268267

@@ -470,8 +469,7 @@ void spi_nor_init_uniform_erase_map(struct spi_nor_erase_map *map,
470469

471470
int spi_nor_post_bfpt_fixups(struct spi_nor *nor,
472471
const struct sfdp_parameter_header *bfpt_header,
473-
const struct sfdp_bfpt *bfpt,
474-
struct spi_nor_flash_parameter *params);
472+
const struct sfdp_bfpt *bfpt);
475473

476474
static struct spi_nor __maybe_unused *mtd_to_spi_nor(struct mtd_info *mtd)
477475
{

drivers/mtd/spi-nor/issi.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
static int
1212
is25lp256_post_bfpt_fixups(struct spi_nor *nor,
1313
const struct sfdp_parameter_header *bfpt_header,
14-
const struct sfdp_bfpt *bfpt,
15-
struct spi_nor_flash_parameter *params)
14+
const struct sfdp_bfpt *bfpt)
1615
{
1716
/*
1817
* IS25LP256 supports 4B opcodes, but the BFPT advertises a

drivers/mtd/spi-nor/macronix.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
static int
1212
mx25l25635_post_bfpt_fixups(struct spi_nor *nor,
1313
const struct sfdp_parameter_header *bfpt_header,
14-
const struct sfdp_bfpt *bfpt,
15-
struct spi_nor_flash_parameter *params)
14+
const struct sfdp_bfpt *bfpt)
1615
{
1716
/*
1817
* MX25L25635F supports 4B opcodes but MX25L25635E does not.

drivers/mtd/spi-nor/sfdp.c

Lines changed: 27 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,6 @@ static void spi_nor_regions_sort_erase_types(struct spi_nor_erase_map *map)
405405
* @nor: pointer to a 'struct spi_nor'
406406
* @bfpt_header: pointer to the 'struct sfdp_parameter_header' describing
407407
* the Basic Flash Parameter Table length and version
408-
* @params: pointer to the 'struct spi_nor_flash_parameter' to be
409-
* filled
410408
*
411409
* The Basic Flash Parameter Table is the main and only mandatory table as
412410
* defined by the SFDP (JESD216) specification.
@@ -431,9 +429,9 @@ static void spi_nor_regions_sort_erase_types(struct spi_nor_erase_map *map)
431429
* Return: 0 on success, -errno otherwise.
432430
*/
433431
static int spi_nor_parse_bfpt(struct spi_nor *nor,
434-
const struct sfdp_parameter_header *bfpt_header,
435-
struct spi_nor_flash_parameter *params)
432+
const struct sfdp_parameter_header *bfpt_header)
436433
{
434+
struct spi_nor_flash_parameter *params = nor->params;
437435
struct spi_nor_erase_map *map = &params->erase_map;
438436
struct spi_nor_erase_type *erase_type = map->erase_type;
439437
struct sfdp_bfpt bfpt;
@@ -552,8 +550,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
552550

553551
/* Stop here if not JESD216 rev A or later. */
554552
if (bfpt_header->length == BFPT_DWORD_MAX_JESD216)
555-
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt,
556-
params);
553+
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
557554

558555
/* Page size: this field specifies 'N' so the page size = 2^N bytes. */
559556
val = bfpt.dwords[BFPT_DWORD(11)];
@@ -614,8 +611,8 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
614611

615612
/* Stop here if not JESD216 rev C or later. */
616613
if (bfpt_header->length == BFPT_DWORD_MAX_JESD216B)
617-
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt,
618-
params);
614+
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
615+
619616
/* 8D-8D-8D command extension. */
620617
switch (bfpt.dwords[BFPT_DWORD(18)] & BFPT_DWORD18_CMD_EXT_MASK) {
621618
case BFPT_DWORD18_CMD_EXT_REP:
@@ -635,7 +632,7 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
635632
return -EOPNOTSUPP;
636633
}
637634

638-
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt, params);
635+
return spi_nor_post_bfpt_fixups(nor, bfpt_header, &bfpt);
639636
}
640637

641638
/**
@@ -800,18 +797,14 @@ spi_nor_region_check_overlay(struct spi_nor_erase_region *region,
800797
/**
801798
* spi_nor_init_non_uniform_erase_map() - initialize the non-uniform erase map
802799
* @nor: pointer to a 'struct spi_nor'
803-
* @params: pointer to a duplicate 'struct spi_nor_flash_parameter' that is
804-
* used for storing SFDP parsed data
805800
* @smpt: pointer to the sector map parameter table
806801
*
807802
* Return: 0 on success, -errno otherwise.
808803
*/
809-
static int
810-
spi_nor_init_non_uniform_erase_map(struct spi_nor *nor,
811-
struct spi_nor_flash_parameter *params,
812-
const u32 *smpt)
804+
static int spi_nor_init_non_uniform_erase_map(struct spi_nor *nor,
805+
const u32 *smpt)
813806
{
814-
struct spi_nor_erase_map *map = &params->erase_map;
807+
struct spi_nor_erase_map *map = &nor->params->erase_map;
815808
struct spi_nor_erase_type *erase = map->erase_type;
816809
struct spi_nor_erase_region *region;
817810
u64 offset;
@@ -889,8 +882,6 @@ spi_nor_init_non_uniform_erase_map(struct spi_nor *nor,
889882
* spi_nor_parse_smpt() - parse Sector Map Parameter Table
890883
* @nor: pointer to a 'struct spi_nor'
891884
* @smpt_header: sector map parameter table header
892-
* @params: pointer to a duplicate 'struct spi_nor_flash_parameter'
893-
* that is used for storing SFDP parsed data
894885
*
895886
* This table is optional, but when available, we parse it to identify the
896887
* location and size of sectors within the main data array of the flash memory
@@ -899,8 +890,7 @@ spi_nor_init_non_uniform_erase_map(struct spi_nor *nor,
899890
* Return: 0 on success, -errno otherwise.
900891
*/
901892
static int spi_nor_parse_smpt(struct spi_nor *nor,
902-
const struct sfdp_parameter_header *smpt_header,
903-
struct spi_nor_flash_parameter *params)
893+
const struct sfdp_parameter_header *smpt_header)
904894
{
905895
const u32 *sector_map;
906896
u32 *smpt;
@@ -928,11 +918,11 @@ static int spi_nor_parse_smpt(struct spi_nor *nor,
928918
goto out;
929919
}
930920

931-
ret = spi_nor_init_non_uniform_erase_map(nor, params, sector_map);
921+
ret = spi_nor_init_non_uniform_erase_map(nor, sector_map);
932922
if (ret)
933923
goto out;
934924

935-
spi_nor_regions_sort_erase_types(&params->erase_map);
925+
spi_nor_regions_sort_erase_types(&nor->params->erase_map);
936926
/* fall through */
937927
out:
938928
kfree(smpt);
@@ -944,13 +934,11 @@ static int spi_nor_parse_smpt(struct spi_nor *nor,
944934
* @nor: pointer to a 'struct spi_nor'.
945935
* @param_header: pointer to the 'struct sfdp_parameter_header' describing
946936
* the 4-Byte Address Instruction Table length and version.
947-
* @params: pointer to the 'struct spi_nor_flash_parameter' to be.
948937
*
949938
* Return: 0 on success, -errno otherwise.
950939
*/
951940
static int spi_nor_parse_4bait(struct spi_nor *nor,
952-
const struct sfdp_parameter_header *param_header,
953-
struct spi_nor_flash_parameter *params)
941+
const struct sfdp_parameter_header *param_header)
954942
{
955943
static const struct sfdp_4bait reads[] = {
956944
{ SNOR_HWCAPS_READ, BIT(0) },
@@ -974,6 +962,7 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
974962
{ 0u /* not used */, BIT(11) },
975963
{ 0u /* not used */, BIT(12) },
976964
};
965+
struct spi_nor_flash_parameter *params = nor->params;
977966
struct spi_nor_pp_command *params_pp = params->page_programs;
978967
struct spi_nor_erase_map *map = &params->erase_map;
979968
struct spi_nor_erase_type *erase_type = map->erase_type;
@@ -1130,13 +1119,11 @@ static int spi_nor_parse_4bait(struct spi_nor *nor,
11301119
* @nor: pointer to a 'struct spi_nor'
11311120
* @profile1_header: pointer to the 'struct sfdp_parameter_header' describing
11321121
* the Profile 1.0 Table length and version.
1133-
* @params: pointer to the 'struct spi_nor_flash_parameter' to be.
11341122
*
11351123
* Return: 0 on success, -errno otherwise.
11361124
*/
11371125
static int spi_nor_parse_profile1(struct spi_nor *nor,
1138-
const struct sfdp_parameter_header *profile1_header,
1139-
struct spi_nor_flash_parameter *params)
1126+
const struct sfdp_parameter_header *profile1_header)
11401127
{
11411128
u32 *dwords, addr;
11421129
size_t len;
@@ -1160,14 +1147,14 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,
11601147

11611148
/* Set the Read Status Register dummy cycles and dummy address bytes. */
11621149
if (dwords[0] & PROFILE1_DWORD1_RDSR_DUMMY)
1163-
params->rdsr_dummy = 8;
1150+
nor->params->rdsr_dummy = 8;
11641151
else
1165-
params->rdsr_dummy = 4;
1152+
nor->params->rdsr_dummy = 4;
11661153

11671154
if (dwords[0] & PROFILE1_DWORD1_RDSR_ADDR_BYTES)
1168-
params->rdsr_addr_nbytes = 4;
1155+
nor->params->rdsr_addr_nbytes = 4;
11691156
else
1170-
params->rdsr_addr_nbytes = 0;
1157+
nor->params->rdsr_addr_nbytes = 0;
11711158

11721159
/*
11731160
* We don't know what speed the controller is running at. Find the
@@ -1193,7 +1180,7 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,
11931180
dummy = round_up(dummy, 2);
11941181

11951182
/* Update the fast read settings. */
1196-
spi_nor_set_read_settings(&params->reads[SNOR_CMD_READ_8_8_8_DTR],
1183+
spi_nor_set_read_settings(&nor->params->reads[SNOR_CMD_READ_8_8_8_DTR],
11971184
0, dummy, opcode,
11981185
SNOR_PROTO_8_8_8_DTR);
11991186

@@ -1210,13 +1197,11 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,
12101197
* @nor: pointer to a 'struct spi_nor'
12111198
* @sccr_header: pointer to the 'struct sfdp_parameter_header' describing
12121199
* the SCCR Map table length and version.
1213-
* @params: pointer to the 'struct spi_nor_flash_parameter' to be.
12141200
*
12151201
* Return: 0 on success, -errno otherwise.
12161202
*/
12171203
static int spi_nor_parse_sccr(struct spi_nor *nor,
1218-
const struct sfdp_parameter_header *sccr_header,
1219-
struct spi_nor_flash_parameter *params)
1204+
const struct sfdp_parameter_header *sccr_header)
12201205
{
12211206
u32 *dwords, addr;
12221207
size_t len;
@@ -1245,8 +1230,6 @@ static int spi_nor_parse_sccr(struct spi_nor *nor,
12451230
/**
12461231
* spi_nor_parse_sfdp() - parse the Serial Flash Discoverable Parameters.
12471232
* @nor: pointer to a 'struct spi_nor'
1248-
* @params: pointer to the 'struct spi_nor_flash_parameter' to be
1249-
* filled
12501233
*
12511234
* The Serial Flash Discoverable Parameters are described by the JEDEC JESD216
12521235
* specification. This is a standard which tends to supported by almost all
@@ -1256,8 +1239,7 @@ static int spi_nor_parse_sccr(struct spi_nor *nor,
12561239
*
12571240
* Return: 0 on success, -errno otherwise.
12581241
*/
1259-
int spi_nor_parse_sfdp(struct spi_nor *nor,
1260-
struct spi_nor_flash_parameter *params)
1242+
int spi_nor_parse_sfdp(struct spi_nor *nor)
12611243
{
12621244
const struct sfdp_parameter_header *param_header, *bfpt_header;
12631245
struct sfdp_parameter_header *param_headers = NULL;
@@ -1326,7 +1308,7 @@ int spi_nor_parse_sfdp(struct spi_nor *nor,
13261308
bfpt_header = param_header;
13271309
}
13281310

1329-
err = spi_nor_parse_bfpt(nor, bfpt_header, params);
1311+
err = spi_nor_parse_bfpt(nor, bfpt_header);
13301312
if (err)
13311313
goto exit;
13321314

@@ -1336,19 +1318,19 @@ int spi_nor_parse_sfdp(struct spi_nor *nor,
13361318

13371319
switch (SFDP_PARAM_HEADER_ID(param_header)) {
13381320
case SFDP_SECTOR_MAP_ID:
1339-
err = spi_nor_parse_smpt(nor, param_header, params);
1321+
err = spi_nor_parse_smpt(nor, param_header);
13401322
break;
13411323

13421324
case SFDP_4BAIT_ID:
1343-
err = spi_nor_parse_4bait(nor, param_header, params);
1325+
err = spi_nor_parse_4bait(nor, param_header);
13441326
break;
13451327

13461328
case SFDP_PROFILE1_ID:
1347-
err = spi_nor_parse_profile1(nor, param_header, params);
1329+
err = spi_nor_parse_profile1(nor, param_header);
13481330
break;
13491331

13501332
case SFDP_SCCR_MAP_ID:
1351-
err = spi_nor_parse_sccr(nor, param_header, params);
1333+
err = spi_nor_parse_sccr(nor, param_header);
13521334
break;
13531335

13541336
default:

drivers/mtd/spi-nor/sfdp.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ struct sfdp_parameter_header {
107107
u8 id_msb;
108108
};
109109

110-
int spi_nor_parse_sfdp(struct spi_nor *nor,
111-
struct spi_nor_flash_parameter *params);
110+
int spi_nor_parse_sfdp(struct spi_nor *nor);
112111

113112
#endif /* __LINUX_MTD_SFDP_H */

drivers/mtd/spi-nor/spansion.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ static void s28hs512t_post_sfdp_fixup(struct spi_nor *nor)
142142

143143
static int s28hs512t_post_bfpt_fixup(struct spi_nor *nor,
144144
const struct sfdp_parameter_header *bfpt_header,
145-
const struct sfdp_bfpt *bfpt,
146-
struct spi_nor_flash_parameter *params)
145+
const struct sfdp_bfpt *bfpt)
147146
{
148147
/*
149148
* 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,
162161
return ret;
163162

164163
if (nor->bouncebuf[0] & SPINOR_REG_CYPRESS_CFR3V_PGSZ)
165-
params->page_size = 512;
164+
nor->params->page_size = 512;
166165
else
167-
params->page_size = 256;
166+
nor->params->page_size = 256;
168167

169168
return 0;
170169
}
@@ -178,16 +177,15 @@ static struct spi_nor_fixups s28hs512t_fixups = {
178177
static int
179178
s25fs_s_post_bfpt_fixups(struct spi_nor *nor,
180179
const struct sfdp_parameter_header *bfpt_header,
181-
const struct sfdp_bfpt *bfpt,
182-
struct spi_nor_flash_parameter *params)
180+
const struct sfdp_bfpt *bfpt)
183181
{
184182
/*
185183
* The S25FS-S chip family reports 512-byte pages in BFPT but
186184
* in reality the write buffer still wraps at the safe default
187185
* of 256 bytes. Overwrite the page size advertised by BFPT
188186
* to get the writes working.
189187
*/
190-
params->page_size = 256;
188+
nor->params->page_size = 256;
191189

192190
return 0;
193191
}

drivers/mtd/spi-nor/winbond.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
static int
1212
w25q256_post_bfpt_fixups(struct spi_nor *nor,
1313
const struct sfdp_parameter_header *bfpt_header,
14-
const struct sfdp_bfpt *bfpt,
15-
struct spi_nor_flash_parameter *params)
14+
const struct sfdp_bfpt *bfpt)
1615
{
1716
/*
1817
* W25Q256JV supports 4B opcodes but W25Q256FV does not.

0 commit comments

Comments
 (0)