STRUCT COMEDI_BUF_MAP(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct comedi_buf_map(9) ✨

okay so bestie, welcome to the Kernel API Manual πŸ’… today we're looking at struct comedi_buf_map(9) β€” literally the little struct that's like "hey, lemme describe the pages in a COMEDI buffer" 🫢


🌸 NAME 🌸

struct comedi_buf_map β€” Describe pages in a COMEDI buffer


πŸŽ€ SYNOPSIS πŸŽ€

struct comedi_buf_map {
    struct device *dma_hw_dev;
    struct comedi_buf_page *page_list;
    unsigned int n_pages;
    enum dma_data_direction dma_dir;
    struct kref refcount;
 };

πŸ’– Members πŸ’–

  • dma_hw_dev β€” a low-level hardware struct device pointer, and it's literally copied straight from the COMEDI device's hw_dev member. no cap, it's a copy 🧚
  • page_list β€” pointer to an array of struct comedi_buf_page, one for each page in the buffer. one page, one entry, iconic behaviour ⭐
  • n_pages β€” the number of pages in the buffer. that's the count, periodt πŸ”₯
  • dma_dir β€” the DMA direction used to allocate pages of DMA coherent memory, or DMA_NONE if the pages were allocated from regular memory πŸ‘‘
  • refcount β€” a struct kref reference counter used to free the buffer. this is the little guardian angel of cleanup 😭

πŸ¦‹ Description πŸ¦‹

A COMEDI data buffer is allocated as individual pages, either in conventional memory or DMA coherent memory, depending on the attached, low-level hardware device. it's giving "pages, not one big blob" energy πŸ’œ

The buffer is normally freed when the COMEDI device is detached from the low-level driver (which may happen due to device removal), but if it happens to be mmapped at the time, the pages cannot be freed until the buffer has been munmapped. that is what the reference counter is for β€” not me explaining lifetime management in a group chat πŸ˜­πŸ’€

fr fr, that refcount is the whole plot twist: it's what lets the pages stick around until nobody's mmapping them anymore.

🌈 SEE ALSO 🌈

Kernel file ./include/linux/comedi/comedidev.h struct comedi_subdevice(9), struct comedi_buf_page(9), struct comedi_async(9), enum comedi_cb(9), struct comedi_driver(9), struct comedi_device(9), struct comedi_lrange(9), comedi_range_is_bipolar(9), comedi_range_is_unipolar(9), comedi_range_is_external(9), comedi_chan_range_is_bipolar(9), comedi_chan_range_is_unipolar(9), comedi_chan_range_is_external(9), comedi_offset_munge(9), comedi_bytes_per_sample(9), comedi_sample_shift(9), comedi_bytes_to_samples(9), comedi_samples_to_bytes(9), comedi_check_trigger_src(9), comedi_check_trigger_is_unique(9), comedi_check_trigger_arg_is(9), comedi_check_trigger_arg_min(9), comedi_check_trigger_arg_max(9), comedi_buf_n_bytes_ready(9), __comedi_request_region(9), comedi_request_region(9), module_comedi_driver(9) πŸ’…βœ¨


and that's the whole page, bestie πŸŽ€ this one's from the Kernel file ./include/linux/comedi, dated October 2026, and the title is struct comedi_buf_map(9). go read the source, ily, bye πŸ’–πŸ‘‘

πŸ“¦ where this page comes from