OSDN Git Service

iio: core: centralize ioctl() calls to the main chardev
authorAlexandru Ardelean <alexandru.ardelean@analog.com>
Thu, 24 Sep 2020 08:41:55 +0000 (11:41 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 14 Nov 2020 15:31:25 +0000 (15:31 +0000)
commit8dedcc3eee3aceb37832176f0a1b03d5687acda3
tree1364f8a7dc31966f1e9a9d575a2ee69a65e19f41
parent1f4877218f7e2c2b914aeb69a8a0f47d59c74717
iio: core: centralize ioctl() calls to the main chardev

The aim of this is to improve a bit the organization of ioctl() calls in
IIO core. Currently the chardev is split across IIO core sub-modules/files.
The main chardev has to be able to handle ioctl() calls, and if we need to
add buffer ioctl() calls, this would complicate things.

The 'industrialio-core.c' file will provide a 'iio_device_ioctl()' which
will iterate over a list of ioctls registered with the IIO device. These
can be event ioctl() or buffer ioctl() calls, or something else.

Each ioctl() handler will have to return a IIO_IOCTL_UNHANDLED code (which
is positive 1), if the ioctl() did not handle the call in any. This
eliminates any potential ambiguities about negative error codes, which
should fail the call altogether.

If any ioctl() returns 0, it was considered that it was serviced
successfully and the loop will exit.

This change also moves the handling of the IIO_GET_EVENT_FD_IOCTL command
inside 'industrialio-event.c', where this is better suited.

This patch is a combination of 2 other patches from an older series:
Patch 1: iio: core: add simple centralized mechanism for ioctl() handlers
Link: https://lore.kernel.org/linux-iio/20200427131100.50845-6-alexandru.ardelean@analog.com/
Patch 2: iio: core: use new common ioctl() mechanism
Link: https://lore.kernel.org/linux-iio/20200427131100.50845-7-alexandru.ardelean@analog.com/
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Link: https://lore.kernel.org/r/20200924084155.99406-1-alexandru.ardelean@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/iio_core.h
drivers/iio/industrialio-core.c
drivers/iio/industrialio-event.c
include/linux/iio/iio-opaque.h