STRUCT IIO_ENUM(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 NAME 🌸

okay so bestie, welcome to struct iio_enum(9) from the Kernel API Manual ✨ β€” this is the Enum channel info attribute, and it's lowkey iconic. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the whole struct, no cap:

struct iio_enum {
    const char * const *items;
    unsigned int num_items;
    int (*set)(struct iio_dev *, const struct iio_chan_spec *, unsigned int);
    int (*get)(struct iio_dev *, const struct iio_chan_spec *);
};

πŸŽ€ Members πŸŽ€

  • items β€” An array of strings. literally the string menu, iykyk πŸ“
  • num_items β€” Length of the item array. the count, bestie ✨
  • set β€” Set callback function, may be NULL. optional but important 🫢
  • get β€” Get callback function, may be NULL. also optional, also important πŸ’–

πŸ’– Description πŸ’–

okay so the tea: the iio_enum struct can be used to implement enum style channel attributes. Enum style attributes are those which have a set of strings which map to unsigned integer values. slay 🌈

The IIO enum helper code takes care of mapping between value and string as well as generating a _available file which contains a list of all available items. the helper is doing the absolute most so you don't have to πŸ‘‘

The set callback will be called when the attribute is updated. The last parameter is the index to the newly activated item. The get callback will be used to query the currently active item and is supposed to return the index for it. periodt. πŸ’…


πŸ”₯ SEE ALSO πŸ”₯

the kernel file is ./include/linux/iio/iio.h, and then the whole squad: 🫢

xoxo, your kernel bestie πŸ’– β€” source/version is ./include/linux/iio, dated October 2026. πŸŽ€

πŸ“¦ where this page comes from