STRUCT IIO_BUFFER_ACCESS_FUNCS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct iio_buffer_access_funcs β€” access functions for buffers ✨

okay bestie, so this is a page from the Kernel API Manual (section 9, kernel API vibes), and it's all about struct iio_buffer_access_funcs πŸ¦‹ β€” literally the little bundle of function pointers that tells the IIO core how to talk to a buffer. it's giving "plugin interface but make it kernel" πŸ’…


🌸 SYNOPSIS 🌸

bestie. look at this beast. this is the whole struct, character for character, no cap:

struct iio_buffer_access_funcs {
    int (*store_to)(struct iio_buffer *buffer, const void *data);
    int (*read)(struct iio_buffer *buffer, size_t n, char __user *buf);
    size_t (*data_available)(struct iio_buffer *buffer);
    int (*remove_from)(struct iio_buffer *buffer, void *data);
    int (*write)(struct iio_buffer *buffer, size_t n, const char __user
*buf);
    size_t (*space_available)(struct iio_buffer *buffer);
    int (*request_update)(struct iio_buffer *buffer);
    int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
    int (*set_length)(struct iio_buffer *buffer, unsigned int length);
    int (*enable)(struct iio_buffer *buffer, struct iio_dev *indio_dev);
    int (*disable)(struct iio_buffer *buffer, struct iio_dev
*indio_dev);
    void (*release)(struct iio_buffer *buffer);
    struct iio_dma_buffer_block * (*attach_dmabuf)(struct iio_buffer
*buffer, struct dma_buf_attachment *attach);
    void (*detach_dmabuf)(struct iio_buffer *buffer, struct
iio_dma_buffer_block *block);
    int (*enqueue_dmabuf)(struct iio_buffer *buffer, struct
iio_dma_buffer_block *block, struct dma_fence *fence, struct sg_table
*sgt, size_t size, bool cyclic);
    struct device * (*get_dma_dev)(struct iio_buffer *buffer);
    void (*lock_queue)(struct iio_buffer *buffer);
    void (*unlock_queue)(struct iio_buffer *buffer);
    unsigned int modes;
    unsigned int flags;
 };

like… twenty members. she's thorough. periodt. πŸ‘‘


πŸŽ€ Members πŸŽ€

time to meet the cast, one icon at a time πŸ‘‡

  • store_to β€” actually store stuff to the buffer. and listen: it must be safe to call from any context (e.g. must not sleep). that's not a suggestion, that's the whole assignment. 😴🚫
  • read β€” try to get a specified number of bytes (must exist). no phantom bytes, bestie.
  • data_available β€” indicates how much data is available for reading from the buffer. the little "how full is it" check 🌊
  • remove_from β€” remove scan from buffer. Drivers should call this to remove a scan from a buffer. (yes, the original said "Drivers should calls this" β€” we're conveying the info, not the typo πŸ’€)
  • write β€” try to write a number of bytes ✍️
  • space_available β€” returns the amount of bytes available in a buffer. cute little capacity check 🫢
  • request_update β€” if a parameter change has been marked, update underlying storage. it's the "you changed something, now make it real" hook ✨
  • set_bytes_per_datum β€” set number of bytes per datum πŸ“
  • set_length β€” set number of datums in buffer. length, but for datums. iykyk.
  • enable β€” called if the buffer is attached to a device and the device starts sampling. Calls are balanced with disable. (keep the books balanced, bestie βš–οΈ)
  • disable β€” called if the buffer is attached to a device and the device stops sampling. Calls are balanced with enable. the matching pair to the one above 🀝
  • release β€” called when the last reference to the buffer is dropped, should free all resources allocated by the buffer. last one out frees everything πŸ”₯
  • attach_dmabuf β€” called from userspace via ioctl to attach one external DMABUF 🧚
  • detach_dmabuf β€” called from userspace via ioctl to detach one previously attached DMABUF. the breakup arc πŸ’”
  • enqueue_dmabuf β€” called from userspace via ioctl to queue this DMABUF object to this buffer. Requires a valid DMABUF fd, that was previously attached to this buffer. so like, attach first. no skipping steps πŸ™ˆ
  • get_dma_dev β€” called to get the DMA channel associated with this buffer πŸ“‘
  • lock_queue β€” called when the core needs to lock the buffer queue; it is used when enqueueing DMABUF objects πŸ”’
  • unlock_queue β€” used to unlock a previously locked buffer queue πŸ”“
  • modes β€” Supported operating modes by this buffer type πŸŽ›οΈ
  • flags β€” A bitmask combination of INDIO_BUFFER_FLAG_* 🚩

πŸ’œ Description πŸ’œ

The purpose of this structure is to make the buffer element modular, as even for a given driver, different usecases may require different buffer designs (space efficiency vs speed for example). so the same driver can swap in whatever buffer flavour fits the moment β€” sometimes you want small, sometimes you want fast 🌈

It is worth noting that a given buffer implementation may only support a small proportion of these functions. and that is entirely fine β€” the core code 'should' cope fine with any of them not existing. (note the quotes around 'should'. they're load-bearing, bestie 😭)

none of these pointers are mandatory, but the ones that are implemented come with real rules attached β€” especially store_to, which has to be callable from any context and must not sleep. take that seriously fr fr.

πŸ”₯ SEE ALSO πŸ”₯


and that's the page, bestie 🫢 this one came out of ./include/linux/iio, dated October 2026, same charming header and footer as ever (struct iio_b...access_funcs(9) wrapped her name around the top and bottom, we just folded it in so it looks cuter) βœ¨πŸ’– go forth and modularise ur buffers. mwah πŸ’…

πŸ“¦ where this page comes from