Skip to content

Commit

Permalink
Merge tag 'spi-fix-v6.15-merge-window' of git://git.kernel.org/pub/sc…
Browse files Browse the repository at this point in the history
…m/linux/kernel/git/broonie/spi

Pull spi fixes from Mark Brown:
 "A small collection of fixes that came in during the merge window,
  everything is driver specific with nothing standing out particularly"

* tag 'spi-fix-v6.15-merge-window' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
  spi: bcm2835: Restore native CS probing when pinctrl-bcm2835 is absent
  spi: bcm2835: Do not call gpiod_put() on invalid descriptor
  spi: cadence-qspi: revert "Improve spi memory performance"
  spi: cadence: Fix out-of-bounds array access in cdns_mrvl_xspi_setup_clock()
  spi: fsl-qspi: use devm function instead of driver remove
  spi: SPI_QPIC_SNAND should be tristate and depend on MTD
  spi-rockchip: Fix register out of bounds access
  • Loading branch information
Linus Torvalds committed Apr 4, 2025
2 parents a05c6e6 + e19c127 commit 9636452
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 22 deletions.
4 changes: 2 additions & 2 deletions drivers/spi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -937,9 +937,9 @@ config SPI_QCOM_QSPI
QSPI(Quad SPI) driver for Qualcomm QSPI controller.

config SPI_QPIC_SNAND
bool "QPIC SNAND controller"
tristate "QPIC SNAND controller"
depends on ARCH_QCOM || COMPILE_TEST
select MTD
depends on MTD
help
QPIC_SNAND (QPIC SPI NAND) driver for Qualcomm QPIC controller.
QPIC controller supports both parallel nand and serial nand.
Expand Down
18 changes: 16 additions & 2 deletions drivers/spi/spi-bcm2835.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,8 @@ static void bcm2835_spi_cleanup(struct spi_device *spi)
sizeof(u32),
DMA_TO_DEVICE);

gpiod_put(bs->cs_gpio);
if (!IS_ERR(bs->cs_gpio))
gpiod_put(bs->cs_gpio);
spi_set_csgpiod(spi, 0, NULL);

kfree(target);
Expand Down Expand Up @@ -1225,7 +1226,12 @@ static int bcm2835_spi_setup(struct spi_device *spi)
struct bcm2835_spi *bs = spi_controller_get_devdata(ctlr);
struct bcm2835_spidev *target = spi_get_ctldata(spi);
struct gpiod_lookup_table *lookup __free(kfree) = NULL;
int ret;
const char *pinctrl_compats[] = {
"brcm,bcm2835-gpio",
"brcm,bcm2711-gpio",
"brcm,bcm7211-gpio",
};
int ret, i;
u32 cs;

if (!target) {
Expand Down Expand Up @@ -1290,6 +1296,14 @@ static int bcm2835_spi_setup(struct spi_device *spi)
goto err_cleanup;
}

for (i = 0; i < ARRAY_SIZE(pinctrl_compats); i++) {
if (of_find_compatible_node(NULL, NULL, pinctrl_compats[i]))
break;
}

if (i == ARRAY_SIZE(pinctrl_compats))
return 0;

