]> git.karo-electronics.de Git - mv-sheeva.git/blob - drivers/staging/iio/Documentation/device.txt
Merge branch 'packaging' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek...
[mv-sheeva.git] / drivers / staging / iio / Documentation / device.txt
1 IIO Device drivers
2
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
5 subsystem.
6
7 The crucial structure for device drivers in iio is iio_dev.
8
9 First allocate one using:
10
11 struct iio_dev *indio_dev = iio_allocate_device();
12
13 Then fill in the following:
14
15 indio_dev->dev.parent
16   the struct device associated with the underlying hardware.
17
18 indio_dev->num_interrupt_lines
19    number of event triggering hardware lines the device has.
20
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.
26
27 indio_dev->attrs
28    general attributes such as polled access to device channels.
29
30 indio_dev->dev_data
31    private device specific data.
32
33 indio_dev->driver_module
34    typically set to THIS_MODULE. Used to specify ownership of some
35    iio created resources.
36
37 indio_dev->modes
38    whether direct access and / or ring buffer access is supported.
39
40 Once these are set up, a call to iio_device_register(indio_dev),
41 will register the device with the iio core.
42
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
46 gets confused)
47
48 On remove, iio_device_unregister(indio_dev) will remove the device from
49 the core, and iio_free_device will clean up.