This is an attempt to solve the problem of binding spidev to a device on a device-tree system. Explicitly listing spidev in the "compatible" property of a device is not allowed, as it not type of the device but rather a Linux specific driver name. The current solution is to list every possible device spidev can be bound to, but this is highly unsatisfactory. 1. Needing to patch and compile the kernel is a significant barrier to many who could otherwise make use of embedded dev kits, such as RPi, that have SPI hardware. 2. Up-streaming a new spi device ID is a lengthy undertaking even to those who know how. This causes unneeded delay in upstream kernel support for a new device. 3. Maintaining a list of obscure and one-off device IDs in the spidev driver is largely a waste of effort to nearly every developer to use the driver. 4. It's not possible to bind a device that has a kernel SPI driver to spidev instead of its normal driver. This is quite useful to debug hardware problems, development of the kernel driver, and testing SPI bus timing, impedance, etc. It can also be used to access device features, like a one time programming step, that the device's kernel driver does not necessary need to support. This approach should solve these problems. Three existing Linux busses - AMBA, PCI, and platform - give device's a "driver_override" attribute, which can be used to bind them to a driver without requiring a match against the driver's device ID table. This can be used to bind spidev to a device without needing to add the device to some list inside the spidev driver. Udev rules can be written to make this automatic, example: ACTION=="add|change",, SUBSYSTEM=="spi", ENV{MODALIAS}=="spi:adrf6820", ATTR{driver_override}+="spidev" This will automatically bind a device that claims (likely via device-tree compatible value) to be an "adrf6820" to spidev. Additional rules could be imagined to bind specific spi bus chip selects, or any device on a certain bus, or via the device's node name in the device tree, to spidev. Changes from v1: - Fix leak on device release with override set - Simplifly spidev warn logic and remove dev_err - Split automatic attach attempt into another commit Trent Piepho (3): spi: Add driver_override SPI device attribute spi: Automatically attempt attach after driver_override alteration spi: spidev: Fix OF tree warning logic drivers/spi/spi.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ drivers/spi/spidev.c | 8 +++---- include/linux/spi/spi.h | 1 + 3 files changed, 62 insertions(+), 5 deletions(-) -- 2.14.4