spi: Fixes for v6.17

A small collection of fixes that came in during the past week, a few
 driver specifics plus one fix for the spi-mem core where we weren't
 taking account of the frequency capabilities of the system when
 determining if it can support an operation.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmincWcACgkQJNaLcl1U
 h9AZJgf9GgIDY30+6IAW13I+g0UVOWyUi7rz6RN4fC6fNc82+OLfgkR4yKr7a2az
 77udyVqy/cgvUEC41OyJ8Tvl8mfPXjOQ8WzobYynq/ldvN4d7JRGeds2rF4qG3rF
 yz7sCDZBcBwZYQ5FGTsjawubFOjvgatafVcLUsZ6Q4gyt8lvyHs+Pl3P/XeEVlVZ
 GVbqJfzpidpxDxMII5E0TH+YGJwtU0BC0JGB0EfdW9/SKXRp3nkbMJIXVshmy5G3
 E8QLVE6brSL7hhDOjOtBfxEb5ddvibsEkNJUg//VfDFh3tTx3BGaFDxaCw/WPGtL
 JReicUkzH0bm6Qg++xkVaHh37XFLDw==
 =hyVr
 -----END PGP SIGNATURE-----

Merge tag 'spi-fix-v6.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi

Pull spi fixes from Mark Brown:
 "A small collection of fixes that came in during the past week, a few
  driver specifics plus one fix for the spi-mem core where we weren't
  taking account of the frequency capabilities of the system when
  determining if it can support an operation"

* tag 'spi-fix-v6.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
  spi: st: fix PM macros to use CONFIG_PM instead of CONFIG_PM_SLEEP
  spi: spi-qpic-snand: fix calculating of ECC OOB regions' properties
  spi: spi-fsl-lpspi: Clamp too high speed_hz
  spi: spi-mem: add spi_mem_adjust_op_freq() in spi_mem_supports_op()
  spi: spi-mem: Add missing kdoc argument
  spi: spi-qpic-snand: use correct CW_PER_PAGE value for OOB write
This commit is contained in:
Linus Torvalds 2025-08-21 16:28:00 -04:00
commit 9a36b58a88
4 changed files with 27 additions and 17 deletions

View file

@ -330,13 +330,11 @@ static int fsl_lpspi_set_bitrate(struct fsl_lpspi_data *fsl_lpspi)
}
if (config.speed_hz > perclk_rate / 2) {
dev_err(fsl_lpspi->dev,
"per-clk should be at least two times of transfer speed");
return -EINVAL;
div = 2;
} else {
div = DIV_ROUND_UP(perclk_rate, config.speed_hz);
}
div = DIV_ROUND_UP(perclk_rate, config.speed_hz);
for (prescale = 0; prescale <= prescale_max; prescale++) {
scldiv = div / (1 << prescale) - 2;
if (scldiv >= 0 && scldiv < 256) {

View file

@ -265,6 +265,9 @@ static bool spi_mem_internal_supports_op(struct spi_mem *mem,
*/
bool spi_mem_supports_op(struct spi_mem *mem, const struct spi_mem_op *op)
{
/* Make sure the operation frequency is correct before going futher */
spi_mem_adjust_op_freq(mem, (struct spi_mem_op *)op);
if (spi_mem_check_op(op))
return false;
@ -577,6 +580,7 @@ EXPORT_SYMBOL_GPL(spi_mem_adjust_op_freq);
* spi_mem_calc_op_duration() - Derives the theoretical length (in ns) of an
* operation. This helps finding the best variant
* among a list of possible choices.
* @mem: the SPI memory
* @op: the operation to benchmark
*
* Some chips have per-op frequency limitations, PCBs usually have their own

View file

@ -210,13 +210,21 @@ static int qcom_spi_ooblayout_ecc(struct mtd_info *mtd, int section,
struct qcom_nand_controller *snandc = nand_to_qcom_snand(nand);
struct qpic_ecc *qecc = snandc->qspi->ecc;
if (section > 1)
return -ERANGE;
switch (section) {
case 0:
oobregion->offset = 0;
oobregion->length = qecc->bytes * (qecc->steps - 1) +
qecc->bbm_size;
return 0;
case 1:
oobregion->offset = qecc->bytes * (qecc->steps - 1) +
qecc->bbm_size +
qecc->steps * 4;
oobregion->length = mtd->oobsize - oobregion->offset;
return 0;
}
oobregion->length = qecc->ecc_bytes_hw + qecc->spare_bytes;
oobregion->offset = mtd->oobsize - oobregion->length;
return 0;
return -ERANGE;
}
static int qcom_spi_ooblayout_free(struct mtd_info *mtd, int section,
@ -1196,7 +1204,7 @@ static int qcom_spi_program_oob(struct qcom_nand_controller *snandc,
u32 cfg0, cfg1, ecc_bch_cfg, ecc_buf_cfg;
cfg0 = (ecc_cfg->cfg0 & ~CW_PER_PAGE_MASK) |
FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1);
FIELD_PREP(CW_PER_PAGE_MASK, 0);
cfg1 = ecc_cfg->cfg1;
ecc_bch_cfg = ecc_cfg->ecc_bch_cfg;
ecc_buf_cfg = ecc_cfg->ecc_buf_cfg;

View file

@ -378,7 +378,7 @@ static void spi_st_remove(struct platform_device *pdev)
pinctrl_pm_select_sleep_state(&pdev->dev);
}
static int __maybe_unused spi_st_runtime_suspend(struct device *dev)
static int spi_st_runtime_suspend(struct device *dev)
{
struct spi_controller *host = dev_get_drvdata(dev);
struct spi_st *spi_st = spi_controller_get_devdata(host);
@ -391,7 +391,7 @@ static int __maybe_unused spi_st_runtime_suspend(struct device *dev)
return 0;
}
static int __maybe_unused spi_st_runtime_resume(struct device *dev)
static int spi_st_runtime_resume(struct device *dev)
{
struct spi_controller *host = dev_get_drvdata(dev);
struct spi_st *spi_st = spi_controller_get_devdata(host);
@ -428,8 +428,8 @@ static int __maybe_unused spi_st_resume(struct device *dev)
}
static const struct dev_pm_ops spi_st_pm = {
SET_SYSTEM_SLEEP_PM_OPS(spi_st_suspend, spi_st_resume)
SET_RUNTIME_PM_OPS(spi_st_runtime_suspend, spi_st_runtime_resume, NULL)
SYSTEM_SLEEP_PM_OPS(spi_st_suspend, spi_st_resume)
RUNTIME_PM_OPS(spi_st_runtime_suspend, spi_st_runtime_resume, NULL)
};
static const struct of_device_id stm_spi_match[] = {
@ -441,7 +441,7 @@ MODULE_DEVICE_TABLE(of, stm_spi_match);
static struct platform_driver spi_st_driver = {
.driver = {
.name = "spi-st",
.pm = pm_sleep_ptr(&spi_st_pm),
.pm = pm_ptr(&spi_st_pm),
.of_match_table = of_match_ptr(stm_spi_match),
},
.probe = spi_st_probe,