spi_register_controller(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… spi_register_controller(9)

okay so bestie, welcome to the kernel API manual, this one's spi_register_controller(9) and it's literally the moment your SPI controller becomes ✨real✨.


🌸 NAME 🌸

spi_register_controller β€” register SPI host or target controller

like, you built the thing, now introduce it to the bus 🫢


✨ SYNOPSIS ✨

int spi_register_controller (struct spi_controller *ctlr );

πŸŽ€ ARGUMENTS πŸŽ€

  • ctlr β€” the initialized controller. and when we say initialized we mean it β€” it originally came from spi_alloc_host or spi_alloc_target, no cap. don't just roll up with a random struct, it will not slay πŸ’€

πŸ¦‹ CONTEXT πŸ¦‹

can sleep 😴

(translation: you're allowed to block in here, it's not one of Those functions)


πŸ’– DESCRIPTION πŸ’–

SPI controllers don't just spawn into the SPI bus out of nowhere β€” they connect to their drivers using some other non-SPI bus, like the platform bus. so the final stage of probe in that code is where you call spi_register_controller, and that's what hooks you up to the SPI bus glue. iconic behavior honestly.

SPI controllers use board specific (often SOC specific) bus numbers, and board-specific addressing for SPI devices combines those numbers with chip select numbers. the way SPI works, it does not directly support dynamic device identification β€” so boards need configuration tables telling which chip is at which address. yes, an actual table. a whole little seating chart for your chips πŸͺ‘βœ¨

This must be called from context that can sleep. fr fr, don't try this in atomic context.

⭐ after a successful return, the caller is responsible for calling spi_unregister_controller. that's you, bestie. it's your job now. don't ghost it πŸ™ˆ

πŸ”₯ RETURN πŸ”₯

zero on success πŸŽ‰ else a negative error code 😭


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./drivers/spi/spi.c and its whole friend group:


🌈 and that's the whole page!! this little manual page lives in ./drivers/spi and it's dated October 2026 β€” so yeah, she's from the future, we stan a time traveler πŸ’œπŸŽ€βœ¨
πŸ“¦ where this page comes from