aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 70845ccd85c3..8518a6eb63f3 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -59,9 +59,32 @@ static struct device_attribute spi_dev_attrs[] = {
59 * and the sysfs version makes coldplug work too. 59 * and the sysfs version makes coldplug work too.
60 */ 60 */
61 61
62static const struct spi_device_id *spi_match_id(const struct spi_device_id *id,
63 const struct spi_device *sdev)
64{
65 while (id->name[0]) {
66 if (!strcmp(sdev->modalias, id->name))
67 return id;
68 id++;
69 }
70 return NULL;
71}
72
73const struct spi_device_id *spi_get_device_id(const struct spi_device *sdev)
74{
75 const struct spi_driver *sdrv = to_spi_driver(sdev->dev.driver);
76
77 return spi_match_id(sdrv->id_table, sdev);
78}
79EXPORT_SYMBOL_GPL(spi_get_device_id);
80
62static int spi_match_device(struct device *dev, struct device_driver *drv) 81static int spi_match_device(struct device *dev, struct device_driver *drv)
63{ 82{
64 const struct spi_device *spi = to_spi_device(dev); 83 const struct spi_device *spi = to_spi_device(dev);
84 const struct spi_driver *sdrv = to_spi_driver(drv);
85
86 if (sdrv->id_table)
87 return !!spi_match_id(sdrv->id_table, spi);
65 88
66 return strcmp(spi->modalias, drv->name) == 0; 89 return strcmp(spi->modalias, drv->name) == 0;
67} 90}