/*
* TODO: The code below is a slightly better alternative to the utter
* abuse of the GPIO API that I found here before. It creates a
Expand Down
2 changes: 1 addition & 1 deletion drivers/spi/spi-cadence-quadspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,7 @@ static const struct cqspi_driver_platdata k2g_qspi = {

static const struct cqspi_driver_platdata am654_ospi = {
.hwcaps_mask = CQSPI_SUPPORTS_OCTAL | CQSPI_SUPPORTS_QUAD,
.quirks = CQSPI_DISABLE_DAC_MODE | CQSPI_NEEDS_WR_DELAY,
.quirks = CQSPI_NEEDS_WR_DELAY,
};

static const struct cqspi_driver_platdata intel_lgm_qspi = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/spi/spi-cadence-xspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ static bool cdns_mrvl_xspi_setup_clock(struct cdns_xspi_dev *cdns_xspi,
u32 clk_reg;
bool update_clk = false;

while (i < ARRAY_SIZE(cdns_mrvl_xspi_clk_div_list)) {
while (i < (ARRAY_SIZE(cdns_mrvl_xspi_clk_div_list) - 1)) {
clk_val = MRVL_XSPI_CLOCK_DIVIDED(
cdns_mrvl_xspi_clk_div_list[i]);
if (clk_val <= requested_clk)
Expand Down
31 changes: 17 additions & 14 deletions drivers/spi/spi-fsl-qspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,19 @@ static const struct spi_controller_mem_caps fsl_qspi_mem_caps = {
.per_op_freq = true,
};

static void fsl_qspi_cleanup(void *data)
{
struct fsl_qspi *q = data;

/* disable the hardware */
qspi_writel(q, QUADSPI_MCR_MDIS_MASK, q->iobase + QUADSPI_MCR);
qspi_writel(q, 0x0, q->iobase + QUADSPI_RSER);

fsl_qspi_clk_disable_unprep(q);

mutex_destroy(&q->lock);
}

static int fsl_qspi_probe(struct platform_device *pdev)
{
struct spi_controller *ctlr;
Expand Down Expand Up @@ -934,6 +947,10 @@ static int fsl_qspi_probe(struct platform_device *pdev)

ctlr->dev.of_node = np;

ret = devm_add_action_or_reset(dev, fsl_qspi_cleanup, q);
if (ret)
goto err_destroy_mutex;

ret = devm_spi_register_controller(dev, ctlr);
if (ret)
goto err_destroy_mutex;
Expand All @@ -953,19 +970,6 @@ static int fsl_qspi_probe(struct platform_device *pdev)
return ret;
}

static void fsl_qspi_remove(struct platform_device *pdev)
{
struct fsl_qspi *q = platform_get_drvdata(pdev);

/* disable the hardware */
qspi_writel(q, QUADSPI_MCR_MDIS_MASK, q->iobase + QUADSPI_MCR);
qspi_writel(q, 0x0, q->iobase + QUADSPI_RSER);

fsl_qspi_clk_disable_unprep(q);

mutex_destroy(&q->lock);
}

static int fsl_qspi_suspend(struct device *dev)
{
return 0;
Expand Down Expand Up @@ -1003,7 +1007,6 @@ static struct platform_driver fsl_qspi_driver = {
.pm = &fsl_qspi_pm_ops,
},
.probe = fsl_qspi_probe,
.remove = fsl_qspi_remove,
};
module_platform_driver(fsl_qspi_driver);

Expand Down
2 changes: 1 addition & 1 deletion drivers/spi/spi-qpic-snand.c
Original file line number Diff line number Diff line change
Expand Up @@ -1614,7 +1614,7 @@ static const struct of_device_id qcom_snandc_of_match[] = {
.data = &ipq9574_snandc_props,
},
{}
}
};
MODULE_DEVICE_TABLE(of, qcom_snandc_of_match);

static struct platform_driver qcom_spi_driver = {
Expand Down
2 changes: 1 addition & 1 deletion drivers/spi/spi-rockchip.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ static int rockchip_spi_config(struct rockchip_spi *rs,
cr0 |= (spi->mode & 0x3U) << CR0_SCPH_OFFSET;
if (spi->mode & SPI_LSB_FIRST)
cr0 |= CR0_FBM_LSB << CR0_FBM_OFFSET;
if (spi->mode & SPI_CS_HIGH)
if ((spi->mode & SPI_CS_HIGH) && !(spi_get_csgpiod(spi, 0)))
cr0 |= BIT(spi_get_chipselect(spi, 0)) << CR0_SOI_OFFSET;

if (xfer->rx_buf && xfer->tx_buf)
Expand Down

0 comments on commit 9636452

Please sign in to comment.