IOSYS_MAP_INIT_OFFSET(9)
π IOSYS_MAP_INIT_OFFSET π
bestie this one's straight out of the Kernel API Manual and it is so useful β it's the macro that gives your iosys_map a whole new vibe without losing its roots β¨
π NAME π
IOSYS_MAP_INIT_OFFSET β Initializes struct iosys_map from another iosys_map. that's it, that's the tweet π
π¦ SYNOPSIS π¦
IOSYS_MAP_INIT_OFFSET (map_ , offset_ );
πΈ ARGUMENTS πΈ
map_β The dma-buf mapping structure to copy from. this is the source map, the one you're building off of, the blueprint πoffset_β Offset to add to the other mapping. the little nudge forward, yk? the "scoot over" of it all π«Ά
π DESCRIPTION π
okay so here's the tea: this macro initializes a new iosys_map struct based on another passed as argument. it does a shallow copy of the struct, which is iconic because it means it's possible to update the back storage without changing where the original map points to. periodt π
it's literally the equivalent of doing:
iosys_map map = other_map;
iosys_map_incr(map, offset);
Example usage, bestie:
void foo(struct device *dev, struct iosys_map *base_map)
{
...
struct iosys_map map = IOSYS_MAP_INIT_OFFSET(base_map, FIELD_OFFSET);
...
}
The advantage of using the initializer over just increasing the offset with iosys_map_incr like above is that the new map will always point to the right place of the buffer during its scope. it's giving safety, it's giving main character energy π«Ά It reduces the risk of updating the wrong part of the buffer and having no compiler warning about that. and like, if the assignment to IOSYS_MAP_INIT_OFFSET is forgotten, the compiler can warn about the use of uninitialized variable. chefs kiss π
π SEE ALSO π
- Kernel file
./include/linux/iosys-map.hoverview(9) struct iosys_map(9)IOSYS_MAP_INIT_VADDR(9)IOSYS_MAP_INIT_VADDR_IOMEM(9)iosys_map_set_vaddr(9)iosys_map_set_vaddr_iomem(9)iosys_map_is_equal(9)iosys_map_is_null(9)iosys_map_is_set(9)iosys_map_clear(9)iosys_map_memcpy_to(9)iosys_map_memcpy_from(9)iosys_map_incr(9)iosys_map_memset(9)iosys_map_rd(9)iosys_map_wr(9)iosys_map_rd_field(9)iosys_map_wr_field(9)
and that's the whole page, bestie! brought to you by ./include/linux, dated October 2026, IOSYS_MAP_INIT_OFFSET(9) in the Kernel API Manual πβ¨ now go slay those buffer offsets ππ
π¦ 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