Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The driver improperly restricts the total number of chip selects (`num_cs`) to the hardware's native maximum, causing probe to fail for valid device tree configurations that explicitly declare additional GPIO chip selects.
--
--- Patch [1]: [PATCH v2] spi: ma35d1-qspi: Enable GPIO chip selects ---
commit 9b36effcfaa138327c6207a2889e09445f4ecaba
Author: Chi-Wen Weng [off-list ref]
spi: ma35d1-qspi: Enable GPIO chip selects
The generic SPI controller binding allows GPIO-based chip selects, but
the MA35D1 QSPI driver does not currently enable the SPI core's GPIO
descriptor handling. Enable GPIO chip-select support and specify that
the controller provides two native chip selects.
quoted hunk ↗ jump to hunk
diff --git a/drivers/spi/spi-ma35d1-qspi.c b/drivers/spi/spi-ma35d1-qspi.c
index 541d5d72484cf..60e082de58f51 100644
--- a/drivers/spi/spi-ma35d1-qspi.c
+++ b/drivers/spi/spi-ma35d1-qspi.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -613,10 +624,13 @@ static int nuvoton_qspi_probe(struct platform_device *pdev)
num_cs);
ctlr->num_chipselect = num_cs;
+ ctlr->max_native_cs = NUVOTON_QSPI_MAX_NUM_CS;
+ ctlr->use_gpio_descriptors = true;
[Severity: Medium]
Since this patch enables GPIO chip selects, shouldn't the driver allow
configurations where the total number of chip selects exceeds the native
maximum?
In nuvoton_qspi_probe() just above this diff, there is a check:
if (!num_cs || num_cs > NUVOTON_QSPI_MAX_NUM_CS)
return dev_err_probe(dev, -EINVAL, "invalid num-cs %u\n",
num_cs);
If a device tree explicitly defines a higher value for num-cs (for example
num-cs = <3>) to declare additional GPIO chip selects alongside the native
ones, this check will cause the probe to fail with -EINVAL, preventing
any devices on the bus from functioning.
quoted hunk ↗ jump to hunk
ctlr->max_transfer_size = nuvoton_qspi_max_transfer_size;
ctlr->max_message_size = nuvoton_qspi_max_message_size;
ctlr->mem_ops = &nuvoton_qspi_mem_ops;
ctlr->mem_caps = &nuvoton_qspi_mem_caps;
+ ctlr->setup = nuvoton_qspi_setup;
ctlr->set_cs = nuvoton_qspi_set_cs;
ctlr->transfer_one = nuvoton_qspi_transfer_one;
ctlr->bits_per_word_mask = SPI_BPW_MASK(8);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803062444.1649057-1-cwweng.linux@gmail.com?part=1