2020-04-27 13:14:21

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH v6 0/6] iio: core,buffer: re-organize chardev creation

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 v5 -> v6:
- patch 'iio: core: register chardev only if needed'
- sort file_operations fields for iio_event_fileops
- patch 'iio: buffer,event: duplicate chardev creation for buffers & events'
- fixed-up '**/' -> '*/' for 2 block comments
- sorted file_operations for iio_buffer_fileops, after move
- removed 'indio_dev->chrdev = NULL' on IIO device unregister
- added comment about 'indio_dev->info' NULL check in
iio_device_event_ioctl()
- patch 'iio: core: add simple centralized mechanism for ioctl() handlers'
- re-using lock 'indio_dev->info_exist_lock' for new ioctl register
mechanism in iio_device_ioctl()
- simplified exit condition from the loop; only need to check
`ret != IIO_IOCTL_UNHANDLED` to continue looping;
everything else is just return/break
- patch 'iio: core: use new common ioctl() mechanism'
- the comment for 'indio_dev->info' NULL check is being moved here to
highlight why the null-check is being removed; or where it's being
moved

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 | 116 +++++++++++++-----------------
drivers/iio/industrialio-event.c | 100 +++++++++++++++++++++++++-
include/linux/iio/buffer_impl.h | 10 +++
include/linux/iio/iio.h | 8 +--
6 files changed, 276 insertions(+), 89 deletions(-)

--
2.17.1


2020-04-27 13:15:34

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH v6 2/6] iio: core,buffer: wrap iio_buffer_put() call into iio_buffers_put()

The name (and the wrapper) seems superfluous now, but when more buffers
will be attached to the IIO device this will be a bit more useful.

Signed-off-by: Alexandru Ardelean <[email protected]>
---
drivers/iio/iio_core.h | 4 ++++
drivers/iio/industrialio-buffer.c | 10 ++++++++++
drivers/iio/industrialio-core.c | 2 +-
3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/iio_core.h b/drivers/iio/iio_core.h
index fd9a5f1d5e51..39ec0344fb68 100644
--- a/drivers/iio/iio_core.h
+++ b/drivers/iio/iio_core.h
@@ -51,6 +51,8 @@ void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev);
#define iio_buffer_poll_addr (&iio_buffer_poll)
#define iio_buffer_read_outer_addr (&iio_buffer_read_outer)

+void iio_device_buffers_put(struct iio_dev *indio_dev);
+
void iio_disable_all_buffers(struct iio_dev *indio_dev);
void iio_buffer_wakeup_poll(struct iio_dev *indio_dev);

@@ -66,6 +68,8 @@ static inline int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)

static inline void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev) {}

+static inline void iio_device_buffers_put(struct iio_dev *indio_dev) {}
+
static inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {}
static inline void iio_buffer_wakeup_poll(struct iio_dev *indio_dev) {}

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index bc5050191f51..a66d3fbc2905 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -1355,6 +1355,16 @@ void iio_buffer_free_sysfs_and_mask(struct iio_dev *indio_dev)
iio_free_chan_devattr_list(&buffer->scan_el_dev_attr_list);
}

