STRUCT IIO_CHAN_SPEC(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ struct iio_chan_spec(9) ✨

okay bestie, so this is the Kernel API Manual entry for struct iio_chan_spec and it's literally the blueprint for one single IIO channel β€” like, the whole personality of a channel lives in this struct πŸ’…


🌸 NAME 🌸

struct iio_chan_spec β€” specification of a single channel


πŸ¦‹ SYNOPSIS πŸ¦‹

struct iio_chan_spec {
    enum iio_chan_type      type;
    int channel;
    int channel2;
    unsigned long           address;
    int scan_index;
    union {
      struct iio_scan_type scan_type;
      struct {
        const struct iio_scan_type *ext_scan_type;
        unsigned int num_ext_scan_type;
      };
    };
    unsigned long                   info_mask_separate;
    unsigned long                   info_mask_separate_available;
    unsigned long                   info_mask_shared_by_type;
    unsigned long                   info_mask_shared_by_type_available;
    unsigned long                   info_mask_shared_by_dir;
    unsigned long                   info_mask_shared_by_dir_available;
    unsigned long                   info_mask_shared_by_all;
    unsigned long                   info_mask_shared_by_all_available;
    const struct iio_event_spec *event_spec;
    unsigned int            num_event_specs;
    const struct iio_chan_spec_ext_info *ext_info;
    const char              *extend_name;
    const char              *datasheet_name;
    unsigned int            modified:1;
    unsigned int            indexed:1;
    unsigned int            output:1;
    unsigned int            differential:1;
    unsigned int            has_ext_scan_type:1;
 };

πŸ‘‘ Members πŸ‘‘

ok so let's go field by field, no skips, we're doing the whole thing 🫢

  • type β€” tells you what kind of measurement this channel is doing. the whole vibe check of the channel basically 🌈
  • channel β€” the number we wanna assign to this channel, like its little name tag πŸ’–
  • channel2 β€” if a differential channel has a second number, this is where it goes. and if modified is set, the value in here is the modifier, iykyk ✨
  • address β€” a driver-specific identifier. lowkey just a lil fingerprint for the driver πŸŽ€
  • scan_index β€” a monotonic index that gives ordering in scans when you're reading from a buffer. it's giving "line order but make it silicon" πŸ’€
  • {unnamed_union} β€” anonymous. no name, all mystery πŸ™ˆ
  • scan_type β€” a struct describing the scan type β€” and heads up bestie, this is mutually exclusive with ext_scan_type ⚠️
  • {unnamed_struct} β€” anonymous. again. mysterious icon behavior 🧚
  • ext_scan_type β€” used in the rare cases where there's more than one scan format for a channel. when you use this, the has_ext_scan_type flag must be set, and the driver must implement get_current_scan_type in struct iio_info. no cap, both requirements fr fr πŸ”₯
  • num_ext_scan_type β€” number of elements in ext_scan_type
  • info_mask_separate β€” what information gets exported that's specific to this channel πŸ’…
  • info_mask_separate_available β€” what availability information gets exported that's specific to this channel
  • info_mask_shared_by_type β€” what information gets exported that's shared by all channels of the same type
  • info_mask_shared_by_type_available β€” what availability information gets exported that's shared by all channels of the same type
  • info_mask_shared_by_dir β€” what information gets exported that's shared by all channels of the same direction
  • info_mask_shared_by_dir_available β€” what availability information gets exported that's shared by all channels of the same direction
  • info_mask_shared_by_all β€” what information gets exported that's shared by all channels, periodt πŸ‘‘
  • info_mask_shared_by_all_available β€” what availability information gets exported that's shared by all channels
  • event_spec β€” array of events that should be registered for this channel πŸŽ€
  • num_event_specs β€” size of the event_spec array
  • ext_info β€” array of extended info attributes for this channel. the array is NULL terminated, so the last element should have its name field set to NULL β€” don't forget or it's gonna be a whole situation 😭
  • extend_name β€” lets you label channel attributes with an informative name. note this has no effect on codes etc, unlike modifiers. this field is deprecated in favour of providing iio_info->read_label to override the label β€” which, unlike extend_name, does not affect sysfs filenames. so yeah, it's giving "old but still here" πŸ’€
  • datasheet_name β€” a name used in in-kernel mapping of channels. it should correspond to the first name the channel is referred to by in the datasheet (e.g. IND), or the nearest possible compound name (e.g. IND-INC). literally just match the datasheet bestie πŸ“„
  • modified β€” does a modifier apply to this channel? what those are depends on the channel type. the modifier is set in channel2. examples are IIO_MOD_X for axial sensors about the 'x' axis πŸ’«
  • indexed β€” specifies the channel has a numerical index. if not, the channel index number will be suppressed for sysfs attributes β€” but not for event codes 🫢
  • output β€” channel is output
  • differential β€” channel is differential
  • has_ext_scan_type β€” true if ext_scan_type is used instead of scan_type βœ…

πŸŽ€ SEE ALSO πŸŽ€

you might also vibe with these icons ✨

Kernel file ./include/linux/iio/iio.h struct iio_chan_spec_ext_info(9), struct iio_enum(9), IIO_ENUM(9), IIO_ENUM_AVAILABLE(9), struct iio_mount_matrix(9), IIO_MOUNT_MATRIX(9), struct iio_event_spec(9), IIO_SCAN_FORMAT_SIGNED_INT(9), IIO_SCAN_FORMAT_UNSIGNED_INT(9), IIO_SCAN_FORMAT_FLOAT(9), struct iio_scan_type(9), iio_channel_has_info(9), iio_channel_has_available(9), struct iio_info(9), struct iio_buffer_setup_ops(9), struct iio_dev(9), iio_device_register(9), devm_iio_device_register(9), iio_device_claim_direct(9), iio_device_release_direct(9), iio_device_try_claim_buffer_mode(9), iio_device_release_buffer_mode(9), IIO_DEV_ACQUIRE_DIRECT_MODE(9), IIO_DEV_ACQUIRE_FAILED(9), IIO_DEV_GUARD_CURRENT_MODE(9), iio_device_put(9), dev_to_iio_dev(9), iio_device_get(9), iio_device_set_parent(9), iio_device_set_drvdata(9), iio_device_get_drvdata(9), IIO_DECLARE_BUFFER_WITH_TS(9), IIO_DECLARE_DMA_BUFFER_WITH_TS(9), IIO_DECLARE_QUATERNION(9), iio_get_debugfs_dentry(9), iio_device_suspend_triggering(9), iio_device_resume_triggering(9), iio_get_current_scan_type(9), iio_get_masklength(9), iio_for_each_active_channel(9), IIO_DEGREE_TO_RAD(9), IIO_RAD_TO_DEGREE(9), IIO_G_TO_M_S_2(9), IIO_M_S_2_TO_G(9)


and that's the whole thing bestie, slay πŸ’– this gem right here comes from the kernel API manual, sourced from ./include/linux/iio, dated October 2026 β€” so yeah, future iconic behavior, we love to see it 🌸✨

πŸ“¦ where this page comes from