i2c_get_dma_safe_msg_buf(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ i2c_get_dma_safe_msg_buf(9) πŸ¦‹

okay bestie, welcome to the Kernel API Manual ✨ this one's a lil function with a big job: i2c_get_dma_safe_msg_buf β€” the way it just gets you a DMA safe buffer for the given i2c_msg. iconic behavior honestly πŸ’…


🌸 NAME 🌸

i2c_get_dma_safe_msg_buf β€” grab a DMA safe buffer for the i2c_msg you handed it, no cap 🫢


✨ SYNOPSIS ✨

u8 * i2c_get_dma_safe_msg_buf (struct i2c_msg *msg , unsigned int
threshold );

that's the whole vibe, she takes two things and gives you back a u8 * πŸ’–


πŸŽ€ ARGUMENTS πŸŽ€

  • msg β€” the message that's getting checked, like the main character of this whole operation πŸ‘‘
  • threshold β€” the minimum number of bytes for which using DMA actually makes sense. and listen, it should at least be 1 β€” don't be out here passing 0, that's not the move πŸ™ˆ

⭐ RETURN ⭐

so here's the tea, there's two possible endings:

  • NULL β€” meaning no DMA safe buffer was obtained 😭 in that case you just use msg->buf with PIO, easy.
  • a valid pointer β€” this one's for using with DMA ✨ literally what you wanted.
🚨 and when you're done with that pointer? you release it by calling i2c_put_dma_safe_msg_buf. don't just leave it sitting there, that's not cute, that's a leak.

πŸ¦‹ DESCRIPTION πŸ¦‹

okay this is the important part, pay attention bestie πŸ‘€

This function must only be called from process context!

like, that's it, that's the whole rule. not interrupt context, not whatever wild place you were thinking of. process context only, periodt πŸ’€


🌈 SEE ALSO 🌈

the whole friend group, fr fr β€” kernel file ./drivers/i2c/i2c-core-base.c plus:

i2c_verify_client(9), i2c_adapter_lock_bus(9), i2c_adapter_trylock_bus(9), i2c_adapter_unlock_bus(9), i2c_new_client_device(9), i2c_unregister_device(9), i2c_find_device_by_fwnode(9), i2c_new_dummy_device(9), devm_i2c_new_dummy_device(9), i2c_new_ancillary_device(9), i2c_verify_adapter(9), i2c_handle_smbus_host_notify(9), i2c_add_adapter(9), i2c_add_numbered_adapter(9), i2c_del_adapter(9), devm_i2c_add_adapter(9), i2c_find_adapter_by_fwnode(9), i2c_get_adapter_by_fwnode(9), i2c_parse_fw_timings(9), i2c_del_driver(9), __i2c_transfer(9), i2c_transfer(9), i2c_transfer_buffer_flags(9), i2c_get_device_id(9), i2c_client_get_device_id(9), i2c_put_dma_safe_msg_buf(9)


and that's the page babes πŸŽ€ this lil masterpiece lives over in ./drivers/i2c, stamped October 2026 β€” go forth and DMA responsibly πŸ’œπŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from