[PATCH v5 0/6] iio: core,buffer: re-organize chardev creation

From: Alexandru Ardelean
Date: Sun Apr 26 2020 - 03:38:29 EST


The main intent is to be able to add more chardevs per IIO device, one
for each buffer. To get there, some rework is needed.
This tries to re-organize the init of the chardev.

Changelog v4 -> v5:
- dropped patch 'iio: Use an early return in iio_device_alloc to simplify code.'
is applied upstream

Changelog v3 -> v4:
- added patch [1] 'iio: Use an early return in iio_device_alloc to simplify code.'
it's main purpose is so that this patch applies:
[2]'iio: core: add simple centralized mechanism for ioctl() handlers'
depending on the final version of patch [1], patch [2] needs some
minor fixup
- added patch 'iio: core,buffer: wrap iio_buffer_put() call into iio_buffers_put()'
- patch 'iio: core: register buffer fileops only if buffer present'
is now: 'iio: core: register chardev only if needed'
- dropped 'iio: buffer: move sysfs alloc/free in industrialio-buffer.c'
it's likely we won't be doing this patch anymore
- patches:
'iio: buffer: move iio buffer chrdev in industrialio-buffer.c'
'iio: event: move event-only chardev in industrialio-event.c'
have been merged into 'iio: buffer,event: duplicate chardev creation for buffers & events'
since now, the logic is a bit different, and 'indio_dev->chrdev' is
now a reference to either the buffer's chrdev & or the events-only
chrdev
- added simple mechanism to register ioctl() handlers for IIO device
which is currently used only by events mechanism

Changelog v2 -> v3:
* removed double init in
'iio: event: move event-only chardev in industrialio-event.c'

Changelog v1 -> v2:
* re-reviewed some exit-paths and cleanup some potential leaks on those
exit paths:
- for 'iio: buffer: move iio buffer chrdev in industrialio-buffer.c'
add iio_device_buffers_put() helper and calling iio_buffers_uninit()
on device un-regsiter
- for 'move sysfs alloc/free in industrialio-buffer.c'
call 'iio_buffer_free_sysfs_and_mask()' on exit path if
cdev_device_add() fails
- for 'move event-only chardev in industrialio-event.c'
check if event_interface is NULL in
iio_device_unregister_event_chrdev()

Alexandru Ardelean (6):
iio: buffer: add back-ref from iio_buffer to iio_dev
iio: core,buffer: wrap iio_buffer_put() call into iio_buffers_put()
iio: core: register chardev only if needed
iio: buffer,event: duplicate chardev creation for buffers & events
iio: core: add simple centralized mechanism for ioctl() handlers
iio: core: use new common ioctl() mechanism

drivers/iio/iio_core.h | 29 ++++++---
drivers/iio/industrialio-buffer.c | 102 +++++++++++++++++++++++++++--
drivers/iio/industrialio-core.c | 105 +++++++++++-------------------
drivers/iio/industrialio-event.c | 100 +++++++++++++++++++++++++++-
include/linux/iio/buffer_impl.h | 10 +++
include/linux/iio/iio.h | 8 +--
6 files changed, 267 insertions(+), 87 deletions(-)

--
2.17.1