]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
spi: Fix mismatched DT property access types
authorRob Herring (Arm) <robh@kernel.org>
Fri, 12 Jun 2026 21:50:17 +0000 (16:50 -0500)
committerMark Brown <broonie@kernel.org>
Sun, 14 Jun 2026 00:18:29 +0000 (01:18 +0100)
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
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Link: https://patch.msgid.link/20260612215017.1884893-1-robh@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-fsl-espi.c
drivers/spi/spi-hisi-kunpeng.c

index f560bd537f7d7ecac63b6ac96a8d6170738ec6a8..1341bdd7db75aa06ec501b0a8886224030ff614a 100644 (file)
@@ -756,7 +756,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;
        }
index 395214b81179ec4619dec3004045e63c464228e5..30fcdb5028dc235e6925a7ff2647234f696f45ef 100644 (file)
@@ -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;