spi_add_device(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ spi_add_device(9) ✨

okay so real talk, this is a page from the Kernel API Manual (spi_add_device(9)), and honestly it's giving "small function, big responsibilities" πŸ’…


🌸 NAME 🌸

spi_add_device β€” the bestie that adds an spi_device that you already allocated with spi_alloc_device


πŸŽ€ SYNOPSIS πŸŽ€

int spi_add_device (struct spi_device *spi );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • spi β€” the spi_device you want to register. like, the whole point of this function. no cap.

πŸ’– DESCRIPTION πŸ’–

So spi_add_device is the companion function to spi_alloc_device. Think of it as the second half of the glow-up: spi_alloc_device gets your device all dressed and ready, and then this one actually walks it out onto the SPI bus πŸ”₯

Devices that were allocated with spi_alloc_device can be added onto the SPI bus with this function. that's it, that's the job, and it does it slayfully.


✨ RETURN ✨

  • 0 on success πŸŽ‰ (iconic, we love to see it)
  • negative errno on failure 😭 (not iconic, but informative)

πŸ‘‘ SEE ALSO πŸ‘‘

Everything else living in the same universe β€” kernel file ./drivers/spi/spi.c, plus these absolute legends:

__spi_register_driver(9), spi_alloc_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_lock(9), spi_bus_unlock(9), spi_write_then_read(9)

like… a whole friend group fr fr 🫢


mwah, that's the page πŸ’œ this little gem lives over in ./drivers/spi and it's dated October 2026 β€” go forth and register your devices, bestie, you're gonna do amazing 🌈⭐

πŸ“¦ where this page comes from