Skip to content

Commit

Permalink
spi: amd: Drop redundant check
Browse files Browse the repository at this point in the history
Both spi and spi-mem cores already take care of checking the minimum and
maximum speed for transfers depending on the controller
capabilities. There is no reason to repeat this check in controller
drivers.

Once this possible error condition removed from the function, it makes
no longer sense to return an int.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://patch.msgid.link/20241224-winbond-6-11-rc1-quad-support-v2-4-ad218dbc406f@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Miquel Raynal authored and Mark Brown committed Jan 9, 2025
1 parent d0e5fac commit e6204f3
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions drivers/spi/spi-amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,16 @@ static const struct amd_spi_freq amd_spi_freq[] = {
{ AMD_SPI_MIN_HZ, F_800KHz, 0},
};

static int amd_set_spi_freq(struct amd_spi *amd_spi, u32 speed_hz)
static void amd_set_spi_freq(struct amd_spi *amd_spi, u32 speed_hz)
{
unsigned int i, spd7_val, alt_spd;

if (speed_hz < AMD_SPI_MIN_HZ)
return -EINVAL;

for (i = 0; i < ARRAY_SIZE(amd_spi_freq); i++)
if (speed_hz >= amd_spi_freq[i].speed_hz)
break;

if (amd_spi->speed_hz == amd_spi_freq[i].speed_hz)
return 0;
return;

amd_spi->speed_hz = amd_spi_freq[i].speed_hz;

Expand All @@ -329,8 +326,6 @@ static int amd_set_spi_freq(struct amd_spi *amd_spi, u32 speed_hz)
amd_spi_setclear_reg32(amd_spi, AMD_SPI_SPEED_REG, spd7_val,
AMD_SPI_SPD7_MASK);
}

return 0;
}

static inline int amd_spi_fifo_xfer(struct amd_spi *amd_spi,
Expand Down Expand Up @@ -679,9 +674,7 @@ static int amd_spi_exec_mem_op(struct spi_mem *mem,

amd_spi = spi_controller_get_devdata(mem->spi->controller);

ret = amd_set_spi_freq(amd_spi, op->max_freq);
if (ret)
return ret;
amd_set_spi_freq(amd_spi, op->max_freq);

if (amd_spi->version == AMD_SPI_V2)
amd_set_spi_addr_mode(amd_spi, op);
Expand Down

0 comments on commit e6204f3

Please sign in to comment.