spi_bus_lock(9)
π spi_bus_lock(9) β the Kernel API Manual glow-up
okay so bestie, welcome to spi_bus_lock β the function that says "this SPI bus is mine" and means it. Sit down, we're gonna talk about exclusive access π
β¨ NAME β¨
spi_bus_lock β obtain a lock for exclusive SPI bus usage. periodt, that's the whole vibe π₯
πΈ SYNOPSIS πΈ
int spi_bus_lock (struct spi_controller *ctlr );
π¦ ARGUMENTS π¦
ctlrβ the SPI bus controller that should be locked for exclusive bus access. like, the whole bus. not sharing, not "just for a sec", exclusive π
π§ CONTEXT π§
can sleep π΄
that's it, that's the context line. she naps.
π DESCRIPTION π
okay so here's the tea β β this call may only be used from a context that may sleep. the sleep is non-interruptible, and has no timeout. so if you're lying to yourself about what context you're in... bestie, no. π
this call should be used by drivers that require exclusive access to the SPI bus. no cap, that's the whole point of her.
the SPI bus must be released by a spi_bus_unlock call when the exclusive access is over β do not just walk away and ghost the bus, that's not the move π
and while the SPI bus lock is held, data transfer must be done by spi_sync_locked and spi_async_locked calls. like, those two specifically. not the regular ones. iykyk π
β RETURN β
always zero. every time. she is consistent, she is unbothered, she is iconic π
π SEE ALSO π
the full extended universe, fr fr β kernel file ./drivers/spi/spi.c plus these legends:
__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)spi_register_controller(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_unlock(9)spi_write_then_read(9)
π«Ά and that's the page!! this lil gem lives in ./drivers/spi and the version on deck is October 2026 β so go forth, lock that bus, unlock it when you're done, and slay π
β¨π
π¦ 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