Skip to contentSkip to conversation

spi: Fix mismatched DT property access types

PATCH In review Rob Herring (Arm) 2 participants 2 messages Jun 12 – Jun 14

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: Fix mismatched DT property access types

The SPI drivers read properties whose bindings use normal uint32 cells. Using boolean or u16 helpers makes the access look like a different DT encoding and causes the property checker to flag the call sites.

Use presence checks for unsupported properties and read numeric cell properties through u32 helpers before assigning to driver fields.

Assisted-by Codex:gpt-5-5
---
 drivers/spi/spi-fsl-espi.c     | 2 +-
 drivers/spi/spi-hisi-kunpeng.c | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/spi/spi-fsl-espi.c +1 -1
index 45b9974ae911..7e8c1a124463 100644
@@ -760,7 +760,7 @@ static int of_fsl_espi_probe(struct platform_device *ofdev)
 	unsigned int irq, num_cs;
 	int ret;
 
-	if (of_property_read_bool(np, "mode")) {
+	if (of_property_present(np, "mode")) {
 		dev_err(dev, "mode property is not supported on ESPI!\n");
 		return -EINVAL;
 	}
drivers/spi/spi-hisi-kunpeng.c +4 -2
index 046bd894040b..0e61bf0bf2a4 100644
@@ -463,6 +463,7 @@ static int hisi_spi_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct spi_controller *host;
 	struct hisi_spi *hs;
+	u32 num_cs;
 	int ret, irq;
 
 	irq = platform_get_irq(pdev, 0);
@@ -495,10 +496,11 @@ static int hisi_spi_probe(struct platform_device *pdev)
 	if (host->max_speed_hz == 0)
 		return dev_err_probe(dev, -EINVAL, "spi-max-frequency can't be 0\n");
 
-	ret = device_property_read_u16(dev, "num-cs",
-					&host->num_chipselect);
+	ret = device_property_read_u32(dev, "num-cs", &num_cs);
 	if (ret)
 		host->num_chipselect = DEFAULT_NUM_CS;
+	else
+		host->num_chipselect = num_cs;
 
 	host->use_gpio_descriptors = true;
 	host->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP;
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 1 line · Rob Herring (Arm)

spi: Fix mismatched DT property access types

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.2

Thanks!

[1/1] spi: Fix mismatched DT property access types

      https://git.kernel.org/broonie/spi/c/f846d6899214

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark