diff options
-rw-r--r-- | drivers/spi/spi.c | 12 | ||||
-rw-r--r-- | include/linux/spi/spi.h | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 5d046be8b2dd..dfce0f7d4c64 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); diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index 877395e075af..635a05c30283 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h @@ -1515,6 +1515,9 @@ extern void spi_unregister_device(struct spi_device *spi); extern const struct spi_device_id * spi_get_device_id(const struct spi_device *sdev); +extern const void * +spi_get_device_match_data(const struct spi_device *sdev); + static inline bool spi_transfer_is_last(struct spi_controller *ctlr, struct spi_transfer *xfer) { |