spi_async(9)
π NAME π
spi_async β asynchronous SPI transfer, bestie β¨ like you send it off and you do not sit there waiting, no cap
π¦ SYNOPSIS π¦
int spi_async (struct spi_device *spi , struct spi_message *message );
πΈ ARGUMENTS πΈ
spiβ the device you're exchanging data with π«messageβ describes all the data transfers, and it's also carrying the completion callback, so it's kind of doing two jobs and honestly? main character energy
π CONTEXT π
any β and they mean any, as in (IRQs may be blocked, etc). literally any context, she's flexible like that π§
β¨ DESCRIPTION β¨
okay so this call can be used in in_irq and other contexts which can't sleep, and also from task contexts which can sleep. both. she contains multitudes π
the completion callback gets invoked in a context which can't sleep. and before that invocation? the value of message->status is undefined π so don't go peeking at it early, bestie. when the callback is issued, message->status holds either zero (which means complete success, slay) or a negative error code. and once that callback returns, the driver that issued the transfer request may deallocate the associated memory β it's no longer in use by any SPI core or controller driver code. so clean it up, it's done, periodt π«Ά
now, note this fr fr: although all messages to a spi_device are handled in FIFO order, messages may go to different devices in other orders. some device might be higher priority, or have various "hard" access time requirements, for example. iykyk β
on detection of any fault during the transfer, processing of the entire message is aborted, and the device is deselected. until returning from the associated message completion callback, no other spi_message queued to that device will be processed. and this rule applies equally to all the synchronous transfer calls, which are literally just wrappers around this core asynchronous primitive. she's the blueprint π
π₯ RETURN π₯
zero on success, else a negative error code. simple. iconic. π
π SEE ALSO π
kernel file ./drivers/spi/spi.c and honestly the whole extended 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)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_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, bestie β go forth and transfer asynchronously, you got this fr fr π
this lil beauty is living in the Kernel API Manual π¦ sourced from ./drivers/spi π dated October 2026 π and yeah, the page itself is spi_async(9) β 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