spi_new_device(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ spi_new_device(9) ✨

okay so this is a page from the Kernel API Manual β€” the spi_new_device one, bestie. it's a kernel function, it lives in ./drivers/spi, and it's about to make a whole new SPI device appear out of thin air (well, out of structs). let's get into it πŸ’…


🌸 NAME 🌸

spi_new_device β€” instantiate one new SPI device

like, literally, it births a single SPI device. one. singular. iconic behavior.


πŸ¦‹ SYNOPSIS πŸ¦‹

struct spi_device * spi_new_device (struct spi_controller *ctlr , struct
spi_board_info *chip );

so you hand it a controller and a board info struct, and it hands you back a struct spi_device *. the whole vibe in one line, no cap 🫢


πŸŽ€ ARGUMENTS πŸŽ€

  • ctlr β€” the controller your device is connected to. that's the parent energy right there πŸ‘‘
  • chip β€” describes the SPI device itself. all the deets about what you're bringing into the world ✨

πŸ’œ CONTEXT πŸ’œ

can sleep 😴

yes bestie, this one is allowed to sleep. so don't be calling it from somewhere sleepy-frowned-upon, iykyk.


🌈 DESCRIPTION 🌈

so on your typical mainboards, this function is purely internal β€” and honestly? it's not needed after board init has already created the hard-wired devices. like, the work is done, go home 🏠

but here's the thing πŸ‘€ some development platforms may not be able to use spi_register_board_info, and that's exactly why this one is exported. so for example a USB or parport based adapter driver could add devices β€” ones it would learn about out-of-band 🎧

periodt. that's the whole reason it exists in the public API.


⭐ RETURN ⭐

the new device, or NULL.

that's it. that's the return value. either you get your shiny new device or you get NULL and you gotta deal 😭


🧚 SEE ALSO 🧚

the Kernel file ./drivers/spi/spi.c β€” and a truly legendary list of friends, all of them together, exactly like this:

that's the whole group chat right there, no one left on read πŸ’–


like and subscribe to ./drivers/spi for more, bestie πŸ“

and that's the page!! brought to you by the fine folks at ./drivers/spi, dated October 2026, and yeah β€” it's spi_new_device(9) all the way down. mwah πŸ’‹πŸ«Ά go instantiate something cute today 🌸

πŸ“¦ where this page comes from