aboutsummaryrefslogtreecommitdiff
path: root/drivers/spi/spi.c
diff options
context:
space:
mode:
authorGravatar Andy Shevchenko <andriy.shevchenko@linux.intel.com> 2022-10-20 22:54:21 +0300
committerGravatar Mark Brown <broonie@kernel.org> 2022-10-21 13:05:45 +0100
commitaea672d054a21782ed8450c75febb6ba3c208ca4 (patch)
tree652bad507f7519745849996a530c9a20bdcea075 /drivers/spi/spi.c
parentspi: spi-zyqnmp-gqspi: Add tap delay and Versal platform support (diff)
downloadlinux-aea672d054a21782ed8450c75febb6ba3c208ca4.tar.gz
linux-aea672d054a21782ed8450c75febb6ba3c208ca4.tar.bz2
linux-aea672d054a21782ed8450c75febb6ba3c208ca4.zip
spi: Introduce spi_get_device_match_data() helper
The proposed spi_get_device_match_data() helper is for retrieving a driver data associated with the ID in an ID table. First, it tries to get driver data of the device enumerated by firmware interface (usually Device Tree or ACPI). If none is found it falls back to the SPI ID table matching. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20221020195421.10482-1-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi.c')
-rw-r--r--drivers/spi/spi.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 5f9aedd1f0b6..aaf07052fd01 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -360,6 +360,18 @@ const struct spi_device_id *spi_get_device_id(const struct spi_device *sdev)
}
EXPORT_SYMBOL_GPL(spi_get_device_id);
+const void *spi_get_device_match_data(const struct spi_device *sdev)
+{
+ const void *match;
+
+ match = device_get_match_data(&sdev->dev);
+ if (match)
+ return match;
+
+ return (const void *)spi_get_device_id(sdev)->driver_data;
+}
+EXPORT_SYMBOL_GPL(spi_get_device_match_data);
+
static int spi_match_device(struct device *dev, struct device_driver *drv)
{
const struct spi_device *spi = to_spi_device(dev);