spi_sync(9)
π spi_sync(9) β the manual page, bestie edition
okay so this is a Kernel API Manual page for spi_sync, and honestly? it's a whole vibe. it's the "just do it synchronously and let me nap until it's done" SPI transfer call π¦
β¨ NAME β¨
spi_sync β blocking/synchronous SPI data transfers πΈ
like, you hand it a message, you wait, you get your answer. no callbacks, no chaos, no "we'll get back to you." periodt.
β¨ SYNOPSIS β¨
int spi_sync (struct spi_device *spi , struct spi_message *message );
β¨ ARGUMENTS β¨
spiβ the device you're exchanging data with π«Ά like, who are we talking tomessageβ describes the data transfers β the whole itinerary of the trip, basically
β¨ CONTEXT β¨
can sleep π΄
β¨ DESCRIPTION β¨
okay so the big rule: this call may only be used from a context that may sleep. and not like a cute little nap either β the sleep is non-interruptible, and it has no timeout. it's giving main character energy that refuses to be woken up early π
the good news? low-overhead controller drivers may DMA directly into and out of the message buffers. highkey efficient. π₯
also note π β the SPI device's chip select is active during the message, and then is normally disabled between messages. some drivers for frequently-used devices might wanna minimize the cost of selecting a chip by leaving it selected, anticipating that the next message goes to the same chip. (just know that may increase power usage π)
and one more thing, bestie, this is important: the caller is guaranteeing that the memory associated with the message will not be freed before this call returns. no cap. if you free it early, that's on you π
β¨ RETURN β¨
zero on success β¨ else a negative error code π
β¨ SEE ALSO β¨
kernel file ./drivers/spi/spi.c and the 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)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_locked(9)spi_bus_lock(9)spi_bus_unlock(9)spi_write_then_read(9)
ok that's the whole page, no details skipped, i promise π go forth and transfer synchronously, queen π
and that's a wrap! this one came from the ./drivers/spi directory, dated October 2026 β mwah, tysm for reading, ily, bye πβ¨π§
π¦ 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