3 This is not intended to provide a comprehensive guide to writing an
4 IIO device driver. For further information see the drivers within the
7 The crucial structure for device drivers in iio is iio_dev.
9 First allocate one using:
11 struct iio_dev *indio_dev = iio_allocate_device();
13 The fill in the following.
16 the struct device associated with the underlying hardware.
18 indio_dev->num_interrupt_lines
19 number of event triggering hardware lines the device has.
21 indio_dev->event_attrs
22 attributes used to enable / disable hardware events - note the
23 attributes are embedded in iio_event_attr structures with an
24 associated iio_event_handler which may or may note be shared.
25 If num_interrupt_lines = 0, then no need to fill this in.
28 general attributes such as polled access to device channels.
31 private device specific data.
33 indio_dev->driver_module
34 typically set to THIS_MODULE. Used to specify ownership of some
35 iio created resources.
38 whether direct access and / or ring buffer access is supported.
40 Once these are set up, a call to iio_device_register(indio_dev),
41 will register the device with the iio core.
43 Worth noting here is that, if a ring buffer is to be used, it can be
44 allocated prior to registering the device with the iio-core, but must
45 be registered afterwards (otherwise the whole parentage of devices
48 On remove iio_device_unregister(indio_dev) will remove the device from
49 the core, and iio_free_device will clean up.