Skip to content

devm_iio_device_register()

Purpose

Registers an IIO device with device-managed cleanup.

#include <linux/iio/iio.h>

Prototype

int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev);

Parameters

  • dev: parent device.
  • indio_dev: initialized IIO device object.

Return Value

  • 0 on success.
  • Negative errno on failure.

Minimal Example

indio_dev->name = "myadc";
indio_dev->info = &myadc_info;
indio_dev->channels = myadc_channels;
indio_dev->num_channels = ARRAY_SIZE(myadc_channels);
indio_dev->modes = INDIO_DIRECT_MODE;

return devm_iio_device_register(dev, indio_dev);

Common Pitfalls

  • Register triggered buffer support before registering the IIO device.
  • Make sure channel scan indexes are stable and unique.
  • Avoid exposing incomplete channel definitions.