STRUCT IIO_BUFFER_ACCESS_FUNCS(9)
β¨ 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 withdisable. (keep the books balanced, bestie βοΈ)disableβ called if the buffer is attached to a device and the device stops sampling. Calls are balanced withenable. 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 viaioctlto attach one external DMABUF π§detach_dmabufβ called from userspace viaioctlto detach one previously attached DMABUF. the breakup arc πenqueue_dmabufβ called from userspace viaioctlto 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 ofINDIO_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 π₯
- Kernel file
./include/linux/iio/buffer_impl.hπ INDIO_BUFFER_FLAG_FIXED_WATERMARK(9)struct iio_buffer(9)iio_update_buffers(9)iio_buffer_init(9)
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
- 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