STRUCT SPI_DRIVER(9)
β¨ struct spi_driver(9) β¨
okay so real talk β this is a page straight out of the Kernel API Manual, and it's literally the blueprint for struct spi_driver, aka the host side "protocol" driver. bestie, it's giving main character energy for every SPI protocol driver out there π
πΈ NAME πΈ
struct spi_driver β the host side "protocol" driver, no cap π«Ά
π¦ SYNOPSIS π¦
here's the whole struct, exactly as it lives, don't touch a character of it:
struct spi_driver {
const struct spi_device_id *id_table;
int (*probe)(struct spi_device *spi);
void (*remove)(struct spi_device *spi);
void (*shutdown)(struct spi_device *spi);
struct device_driver driver;
};
π Members π
okay so let's meet the cast, one field at a time π
id_tableβ the list of SPI devices this driver supports. it's literally the driver's "these are my people" list β¨probeβ this one binds the driver to the SPI device. here's the vibe: drivers can verify that the device is actually present, and they may need to configure characteristics (such asbits_per_word) which weren't needed for the initial configuration done during system setup. so yeah, probe is the "hi, are you really there? let me set you up properly" moment π«Άremoveβ unbinds this driver from the SPI device. breakup era, but make it kernel π₯²shutdownβ the standard shutdown callback, used during system state transitions such as powerdown/halt and kexec. it's the "okay bestie, time to go night-night" callback πdriverβ SPI device drivers should initialize thenameandownerfield of this structure. lowkey mandatory homework, don't skip it π
π Description π
so what is this thing? it represents the kind of device driver that uses SPI messages to interact with the hardware at the other end of a SPI link. the reason it's called a "protocol" driver is that it works through messages rather than talking directly to SPI hardware β and that direct-hardware job belongs to the underlying SPI controller driver, which is the one doing the work to pass those messages along. those protocols are defined in the specification for the device(s) supported by the driver. iykyk π₯
as a rule, those device protocols represent the lowest level interface supported by a driver, and it will support upper level interfaces too. examples of such upper levels include frameworks like MTD, networking, MMC, RTC, filesystem character device nodes, and hardware monitoring. so yeah β the protocol layer is the foundations, and everything above it is the cute penthouse β¨ποΈ
ngl this is one of those "small struct, huge responsibility" situations. respect it π
π SEE ALSO π
go read these next, bestie β they're all in the kernel file ./include/linux/spi/spi.h:
struct spi_statistics(9)struct spi_delay(9)struct spi_device(9)spi_unregister_driver(9)module_spi_driver(9)struct spi_controller(9)struct spi_res(9)struct spi_transfer(9)struct spi_message(9)spi_message_init_with_transfers(9)spi_is_bpw_supported(9)spi_bpw_to_bytes(9)spi_controller_xfer_timeout(9)struct spi_replaced_transfers(9)spi_sync_transfer(9)spi_write(9)spi_read(9)spi_w8r8(9)spi_w8r16(9)spi_w8r16be(9)struct spi_board_info(9)
and that's the whole page, bestie! π this one lives in ./include/linux/spi, dated October 2026, and it goes out under the struct spi_driver(9) glow-up. mwah πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms