spi: cadence-quadspi: Assume device could match via platform
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Thu, 1 May 2025 15:02:01 +0000 (17:02 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 5 May 2025 10:31:28 +0000 (19:31 +0900)
Driver has only of_device_id table, however it also has MODULE_ALIAS()
for platform name, thus assume there is a configuration where this can
be loaded outside of OF system.  In such case of_device_get_match_data()
will return NULL, which is already checked in one place of probe()
function but not in the other, leading to Smatch warning:

  drivers/spi/spi-cadence-quadspi.c:1942 cqspi_probe() error: we previously assumed 'ddata' could be null (see line 1885)

Driver should be consistent, so assume device can be matched via
platform bus and of_device_get_match_data() can indeed return NULL.
This is also possible with malformed DTS on OF-platform: no unit address
and device node name matching driver name.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20250501-n-smatch-fixes-v2-3-d2ad9c1f2e67@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-cadence-quadspi.c

index c904627..fe0f122 100644 (file)
@@ -1949,7 +1949,7 @@ static int cqspi_probe(struct platform_device *pdev)
 
        host->num_chipselect = cqspi->num_chipselect;
 
-       if (ddata->quirks & CQSPI_SUPPORT_DEVICE_RESET)
+       if (ddata && (ddata->quirks & CQSPI_SUPPORT_DEVICE_RESET))
                cqspi_device_reset(cqspi);
 
        if (cqspi->use_direct_mode) {