+void iio_device_buffers_put(struct iio_dev *indio_dev)
+{
+ struct iio_buffer *buffer = indio_dev->buffer;
+
+ if (!buffer)
+ return;
+
+ iio_buffer_put(buffer);
+}
+
/**
* iio_validate_scan_mask_onehot() - Validates that exactly one channel is selected
* @indio_dev: the iio device
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 462d3e810013..32c489139cd2 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1481,7 +1481,7 @@ static void iio_dev_release(struct device *device)
iio_device_unregister_eventset(indio_dev);
iio_device_unregister_sysfs(indio_dev);

- iio_buffer_put(indio_dev->buffer);
+ iio_device_buffers_put(indio_dev);

ida_simple_remove(&iio_ida, indio_dev->id);
kfree(indio_dev);
--
2.17.1

2020-04-27 13:16:13

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH v6 3/6] iio: core: register chardev only if needed

The final intent is to localize all buffer ops into the
industrialio-buffer.c file, to be able to add support for multiple buffers
per IIO device.

We only need a chardev if we need to support buffers and/or events.

With this change, a chardev will be created only if an IIO buffer is
attached OR an event_interface is configured.

Otherwise, no chardev will be created, and the IIO device will get
registered with the 'device_add()' call.

Quite a lot of IIO devices don't really need a chardev, so this is a minor
improvement to the IIO core, as the IIO device will take up (slightly)
fewer resources.

Signed-off-by: Alexandru Ardelean <[email protected]>
---
drivers/iio/industrialio-core.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 32c489139cd2..51e279c60793 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1682,6 +1682,15 @@ static int iio_check_unique_scan_index(struct iio_dev *indio_dev)

static const struct iio_buffer_setup_ops noop_ring_setup_ops;

+static const struct file_operations iio_event_fileops = {
+ .owner = THIS_MODULE,
+ .llseek = noop_llseek,
+ .unlocked_ioctl = iio_event_ioctl_wrapper,
+ .compat_ioctl = compat_ptr_ioctl,
+ .open = iio_chrdev_open,
+ .release = iio_chrdev_release,
+};
+
int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
{
int ret;
@@ -1732,11 +1741,18 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
indio_dev->setup_ops == NULL)
indio_dev->setup_ops = &noop_ring_setup_ops;

- cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
+ if (indio_dev->buffer)
+ cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
+ else if (indio_dev->event_interface)
+ cdev_init(&indio_dev->chrdev, &iio_event_fileops);

indio_dev->chrdev.owner = this_mod;

- ret = cdev_device_add(&indio_dev->chrdev, &indio_dev->dev);
+ if (indio_dev->buffer || indio_dev->event_interface)
+ ret = cdev_device_add(&indio_dev->chrdev, &indio_dev->dev);
+ else
+ ret = device_add(&indio_dev->dev);
+
if (ret < 0)
goto error_unreg_eventset;

@@ -1760,7 +1776,10 @@ EXPORT_SYMBOL(__iio_device_register);
**/
void iio_device_unregister(struct iio_dev *indio_dev)
{
- cdev_device_del(&indio_dev->chrdev, &indio_dev->dev);
+ if (indio_dev->buffer || indio_dev->event_interface)
+ cdev_device_del(&indio_dev->chrdev, &indio_dev->dev);
+ else
+ device_del(&indio_dev->dev);

mutex_lock(&indio_dev->info_exist_lock);

--
2.17.1

2020-05-03 15:41:31

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v6 3/6] iio: core: register chardev only if needed

On Mon, 27 Apr 2020 16:10:57 +0300
Alexandru Ardelean <[email protected]> wrote:

> The final intent is to localize all buffer ops into the
> industrialio-buffer.c file, to be able to add support for multiple buffers
> per IIO device.
>
> We only need a chardev if we need to support buffers and/or events.
>
> With this change, a chardev will be created only if an IIO buffer is
> attached OR an event_interface is configured.
>
> Otherwise, no chardev will be created, and the IIO device will get
> registered with the 'device_add()' call.
>
> Quite a lot of IIO devices don't really need a chardev, so this is a minor
> improvement to the IIO core, as the IIO device will take up (slightly)
> fewer resources.
>
> Signed-off-by: Alexandru Ardelean <[email protected]>
> ---
> drivers/iio/industrialio-core.c | 25 ++++++++++++++++++++++---
> 1 file changed, 22 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 32c489139cd2..51e279c60793 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1682,6 +1682,15 @@ static int iio_check_unique_scan_index(struct iio_dev *indio_dev)
>
> static const struct iio_buffer_setup_ops noop_ring_setup_ops;
>
> +static const struct file_operations iio_event_fileops = {
> + .owner = THIS_MODULE,
> + .llseek = noop_llseek,
> + .unlocked_ioctl = iio_event_ioctl_wrapper,

Unfortunately this doesn't exist until the next patch...

> + .compat_ioctl = compat_ptr_ioctl,
> + .open = iio_chrdev_open,
> + .release = iio_chrdev_release,
> +};
> +
> int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
> {
> int ret;
> @@ -1732,11 +1741,18 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
> indio_dev->setup_ops == NULL)
> indio_dev->setup_ops = &noop_ring_setup_ops;
>
> - cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
> + if (indio_dev->buffer)
> + cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
> + else if (indio_dev->event_interface)
> + cdev_init(&indio_dev->chrdev, &iio_event_fileops);
>
> indio_dev->chrdev.owner = this_mod;
>
> - ret = cdev_device_add(&indio_dev->chrdev, &indio_dev->dev);
> + if (indio_dev->buffer || indio_dev->event_interface)
> + ret = cdev_device_add(&indio_dev->chrdev, &indio_dev->dev);
> + else
> + ret = device_add(&indio_dev->dev);
> +
> if (ret < 0)
> goto error_unreg_eventset;
>
> @@ -1760,7 +1776,10 @@ EXPORT_SYMBOL(__iio_device_register);
> **/
> void iio_device_unregister(struct iio_dev *indio_dev)
> {
> - cdev_device_del(&indio_dev->chrdev, &indio_dev->dev);
> + if (indio_dev->buffer || indio_dev->event_interface)
> + cdev_device_del(&indio_dev->chrdev, &indio_dev->dev);
> + else
> + device_del(&indio_dev->dev);
>
> mutex_lock(&indio_dev->info_exist_lock);
>

2020-05-03 15:52:56

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v6 0/6] iio: core,buffer: re-organize chardev creation

