Skip to content

Commit c452d49

Browse files
committed
mtd: spi-nor: s/addr_width/addr_nbytes
Address width was an unfortunate name, as it means the number of IO lines used for the address, whereas in the code it is used as the number of address bytes. s/addr_width/addr_nbytes throughout the entire SPI NOR framework. Signed-off-by: Tudor Ambarus <[email protected]> Reviewed-by: Michael Walle <[email protected]> Acked-by: Pratyush Yadav <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 41e4f15 commit c452d49

File tree

10 files changed

+68
-68
lines changed

10 files changed

+68
-68
lines changed

drivers/mtd/spi-nor/controllers/hisi-sfc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static int hisi_spi_nor_dma_transfer(struct spi_nor *nor, loff_t start_off,
237237
reg = readl(host->regbase + FMC_CFG);
238238
reg &= ~(FMC_CFG_OP_MODE_MASK | SPI_NOR_ADDR_MODE_MASK);
239239
reg |= FMC_CFG_OP_MODE_NORMAL;
240-
reg |= (nor->addr_width == 4) ? SPI_NOR_ADDR_MODE_4BYTES
240+
reg |= (nor->addr_nbytes == 4) ? SPI_NOR_ADDR_MODE_4BYTES
241241
: SPI_NOR_ADDR_MODE_3BYTES;
242242
writel(reg, host->regbase + FMC_CFG);
243243

drivers/mtd/spi-nor/controllers/nxp-spifi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static ssize_t nxp_spifi_write(struct spi_nor *nor, loff_t to, size_t len,
203203
SPIFI_CMD_DATALEN(len) |
204204
SPIFI_CMD_FIELDFORM_ALL_SERIAL |
205205
SPIFI_CMD_OPCODE(nor->program_opcode) |
206-
SPIFI_CMD_FRAMEFORM(spifi->nor.addr_width + 1);
206+
SPIFI_CMD_FRAMEFORM(spifi->nor.addr_nbytes + 1);
207207
writel(cmd, spifi->io_base + SPIFI_CMD);
208208

209209
for (i = 0; i < len; i++)
@@ -230,7 +230,7 @@ static int nxp_spifi_erase(struct spi_nor *nor, loff_t offs)
230230

231231
cmd = SPIFI_CMD_FIELDFORM_ALL_SERIAL |
232232
SPIFI_CMD_OPCODE(nor->erase_opcode) |
233-
SPIFI_CMD_FRAMEFORM(spifi->nor.addr_width + 1);
233+
SPIFI_CMD_FRAMEFORM(spifi->nor.addr_nbytes + 1);
234234
writel(cmd, spifi->io_base + SPIFI_CMD);
235235

236236
return nxp_spifi_wait_for_cmd(spifi);
@@ -252,12 +252,12 @@ static int nxp_spifi_setup_memory_cmd(struct nxp_spifi *spifi)
252252
}
253253

254254
/* Memory mode supports address length between 1 and 4 */
255-
if (spifi->nor.addr_width < 1 || spifi->nor.addr_width > 4)
255+
if (spifi->nor.addr_nbytes < 1 || spifi->nor.addr_nbytes > 4)
256256
return -EINVAL;
257257

258258
spifi->mcmd |= SPIFI_CMD_OPCODE(spifi->nor.read_opcode) |
259259
SPIFI_CMD_INTLEN(spifi->nor.read_dummy / 8) |
260-
SPIFI_CMD_FRAMEFORM(spifi->nor.addr_width + 1);
260+
SPIFI_CMD_FRAMEFORM(spifi->nor.addr_nbytes + 1);
261261

262262
return 0;
263263
}

drivers/mtd/spi-nor/core.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
*/
3939
#define CHIP_ERASE_2MB_READY_WAIT_JIFFIES (40UL * HZ)
4040

41-
#define SPI_NOR_MAX_ADDR_WIDTH 4
41+
#define SPI_NOR_MAX_ADDR_NBYTES 4
4242

