BUS_READ_IVAR(9)

πŸ’– BUS_READ_IVAR β€” bestie edition πŸ’–

okay so. welcome to BUS_READ_IVAR(9), which lives in the Kernel Developer's Manual and is genuinely the most "let me peek at your vibes" pair of functions you'll ever meet. ✨


🌸 NAME 🌸

BUS_READ_IVAR, BUS_WRITE_IVAR β€” manipulate bus-specific device instance variables

like. the name is literally the whole personality. we're reading and writing instance variables that belong to a bus. no cap. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

first you gotta bring the headers, bestie, they're not optional:

#include <sys/param.h>
#include <sys/bus.h>

and then, the icons themselves:

int
BUS_READ_IVAR(device_t dev, device_t child, int index,
    uintptr_t *result);

int
BUS_WRITE_IVAR(device_t dev, device_t child, int index,
    uintptr_t value);

look at them. so clean. so structured. main character energy fr fr. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea. β˜•

These two methods manage a bus-specific set of instance variables belonging to a child device. The whole intention here is that each different type of bus defines its own set of appropriate instance variables β€” think ports and irqs for the ISA bus, etc. Every bus gets to curate its own little collection. it's giving personalised. 🌈

and like, why not just hand the child device a struct and call it a day? great question, bestie. because doing that makes it hard for a bus to add or remove variables without forcing every single driver to be edited and recompiled. and that might not even be possible for vendor supplied binary drivers. 😭

so instead of that chaos: instance variables. flexible. iconic. able to grow without dragging the whole codebase into a recompile situation. we love a design decision that respects everyone's time. 🫢


⭐ RETURN VALUES ⭐

Zero is returned on success. otherwise, an appropriate error is returned. that's it, that's the whole vibe check β€” 0 = slay, anything else = read the error and cope. πŸ’€


🌟 SEE ALSO 🌟

go read those too, you'll be obsessed. iykyk. πŸ“š


πŸ’œ AUTHORS πŸ’œ

This manual page was written by Doug Rabson. thank you for your service, king. πŸŽ€


lowkey reminder bestie: every option, every argument, every return value here is exactly as written. no improvising in kernel land. periodt. πŸ’…

Debian β€’ June 16, 1998 β€’ that's the source, the date, and the whole BUS_READ_IVAR(9) moment β€” mwah, take care of your ivars and they'll take care of you πŸ’–βœ¨

πŸ“¦ where this page comes from