未验证 提交 aea672d0 编写于 作者: A Andy Shevchenko 提交者: Mark Brown

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: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20221020195421.10482-1-andriy.shevchenko@linux.intel.comSigned-off-by: NMark Brown <broonie@kernel.org>
上级 f74d2182
...@@ -360,6 +360,18 @@ const struct spi_device_id *spi_get_device_id(const struct spi_device *sdev) ...@@ -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); 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) static int spi_match_device(struct device *dev, struct device_driver *drv)
{ {
const struct spi_device *spi = to_spi_device(dev); const struct spi_device *spi = to_spi_device(dev);
......
...@@ -1514,6 +1514,9 @@ extern void spi_unregister_device(struct spi_device *spi); ...@@ -1514,6 +1514,9 @@ extern void spi_unregister_device(struct spi_device *spi);
extern const struct spi_device_id * extern const struct spi_device_id *
spi_get_device_id(const struct spi_device *sdev); 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 static inline bool
spi_transfer_is_last(struct spi_controller *ctlr, struct spi_transfer *xfer) spi_transfer_is_last(struct spi_controller *ctlr, struct spi_transfer *xfer)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册