spi_register_controller(9)
π 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 fromspi_alloc_hostorspi_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:
__spi_register_driver(9)spi_alloc_device(9)spi_add_device(9)spi_new_device(9)spi_unregister_device(9)spi_register_board_info(9)spi_res_alloc(9)spi_res_free(9)spi_res_add(9)spi_res_release(9)spi_finalize_current_transfer(9)__spi_pump_messages(9)spi_pump_messages(9)spi_take_timestamp_pre(9)spi_take_timestamp_post(9)spi_set_thread_rt(9)spi_get_next_queued_message(9)spi_finalize_current_message(9)spi_queued_transfer(9)spi_flush_queue(9)of_register_spi_devices(9)spi_new_ancillary_device(9)devm_spi_new_ancillary_device(9)acpi_spi_count_resources(9)acpi_spi_device_alloc(9)spi_target_abort(9)__spi_alloc_controller(9)__devm_spi_alloc_controller(9)spi_get_gpio_descs(9)devm_spi_register_controller(9)spi_unregister_controller(9)spi_replace_transfers(9)spi_split_transfers_maxsize(9)spi_split_transfers_maxwords(9)spi_set_cs_timing(9)spi_setup(9)spi_optimize_message(9)spi_unoptimize_message(9)devm_spi_optimize_message(9)spi_async(9)spi_sync(9)spi_sync_locked(9)spi_bus_lock(9)spi_bus_unlock(9)spi_write_then_read(9)
π 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
- 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