STRUCT AD5761_STATE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct ad5761_state(9) πŸ’…

okay so this is a page straight out of the kernel API manual, and it's literally the blueprint for one driver instance's whole personality β€” its per-chip data bag. bestie, this struct is the main character of ad5761.c and it holds everything the driver needs to remember about the DAC it's currently babysitting. no cap.


✨ NAME ✨

struct ad5761_state β€” driver instance specific data πŸŽ€

like, it's the little state blob that says "this particular chip, right here, here's what's up with it." periodt.


🌸 SYNOPSIS 🌸

struct ad5761_state {
    struct spi_device               *spi;
    struct mutex                    lock;
    bool use_intref;
    int vref;
    enum ad5761_voltage_range range;
    union {
      __be32 d32;
      u8 d8[4];
    } data[3];
 };

look at her. iconic. she's got a pointer, a mutex, a couple of flags and numbers, a range enum, and a lil' union array of three. the vibes are immaculate πŸ’–


πŸ¦‹ Members πŸ¦‹

  • spi β€” a spi_device 🫢 literally the SPI device this whole state belongs to. the whole reason we're here.
  • lock β€” a struct mutex, and its whole job is to protect the data buffer during SPI ops πŸ”’ like, don't let two threads touch the buffer at the same time, that's not the vibe. it's giving safety.
  • use_intref β€” a bool, and it's true when the internal voltage reference is used ✨ (as in, yes we're using the chip's own reference, not an external one, tyvm).
  • vref β€” an int holding the actual voltage reference in mVolts ⚑ so like, the real number, in millivolts. remember the units, bestie, they matter.
  • range β€” an enum ad5761_voltage_range, aka the output range mode used πŸ“ it tells you which output range the thing is configured for.
  • data β€” the cache aligned spi buffer 🧚 that's the union { __be32 d32; u8 d8[4]; } data[3] up there β€” three of them, cache aligned, ready to be shoved down the SPI wire.

πŸ‘‘ SEE ALSO πŸ‘‘

  • Kernel file ./drivers/iio/dac/ad5761.c πŸ“„
  • struct ad5761_chip_info(9) πŸ’œ

⚠️ friendly reminder: lock exists for a reason β€” it protects the data buffer during SPI ops. don't be the one who skips it, i'm literally begging 😭

and that's the whole page, fr fr β€” sourced from ./drivers/iio/dac, dated October 2026, in the kernel API manual. mwah, stan this struct for clear skin πŸ’…πŸŒˆβ­

πŸ“¦ where this page comes from