On Mon, 27 Apr 2020 16:10:54 +0300
Alexandru Ardelean <[email protected]> wrote:

> 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.

Hmm. I'd like this set to sit and ideally gather a few acks before
I move ahead with it.

The protections against problems around remove have always been
somewhat fiddly and I suspect don't cover everything.

I'm fairly sure taking the exist lock is 'sufficient' but I'm not
actually sure it's necessary. We only otherwise take it for
place where the inkern interface is in use so we can race
against removal of a provider driver.

We don't have such heavy weight protections in the buffer code
and I'll be honest I can't remember why. Original patch mentions
that it was about avoiding taking additional new references to the
struct iio_dev. We aren't doing that as such here so perhaps
we don't need to take the lock..

Lars, I suspect you may have been involved in that stuff originally
so I'd appreciate you taking a quick look at this if you have
time!

Thanks,

Jonathan

>
>
> Changelog v5 -> v6:
> - patch 'iio: core: register chardev only if needed'
> - sort file_operations fields for iio_event_fileops
> - patch 'iio: buffer,event: duplicate chardev creation for buffers & events'
> - fixed-up '**/' -> '*/' for 2 block comments
> - sorted file_operations for iio_buffer_fileops, after move
> - removed 'indio_dev->chrdev = NULL' on IIO device unregister
> - added comment about 'indio_dev->info' NULL check in
> iio_device_event_ioctl()
> - patch 'iio: core: add simple centralized mechanism for ioctl() handlers'
> - re-using lock 'indio_dev->info_exist_lock' for new ioctl register
> mechanism in iio_device_ioctl()
> - simplified exit condition from the loop; only need to check
> `ret != IIO_IOCTL_UNHANDLED` to continue looping;
> everything else is just return/break
> - patch 'iio: core: use new common ioctl() mechanism'
> - the comment for 'indio_dev->info' NULL check is being moved here to
> highlight why the null-check is being removed; or where it's being
> moved
>
> 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 | 116 +++++++++++++-----------------
> drivers/iio/industrialio-event.c | 100 +++++++++++++++++++++++++-
> include/linux/iio/buffer_impl.h | 10 +++
> include/linux/iio/iio.h | 8 +--
> 6 files changed, 276 insertions(+), 89 deletions(-)
>

2020-05-04 06:50:42

by Alexandru Ardelean

[permalink] [raw]
Subject: Re: [PATCH v6 3/6] iio: core: register chardev only if needed

