Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: microchip-core-qspi: stop checking viability of op->max_freq in supports_op callback

In commit 13529647743d9 ("spi: microchip-core-qspi: Support per spi-mem
operation frequency switches") the logic for checking the viability of
op->max_freq in mchp_coreqspi_setup_clock() was copied into
mchp_coreqspi_supports_op(). Unfortunately, op->max_freq is not valid
when this function is called during probe but is instead zero.
Accordingly, baud_rate_val is calculated to be INT_MAX due to division
by zero, causing probe of the attached memory device to fail.

Seemingly spi-microchip-core-qspi was the only driver that had such a
modification made to its supports_op callback when the per_op_freq
capability was added, so just remove it to restore prior functionality.

CC: stable@vger.kernel.org
Reported-by: Valentina Fernandez <valentina.fernandezalanis@microchip.com>
Fixes: 13529647743d9 ("spi: microchip-core-qspi: Support per spi-mem operation frequency switches")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Message-ID: <20250825-during-ploy-939bdd068593@spud>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Conor Dooley and committed by
Mark Brown
89e7353f 1b237f19

-12
-12
drivers/spi/spi-microchip-core-qspi.c
··· 531 531 532 532 static bool mchp_coreqspi_supports_op(struct spi_mem *mem, const struct spi_mem_op *op) 533 533 { 534 - struct mchp_coreqspi *qspi = spi_controller_get_devdata(mem->spi->controller); 535 - unsigned long clk_hz; 536 - u32 baud_rate_val; 537 - 538 534 if (!spi_mem_default_supports_op(mem, op)) 539 535 return false; 540 536 ··· 552 556 if (op->data.dir == SPI_MEM_DATA_OUT) 553 557 return false; 554 558 } 555 - 556 - clk_hz = clk_get_rate(qspi->clk); 557 - if (!clk_hz) 558 - return false; 559 - 560 - baud_rate_val = DIV_ROUND_UP(clk_hz, 2 * op->max_freq); 561 - if (baud_rate_val > MAX_DIVIDER || baud_rate_val < MIN_DIVIDER) 562 - return false; 563 559 564 560 return true; 565 561 }