Skip to content

Commit 42f5994

Browse files
committed
mtd: spi-nor: Drop quad_enable() from 'struct spi-nor'
All flash parameters and settings should reside inside 'struct spi_nor_flash_parameter'. Drop the local copy of quad_enable() and use the one from 'struct spi_nor_flash_parameter'. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Vignesh Raghavendra <vigneshr@ti.com>
1 parent 1e35a56 commit 42f5994

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

drivers/mtd/spi-nor/spi-nor.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4403,7 +4403,6 @@ static int spi_nor_setup(struct spi_nor *nor,
44034403
{
44044404
struct spi_nor_flash_parameter *params = &nor->params;
44054405
u32 ignored_mask, shared_mask;
4406-
bool enable_quad_io;
44074406
int err;
44084407

44094408
/*
@@ -4457,23 +4456,33 @@ static int spi_nor_setup(struct spi_nor *nor,
44574456
return err;
44584457
}
44594458

4460-
/* Enable Quad I/O if needed. */
4461-
enable_quad_io = (spi_nor_get_protocol_width(nor->read_proto) == 4 ||
4462-
spi_nor_get_protocol_width(nor->write_proto) == 4);
4463-
if (enable_quad_io && params->quad_enable)
4464-
nor->quad_enable = params->quad_enable;
4465-
else
4466-
nor->quad_enable = NULL;
4467-
44684459
return 0;
44694460
}
44704461

4462+
/**
4463+
* spi_nor_quad_enable() - enable Quad I/O if needed.
4464+
* @nor: pointer to a 'struct spi_nor'
4465+
*
4466+
* Return: 0 on success, -errno otherwise.
4467+
*/
4468+
static int spi_nor_quad_enable(struct spi_nor *nor)
4469+
{
4470+
if (!nor->params.quad_enable)
4471+
return 0;
4472+
4473+
if (!(spi_nor_get_protocol_width(nor->read_proto) == 4 ||
4474+
spi_nor_get_protocol_width(nor->write_proto) == 4))
4475+
return 0;
4476+
4477+
return nor->params.quad_enable(nor);
4478+
}
4479+
44714480
static int spi_nor_init(struct spi_nor *nor)
44724481
{
44734482
int err;
44744483

44754484
if (nor->clear_sr_bp) {
4476-
if (nor->quad_enable == spansion_quad_enable)
4485+
if (nor->params.quad_enable == spansion_quad_enable)
44774486
nor->clear_sr_bp = spi_nor_spansion_clear_sr_bp;
44784487

44794488
err = nor->clear_sr_bp(nor);
@@ -4484,12 +4493,10 @@ static int spi_nor_init(struct spi_nor *nor)
44844493
}
44854494
}
44864495

4487-
if (nor->quad_enable) {
4488-
err = nor->quad_enable(nor);
4489-
if (err) {
4490-
dev_err(nor->dev, "quad mode not supported\n");
4491-
return err;
4492-
}
4496+
err = spi_nor_quad_enable(nor);
4497+
if (err) {
4498+
dev_err(nor->dev, "quad mode not supported\n");
4499+
return err;
44934500
}
44944501

44954502
if (nor->addr_width == 4 && !(nor->flags & SNOR_F_4B_OPCODES)) {
@@ -4706,7 +4713,6 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
47064713
* - select op codes for (Fast) Read, Page Program and Sector Erase.
47074714
* - set the number of dummy cycles (mode cycles + wait states).
47084715
* - set the SPI protocols for register and memory accesses.
4709-
* - set the Quad Enable bit if needed (required by SPI x-y-4 protos).
47104716
*/
47114717
ret = spi_nor_setup(nor, hwcaps);
47124718
if (ret)

include/linux/mtd/spi-nor.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ struct flash_info;
535535
* @flash_unlock: [FLASH-SPECIFIC] unlock a region of the SPI NOR
536536
* @flash_is_locked: [FLASH-SPECIFIC] check if a region of the SPI NOR is
537537
* completely locked
538-
* @quad_enable: [FLASH-SPECIFIC] enables SPI NOR quad mode
539538
* @clear_sr_bp: [FLASH-SPECIFIC] clears the Block Protection Bits from
540539
* the SPI NOR Status Register.
541540
* @params: [FLASH-SPECIFIC] SPI-NOR flash parameters and settings.
@@ -579,7 +578,6 @@ struct spi_nor {
579578
int (*flash_lock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
580579
int (*flash_unlock)(struct spi_nor *nor, loff_t ofs, uint64_t len);
581580
int (*flash_is_locked)(struct spi_nor *nor, loff_t ofs, uint64_t len);
582-
int (*quad_enable)(struct spi_nor *nor);
583581
int (*clear_sr_bp)(struct spi_nor *nor);
584582
struct spi_nor_flash_parameter params;
585583

0 commit comments

Comments
 (0)