On Sun, 2020-05-03 at 16:39 +0100, Jonathan Cameron wrote:
> [External]
>
> On Mon, 27 Apr 2020 16:10:57 +0300
> Alexandru Ardelean <[email protected]> wrote:
>
> > The final intent is to localize all buffer ops into the
> > industrialio-buffer.c file, to be able to add support for multiple buffers
> > per IIO device.
> >
> > We only need a chardev if we need to support buffers and/or events.
> >
> > With this change, a chardev will be created only if an IIO buffer is
> > attached OR an event_interface is configured.
> >
> > Otherwise, no chardev will be created, and the IIO device will get
> > registered with the 'device_add()' call.
> >
> > Quite a lot of IIO devices don't really need a chardev, so this is a minor
> > improvement to the IIO core, as the IIO device will take up (slightly)
> > fewer resources.
> >
> > Signed-off-by: Alexandru Ardelean <[email protected]>
> > ---
> > drivers/iio/industrialio-core.c | 25 ++++++++++++++++++++++---
> > 1 file changed, 22 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-
> > core.c
> > index 32c489139cd2..51e279c60793 100644
> > --- a/drivers/iio/industrialio-core.c
> > +++ b/drivers/iio/industrialio-core.c
> > @@ -1682,6 +1682,15 @@ static int iio_check_unique_scan_index(struct iio_dev
> > *indio_dev)
> >
> > static const struct iio_buffer_setup_ops noop_ring_setup_ops;
> >
> > +static const struct file_operations iio_event_fileops = {
> > + .owner = THIS_MODULE,
> > + .llseek = noop_llseek,
> > + .unlocked_ioctl = iio_event_ioctl_wrapper,
>
> Unfortunately this doesn't exist until the next patch...

crap;
i copied this from the wrong place when i re-ordered this, and forgot to run a
build on each patchset

will fix

>
> > + .compat_ioctl = compat_ptr_ioctl,
> > + .open = iio_chrdev_open,
> > + .release = iio_chrdev_release,
> > +};
> > +
> > int __iio_device_register(struct iio_dev *indio_dev, struct module
> > *this_mod)
> > {
> > int ret;
> > @@ -1732,11 +1741,18 @@ int __iio_device_register(struct iio_dev *indio_dev,
> > struct module *this_mod)
> > indio_dev->setup_ops == NULL)
> > indio_dev->setup_ops = &noop_ring_setup_ops;
> >
> > - cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
> > + if (indio_dev->buffer)
> > + cdev_init(&indio_dev->chrdev, &iio_buffer_fileops);
> > + else if (indio_dev->event_interface)
> > + cdev_init(&indio_dev->chrdev, &iio_event_fileops);
> >
> > indio_dev->chrdev.owner = this_mod;
> >
> > - ret = cdev_device_add(&indio_dev->chrdev, &indio_dev->dev);
> > + if (indio_dev->buffer || indio_dev->event_interface)
> > + ret = cdev_device_add(&indio_dev->chrdev, &indio_dev->dev);
> > + else
> > + ret = device_add(&indio_dev->dev);
> > +
> > if (ret < 0)
> > goto error_unreg_eventset;
> >
> > @@ -1760,7 +1776,10 @@ EXPORT_SYMBOL(__iio_device_register);
> > **/
> > void iio_device_unregister(struct iio_dev *indio_dev)
> > {
> > - cdev_device_del(&indio_dev->chrdev, &indio_dev->dev);
> > + if (indio_dev->buffer || indio_dev->event_interface)
> > + cdev_device_del(&indio_dev->chrdev, &indio_dev->dev);
> > + else
> > + device_del(&indio_dev->dev);
> >
> > mutex_lock(&indio_dev->info_exist_lock);
> >

2020-05-06 12:54:52

by Alexandru Ardelean

[permalink] [raw]
Subject: Re: [PATCH v6 0/6] iio: core,buffer: re-organize chardev creation

On Sun, 2020-05-03 at 16:51 +0100, Jonathan Cameron wrote:
> [External]
>
> On Mon, 27 Apr 2020 16:10:54 +0300
> Alexandru Ardelean <[email protected]> wrote:
>
> > 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.
>
> Hmm. I'd like this set to sit and ideally gather a few acks before
> I move ahead with it.
>
> The protections against problems around remove have always been
> somewhat fiddly and I suspect don't cover everything.
>
> I'm fairly sure taking the exist lock is 'sufficient' but I'm not
> actually sure it's necessary. We only otherwise take it for
> place where the inkern interface is in use so we can race
> against removal of a provider driver.
>
> We don't have such heavy weight protections in the buffer code
> and I'll be honest I can't remember why. Original patch mentions
> that it was about avoiding taking additional new references to the
> struct iio_dev. We aren't doing that as such here so perhaps
> we don't need to take the lock..
>
> Lars, I suspect you may have been involved in that stuff originally
> so I'd appreciate you taking a quick look at this if you have
> time!
>

Well, it will take me a bit to re-do this series.
I've got to a point where some of these patches will need some re-tuning.
.
Adding multiple buffers per IIO device seems a bit more difficult than I
initially thought.

> Thanks,
>
> Jonathan
>
> >
> > Changelog v5 -> v6:
> > - patch 'iio: core: register chardev only if needed'
> > - sort file_operations fields for iio_event_fileops
> > - patch 'iio: buffer,event: duplicate chardev creation for buffers & events'
> > - fixed-up '**/' -> '*/' for 2 block comments
> > - sorted file_operations for iio_buffer_fileops, after move
> > - removed 'indio_dev->chrdev = NULL' on IIO device unregister
> > - added comment about 'indio_dev->info' NULL check in
> > iio_device_event_ioctl()
> > - patch 'iio: core: add simple centralized mechanism for ioctl() handlers'
> > - re-using lock 'indio_dev->info_exist_lock' for new ioctl register
> > mechanism in iio_device_ioctl()
> > - simplified exit condition from the loop; only need to check
> > `ret != IIO_IOCTL_UNHANDLED` to continue looping;
> > everything else is just return/break
> > - patch 'iio: core: use new common ioctl() mechanism'
> > - the comment for 'indio_dev->info' NULL check is being moved here to
> > highlight why the null-check is being removed; or where it's being
> > moved
> >
> > 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 | 116 +++++++++++++-----------------
> > drivers/iio/industrialio-event.c | 100 +++++++++++++++++++++++++-
> > include/linux/iio/buffer_impl.h | 10 +++
> > include/linux/iio/iio.h | 8 +--
> > 6 files changed, 276 insertions(+), 89 deletions(-)
> >