4343
#define SPI_NOR_SRST_SLEEP_MIN 200
4444
#define SPI_NOR_SRST_SLEEP_MAX 400
@@ -198,7 +198,7 @@ static ssize_t spi_nor_spimem_read_data(struct spi_nor *nor, loff_t from,
198198
{
199199
struct spi_mem_op op =
200200
SPI_MEM_OP(SPI_MEM_OP_CMD(nor->read_opcode, 0),
201-
SPI_MEM_OP_ADDR(nor->addr_width, from, 0),
201+
SPI_MEM_OP_ADDR(nor->addr_nbytes, from, 0),
202202
SPI_MEM_OP_DUMMY(nor->read_dummy, 0),
203203
SPI_MEM_OP_DATA_IN(len, buf, 0));
204204
bool usebouncebuf;
@@ -262,7 +262,7 @@ static ssize_t spi_nor_spimem_write_data(struct spi_nor *nor, loff_t to,
262262
{
263263
struct spi_mem_op op =
264264
SPI_MEM_OP(SPI_MEM_OP_CMD(nor->program_opcode, 0),
265-
SPI_MEM_OP_ADDR(nor->addr_width, to, 0),
265+
SPI_MEM_OP_ADDR(nor->addr_nbytes, to, 0),
266266
SPI_MEM_OP_NO_DUMMY,
267267
SPI_MEM_OP_DATA_OUT(len, buf, 0));
268268
ssize_t nbytes;
@@ -1113,7 +1113,7 @@ int spi_nor_erase_sector(struct spi_nor *nor, u32 addr)
11131113
if (nor->spimem) {
11141114
struct spi_mem_op op =
11151115
SPI_NOR_SECTOR_ERASE_OP(nor->erase_opcode,
1116-
nor->addr_width, addr);
1116+
nor->addr_nbytes, addr);
11171117

11181118
spi_nor_spimem_setup_op(nor, &op, nor->write_proto);
11191119

@@ -1126,13 +1126,13 @@ int spi_nor_erase_sector(struct spi_nor *nor, u32 addr)
11261126
* Default implementation, if driver doesn't have a specialized HW
11271127
* control
11281128
*/
1129-
for (i = nor->addr_width - 1; i >= 0; i--) {
1129+
for (i = nor->addr_nbytes - 1; i >= 0; i--) {
11301130
nor->bouncebuf[i] = addr & 0xff;
11311131
addr >>= 8;
11321132
}
11331133

11341134
return spi_nor_controller_ops_write_reg(nor, nor->erase_opcode,
1135-
nor->bouncebuf, nor->addr_width);
1135+
nor->bouncebuf, nor->addr_nbytes);
11361136
}
11371137

11381138
/**
@@ -2249,43 +2249,43 @@ static int spi_nor_default_setup(struct spi_nor *nor,
22492249
return 0;
22502250
}
22512251

2252-
static int spi_nor_set_addr_width(struct spi_nor *nor)
2252+
static int spi_nor_set_addr_nbytes(struct spi_nor *nor)
22532253
{
2254-
if (nor->addr_width) {
2254+
if (nor->addr_nbytes) {
22552255
/* already configured from SFDP */
22562256
} else if (nor->read_proto == SNOR_PROTO_8_8_8_DTR) {
22572257
/*
22582258
* In 8D-8D-8D mode, one byte takes half a cycle to transfer. So
2259-
* in this protocol an odd address width cannot be used because
2259+
* in this protocol an odd addr_nbytes cannot be used because
22602260
* then the address phase would only span a cycle and a half.
22612261
* Half a cycle would be left over. We would then have to start
22622262
* the dummy phase in the middle of a cycle and so too the data
22632263
* phase, and we will end the transaction with half a cycle left
22642264
* over.
22652265
*
2266-
* Force all 8D-8D-8D flashes to use an address width of 4 to
2266+
* Force all 8D-8D-8D flashes to use an addr_nbytes of 4 to
22672267
* avoid this situation.
22682268
*/
2269-
nor->addr_width = 4;
2270-
} else if (nor->info->addr_width) {
2271-
nor->addr_width = nor->info->addr_width;
2269+
nor->addr_nbytes = 4;
2270+
} else if (nor->info->addr_nbytes) {
2271+
nor->addr_nbytes = nor->info->addr_nbytes;
22722272
} else {
2273-
nor->addr_width = 3;
2273+
nor->addr_nbytes = 3;
22742274
}
22752275

2276-
if (nor->addr_width == 3 && nor->params->size > 0x1000000) {
2276+
if (nor->addr_nbytes == 3 && nor->params->size > 0x1000000) {
22772277
/* enable 4-byte addressing if the device exceeds 16MiB */
2278-
nor->addr_width = 4;
2278+
nor->addr_nbytes = 4;
22792279
}
22802280

2281-
if (nor->addr_width > SPI_NOR_MAX_ADDR_WIDTH) {
2282-
dev_dbg(nor->dev, "address width is too large: %u\n",
2283-
nor->addr_width);
2281+
if (nor->addr_nbytes > SPI_NOR_MAX_ADDR_NBYTES) {
2282+
dev_dbg(nor->dev, "The number of address bytes is too large: %u\n",
2283+
nor->addr_nbytes);
22842284
return -EINVAL;
22852285
}
22862286

22872287
/* Set 4byte opcodes when possible. */
2288-
if (nor->addr_width == 4 && nor->flags & SNOR_F_4B_OPCODES &&
2288+
if (nor->addr_nbytes == 4 && nor->flags & SNOR_F_4B_OPCODES &&
22892289
!(nor->flags & SNOR_F_HAS_4BAIT))
22902290
spi_nor_set_4byte_opcodes(nor);
22912291

@@ -2304,7 +2304,7 @@ static int spi_nor_setup(struct spi_nor *nor,
23042304
if (ret)
23052305
return ret;
23062306

2307-
return spi_nor_set_addr_width(nor);
2307+
return spi_nor_set_addr_nbytes(nor);
23082308
}
23092309

23102310
/**
@@ -2492,7 +2492,7 @@ static void spi_nor_sfdp_init_params_deprecated(struct spi_nor *nor)
24922492

24932493
if (spi_nor_parse_sfdp(nor)) {
24942494
memcpy(nor->params, &sfdp_params, sizeof(*nor->params));
2495-
nor->addr_width = 0;
2495+
nor->addr_nbytes = 0;
24962496
nor->flags &= ~SNOR_F_4B_OPCODES;
24972497
}
24982498
}
@@ -2713,7 +2713,7 @@ static int spi_nor_init(struct spi_nor *nor)
27132713
nor->flags & SNOR_F_SWP_IS_VOLATILE))
27142714
spi_nor_try_unlock_all(nor);
27152715

2716-
if (nor->addr_width == 4 &&
2716+
if (nor->addr_nbytes == 4 &&
27172717
nor->read_proto != SNOR_PROTO_8_8_8_DTR &&
27182718
!(nor->flags & SNOR_F_4B_OPCODES)) {
27192719
/*
@@ -2840,7 +2840,7 @@ static void spi_nor_put_device(struct mtd_info *mtd)
28402840
void spi_nor_restore(struct spi_nor *nor)
28412841
{
28422842
/* restore the addressing mode */
2843-
if (nor->addr_width == 4 && !(nor->flags & SNOR_F_4B_OPCODES) &&
2843+
if (nor->addr_nbytes == 4 && !(nor->flags & SNOR_F_4B_OPCODES) &&
28442844
nor->flags & SNOR_F_BROKEN_RESET)
28452845
nor->params->set_4byte_addr_mode(nor, false);
28462846

@@ -2984,7 +2984,7 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
29842984
* - select op codes for (Fast) Read, Page Program and Sector Erase.
29852985
* - set the number of dummy cycles (mode cycles + wait states).
29862986
* - set the SPI protocols for register and memory accesses.
2987-
* - set the address width.
2987+
* - set the number of address bytes.
29882988
*/
29892989
ret = spi_nor_setup(nor, hwcaps);
29902990
if (ret)
@@ -3025,7 +3025,7 @@ static int spi_nor_create_read_dirmap(struct spi_nor *nor)
30253025
{
30263026
struct spi_mem_dirmap_info info = {
30273027
.op_tmpl = SPI_MEM_OP(SPI_MEM_OP_CMD(nor->read_opcode, 0),
3028-
SPI_MEM_OP_ADDR(nor->addr_width, 0, 0),
3028+
SPI_MEM_OP_ADDR(nor->addr_nbytes, 0, 0),
30293029
SPI_MEM_OP_DUMMY(nor->read_dummy, 0),
30303030
SPI_MEM_OP_DATA_IN(0, NULL, 0)),
30313031
.offset = 0,
@@ -3056,7 +3056,7 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor)
30563056
{
30573057
struct spi_mem_dirmap_info info = {
30583058
.op_tmpl = SPI_MEM_OP(SPI_MEM_OP_CMD(nor->program_opcode, 0),
3059-
SPI_MEM_OP_ADDR(nor->addr_width, 0, 0),
3059+
SPI_MEM_OP_ADDR(nor->addr_nbytes, 0, 0),
30603060
SPI_MEM_OP_NO_DUMMY,
30613061
SPI_MEM_OP_DATA_OUT(0, NULL, 0)),
30623062
.offset = 0,

drivers/mtd/spi-nor/core.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@
8484
SPI_MEM_OP_NO_DUMMY, \
8585
SPI_MEM_OP_NO_DATA)
8686

87-
#define SPI_NOR_SECTOR_ERASE_OP(opcode, addr_width, addr) \
87+
#define SPI_NOR_SECTOR_ERASE_OP(opcode, addr_nbytes, addr) \
8888
SPI_MEM_OP(SPI_MEM_OP_CMD(opcode, 0), \
89-
SPI_MEM_OP_ADDR(addr_width, addr, 0), \
89+
SPI_MEM_OP_ADDR(addr_nbytes, addr, 0), \
9090
SPI_MEM_OP_NO_DUMMY, \
9191
SPI_MEM_OP_NO_DATA)
9292

@@ -429,7 +429,7 @@ struct spi_nor_fixups {
429429
* isn't necessarily called a "sector" by the vendor.
430430
* @n_sectors: the number of sectors.
431431
* @page_size: the flash's page size.
432-
* @addr_width: the flash's address width.
432+
* @addr_nbytes: number of address bytes to send.
433433
*
434434
* @parse_sfdp: true when flash supports SFDP tables. The false value has no
435435
* meaning. If one wants to skip the SFDP tables, one should
@@ -487,7 +487,7 @@ struct flash_info {
487487
unsigned sector_size;
488488
u16 n_sectors;
489489
u16 page_size;
490-
u16 addr_width;
490+
u16 addr_nbytes;
491491

492492
bool parse_sfdp;
493493
u16 flags;
@@ -548,11 +548,11 @@ struct flash_info {
548548
.n_sectors = (_n_sectors), \
549549
.page_size = 256, \
550550

551-
#define CAT25_INFO(_sector_size, _n_sectors, _page_size, _addr_width) \
551+
#define CAT25_INFO(_sector_size, _n_sectors, _page_size, _addr_nbytes) \
552552
.sector_size = (_sector_size), \
553553
.n_sectors = (_n_sectors), \
554554
.page_size = (_page_size), \
555-
.addr_width = (_addr_width), \
555+
.addr_nbytes = (_addr_nbytes), \
556556
.flags = SPI_NOR_NO_ERASE | SPI_NOR_NO_FR, \
557557

558558
#define OTP_INFO(_len, _n_regions, _base, _offset) \

drivers/mtd/spi-nor/debugfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static int spi_nor_params_show(struct seq_file *s, void *data)
8686
seq_printf(s, "size\t\t%s\n", buf);
8787
seq_printf(s, "write size\t%u\n", params->writesize);
8888
seq_printf(s, "page size\t%u\n", params->page_size);
89-
seq_printf(s, "address width\t%u\n", nor->addr_width);
89+
seq_printf(s, "address nbytes\t%u\n", nor->addr_nbytes);
9090

9191
seq_puts(s, "flags\t\t");
9292
spi_nor_print_flags(s, nor->flags, snor_f_names, sizeof(snor_f_names));

drivers/mtd/spi-nor/issi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ is25lp256_post_bfpt_fixups(struct spi_nor *nor,
1414
const struct sfdp_bfpt *bfpt)
1515
{
1616
/*
17-
* IS25LP256 supports 4B opcodes, but the BFPT advertises a
18-
* BFPT_DWORD1_ADDRESS_BYTES_3_ONLY address width.
19-
* Overwrite the address width advertised by the BFPT.
17+
* IS25LP256 supports 4B opcodes, but the BFPT advertises
18+
* BFPT_DWORD1_ADDRESS_BYTES_3_ONLY.
19+
* Overwrite the number of address bytes advertised by the BFPT.
2020
*/
2121
if ((bfpt->dwords[BFPT_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) ==
2222
BFPT_DWORD1_ADDRESS_BYTES_3_ONLY)
23-
nor->addr_width = 4;
23+
nor->addr_nbytes = 4;
2424

2525
return 0;
2626
}

drivers/mtd/spi-nor/otp.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@
3535
*/
3636
int spi_nor_otp_read_secr(struct spi_nor *nor, loff_t addr, size_t len, u8 *buf)
3737
{
38-
u8 addr_width, read_opcode, read_dummy;
38+
u8 addr_nbytes, read_opcode, read_dummy;
3939
struct spi_mem_dirmap_desc *rdesc;
4040
enum spi_nor_protocol read_proto;
4141
int ret;
4242

4343
read_opcode = nor->read_opcode;
44-
addr_width = nor->addr_width;
44+
addr_nbytes = nor->addr_nbytes;
4545
read_dummy = nor->read_dummy;
4646
read_proto = nor->read_proto;
4747
rdesc = nor->dirmap.rdesc;
@@ -54,7 +54,7 @@ int spi_nor_otp_read_secr(struct spi_nor *nor, loff_t addr, size_t len, u8 *buf)
5454
ret = spi_nor_read_data(nor, addr, len, buf);
5555

5656
nor->read_opcode = read_opcode;
57-
nor->addr_width = addr_width;
57+
nor->addr_nbytes = addr_nbytes;
5858
nor->read_dummy = read_dummy;
5959
nor->read_proto = read_proto;
6060
nor->dirmap.rdesc = rdesc;
@@ -85,11 +85,11 @@ int spi_nor_otp_write_secr(struct spi_nor *nor, loff_t addr, size_t len,
8585
{
8686
enum spi_nor_protocol write_proto;
8787
struct spi_mem_dirmap_desc *wdesc;
88-
u8 addr_width, program_opcode;
88+
u8 addr_nbytes, program_opcode;
8989
int ret, written;
9090

9191
program_opcode = nor->program_opcode;
92-
addr_width = nor->addr_width;
92+
addr_nbytes = nor->addr_nbytes;
9393
write_proto = nor->write_proto;
9494
wdesc = nor->dirmap.wdesc;
9595

@@ -113,7 +113,7 @@ int spi_nor_otp_write_secr(struct spi_nor *nor, loff_t addr, size_t len,
113113

114114
out:
115115
nor->program_opcode = program_opcode;
116-
nor->addr_width = addr_width;
116+
nor->addr_nbytes = addr_nbytes;
117117
nor->write_proto = write_proto;
118118
nor->dirmap.wdesc = wdesc;
119119

0 commit comments

Comments
 (0)