diff options
| author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2009-09-22 19:46:04 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-23 10:39:43 -0400 |
| commit | 75368bf6c2876d8f33abfe77aa3864869a3893eb (patch) | |
| tree | 97a543508a8aeb45646d059f8cdd561ae0a76ef2 /include/linux/spi | |
| parent | b5f3294f0be5496aec01e5aa709a5fab8bb2f225 (diff) | |
spi: add support for device table matching
With this patch spi drivers can use standard spi_driver.id_table and
MODULE_DEVICE_TABLE() mechanisms to bind against the devices. Just like
we do with I2C drivers.
This is useful when a single driver supports several variants of devices
but it is not possible to detect them in run-time (like non-JEDEC chips
probing in drivers/mtd/devices/m25p80.c), and when platform_data usage is
overkill.
This patch also makes life a lot easier on OpenFirmware platforms, since
with OF we extensively use proper device IDs in modaliases.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/spi')
| -rw-r--r-- | include/linux/spi/spi.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h index eb25cedb995b..e2051f39f6a8 100644 --- a/include/linux/spi/spi.h +++ b/include/linux/spi/spi.h | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #define __LINUX_SPI_H | 20 | #define __LINUX_SPI_H |
| 21 | 21 | ||
| 22 | #include <linux/device.h> | 22 | #include <linux/device.h> |
| 23 | #include <linux/mod_devicetable.h> | ||
| 23 | 24 | ||
| 24 | /* | 25 | /* |
| 25 | * INTERFACES between SPI master-side drivers and SPI infrastructure. | 26 | * INTERFACES between SPI master-side drivers and SPI infrastructure. |
| @@ -86,7 +87,7 @@ struct spi_device { | |||
| 86 | int irq; | 87 | int irq; |
| 87 | void *controller_state; | 88 | void *controller_state; |
| 88 | void *controller_data; | 89 | void *controller_data; |
| 89 | char modalias[32]; | 90 | char modalias[SPI_NAME_SIZE]; |
| 90 | 91 | ||
| 91 | /* | 92 | /* |
| 92 | * likely need more hooks for more protocol options affecting how | 93 | * likely need more hooks for more protocol options affecting how |
| @@ -145,6 +146,7 @@ struct spi_message; | |||
| 145 | 146 | ||
| 146 | /** | 147 | /** |
| 147 | * struct spi_driver - Host side "protocol" driver | 148 | * struct spi_driver - Host side "protocol" driver |
| 149 | * @id_table: List of SPI devices supported by this driver | ||
| 148 | * @probe: Binds this driver to the spi device. Drivers can verify | 150 | * @probe: Binds this driver to the spi device. Drivers can verify |
| 149 | * that the device is actually present, and may need to configure | 151 | * that the device is actually present, and may need to configure |
| 150 | * characteristics (such as bits_per_word) which weren't needed for | 152 | * characteristics (such as bits_per_word) which weren't needed for |
| @@ -170,6 +172,7 @@ struct spi_message; | |||
| 170 | * MMC, RTC, filesystem character device nodes, and hardware monitoring. | 172 | * MMC, RTC, filesystem character device nodes, and hardware monitoring. |
| 171 | */ | 173 | */ |
| 172 | struct spi_driver { | 174 | struct spi_driver { |
| 175 | const struct spi_device_id *id_table; | ||
| 173 | int (*probe)(struct spi_device *spi); | 176 | int (*probe)(struct spi_device *spi); |
| 174 | int (*remove)(struct spi_device *spi); | 177 | int (*remove)(struct spi_device *spi); |
| 175 | void (*shutdown)(struct spi_device *spi); | 178 | void (*shutdown)(struct spi_device *spi); |
| @@ -734,7 +737,7 @@ struct spi_board_info { | |||
| 734 | * controller_data goes to spi_device.controller_data, | 737 | * controller_data goes to spi_device.controller_data, |
| 735 | * irq is copied too | 738 | * irq is copied too |
| 736 | */ | 739 | */ |
| 737 | char modalias[32]; | 740 | char modalias[SPI_NAME_SIZE]; |
| 738 | const void *platform_data; | 741 | const void *platform_data; |
| 739 | void *controller_data; | 742 | void *controller_data; |
| 740 | int irq; | 743 | int irq; |
| @@ -802,4 +805,7 @@ spi_unregister_device(struct spi_device *spi) | |||
| 802 | device_unregister(&spi->dev); | 805 | device_unregister(&spi->dev); |
| 803 | } | 806 | } |
| 804 | 807 | ||
| 808 | extern const struct spi_device_id * | ||
| 809 | spi_get_device_id(const struct spi_device *sdev); | ||
| 810 | |||
| 805 | #endif /* __LINUX_SPI_H */ | 811 | #endif /* __LINUX_SPI_H */ |
