2021-02-01 15:32:01

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH v3 00/11] iio: core,buffer: add support for multiple IIO buffers per IIO device

Changelog v2 -> v3:
* added commit 'docs: ioctl-number.rst: reserve IIO subsystem ioctl() space'
reserving 'i' 0x90-0x9F ioctls for IIO
I did not see any conflicts with others (in the doc)
- related to this, the new IIO_BUFFER_GET_FD_IOCTL is now at 'i' 0x91
* changed approach for creating sysfs buffer directories;
- they are now created as groups on the IIO device; that also means
that the groups array needs to be krealloc-ed and assign later in
the registration
- merged bufferX/ and scan_elementsX/ directories into a single
bufferX/ directory
- for legacy the buffer/ & scan_elements/ directories are kept; but
they're groups objects have been moved on the iio_dev_opaque object
- internally, the iio_dev_attr type is being extended to hold a
reference for an IIO buffer;
= this is great for scan_elements attributes
= and for the rest of the iio_buffer attributes, it means we need to
wrap them into iio_dev_attr

One thing to be determined: if IIO_BUFFER_GET_FD_IOCTL for buffer0 should
return an FD or not.
Right now, it's returning 0.

Alexandru Ardelean (11):
docs: ioctl-number.rst: reserve IIO subsystem ioctl() space
iio: core: register chardev only if needed
iio: core-trigger: make iio_device_register_trigger_consumer() an int
return
iio: core: rework iio device group creation
iio: buffer: group attr count and attr alloc
iio: core: merge buffer/ & scan_elements/ attributes
iio: add reference to iio buffer on iio_dev_attr
iio: buffer: wrap all buffer attributes into iio_dev_attr
iio: core: wrap iio device & buffer into struct for character devices
iio: buffer: introduce support for attaching more IIO buffers
iio: buffer: add ioctl() to support opening extra buffers for IIO
device

.../userspace-api/ioctl/ioctl-number.rst | 1 +
drivers/iio/iio_core.h | 10 +
drivers/iio/iio_core_trigger.h | 4 +-
drivers/iio/industrialio-buffer.c | 420 +++++++++++++++---
drivers/iio/industrialio-core.c | 87 +++-
drivers/iio/industrialio-event.c | 6 +-
drivers/iio/industrialio-trigger.c | 6 +-
include/linux/iio/buffer.h | 4 +-
include/linux/iio/buffer_impl.h | 21 +-
include/linux/iio/iio-opaque.h | 14 +
include/linux/iio/iio.h | 5 -
include/linux/iio/sysfs.h | 3 +
include/uapi/linux/iio/buffer.h | 10 +
13 files changed, 487 insertions(+), 104 deletions(-)
create mode 100644 include/uapi/linux/iio/buffer.h

--
2.17.1


2021-02-01 15:34:29

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH v3 01/11] docs: ioctl-number.rst: reserve IIO subsystem ioctl() space

Currently, only the 'i' 0x90 ioctl() actually exists and is defined in
'uapi/linux/iio/events.h'.

It's the IIO_GET_EVENT_FD_IOCTL, which is used to retrieve and FD for
reading events from an IIO device.
We will want to add more ioct() numbers, so with this change the 'i'
0x90-0x9F space is reserved for IIO ioctl() calls.

Signed-off-by: Alexandru Ardelean <[email protected]>
---
Documentation/userspace-api/ioctl/ioctl-number.rst | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst
index a4c75a28c839..9ebde26b7e32 100644
--- a/Documentation/userspace-api/ioctl/ioctl-number.rst
+++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
@@ -245,6 +245,7 @@ Code Seq# Include File Comments
'i' 00-3F linux/i2o-dev.h conflict!
'i' 0B-1F linux/ipmi.h conflict!
'i' 80-8F linux/i8k.h
+'i' 90-9F `uapi/linux/iio/*.h` IIO
'j' 00-3F linux/joystick.h
'k' 00-0F linux/spi/spidev.h conflict!
'k' 00-05 video/kyro.h conflict!
--
2.17.1

2021-02-01 15:35:27

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH v3 03/11] iio: core-trigger: make iio_device_register_trigger_consumer() an int return

Oddly enough the noop function is an int-return. This one seems to be void.
This change converts it to int, because we want to change how groups are
registered. With that change this function could error out with -ENOMEM.

Signed-off-by: Alexandru Ardelean <[email protected]>
---
drivers/iio/iio_core_trigger.h | 4 +++-
drivers/iio/industrialio-trigger.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/iio_core_trigger.h b/drivers/iio/iio_core_trigger.h
index 374816bc3e73..e1a56824e07f 100644
--- a/drivers/iio/iio_core_trigger.h
+++ b/drivers/iio/iio_core_trigger.h
@@ -9,8 +9,10 @@
/**
* iio_device_register_trigger_consumer() - set up an iio_dev to use triggers
* @indio_dev: iio_dev associated with the device that will consume the trigger
+ *
+ * Return 0 if successful, negative otherwise
**/
-void iio_device_register_trigger_consumer(struct iio_dev *indio_dev);
+int iio_device_register_trigger_consumer(struct iio_dev *indio_dev);

/**
* iio_device_unregister_trigger_consumer() - reverse the registration process
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index ea3c9859b258..438d5012e8b8 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -692,10 +692,12 @@ int iio_trigger_validate_own_device(struct iio_trigger *trig,
}
EXPORT_SYMBOL(iio_trigger_validate_own_device);

-void iio_device_register_trigger_consumer(struct iio_dev *indio_dev)
+int iio_device_register_trigger_consumer(struct iio_dev *indio_dev)
{
indio_dev->groups[indio_dev->groupcounter++] =
&iio_trigger_consumer_attr_group;
+
+ return 0;
}

void iio_device_unregister_trigger_consumer(struct iio_dev *indio_dev)
--
2.17.1

2021-02-05 01:05:58

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH v3 01/11] docs: ioctl-number.rst: reserve IIO subsystem ioctl() space

On Mon, 1 Feb 2021 16:50:55 +0200
Alexandru Ardelean <[email protected]> wrote:

> Currently, only the 'i' 0x90 ioctl() actually exists and is defined in
> 'uapi/linux/iio/events.h'.
>
> It's the IIO_GET_EVENT_FD_IOCTL, which is used to retrieve and FD for
> reading events from an IIO device.
> We will want to add more ioct() numbers, so with this change the 'i'
> 0x90-0x9F space is reserved for IIO ioctl() calls.
>
> Signed-off-by: Alexandru Ardelean <[email protected]>
Hi Alex,

Thanks for tidying this up. My bad from a long time ago to not register
this at the time.

> ---
> Documentation/userspace-api/ioctl/ioctl-number.rst | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst
> index a4c75a28c839..9ebde26b7e32 100644
> --- a/Documentation/userspace-api/ioctl/ioctl-number.rst
> +++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
> @@ -245,6 +245,7 @@ Code Seq# Include File Comments
> 'i' 00-3F linux/i2o-dev.h conflict!
> 'i' 0B-1F linux/ipmi.h conflict!
> 'i' 80-8F linux/i8k.h
> +'i' 90-9F `uapi/linux/iio/*.h` IIO

I think the uapi/ bit is effectively implicit. I checked a few of them and the
definitions are in uapi/linux/

> 'j' 00-3F linux/joystick.h
> 'k' 00-0F linux/spi/spidev.h conflict!
> 'k' 00-05 video/kyro.h conflict!

2021-02-05 07:16:02

by Alexandru Ardelean

[permalink] [raw]
Subject: Re: [PATCH v3 01/11] docs: ioctl-number.rst: reserve IIO subsystem ioctl() space

On Thu, Feb 4, 2021 at 7:13 PM Jonathan Cameron
<[email protected]> wrote:
>
> On Mon, 1 Feb 2021 16:50:55 +0200
> Alexandru Ardelean <[email protected]> wrote:
>
> > Currently, only the 'i' 0x90 ioctl() actually exists and is defined in
> > 'uapi/linux/iio/events.h'.
> >
> > It's the IIO_GET_EVENT_FD_IOCTL, which is used to retrieve and FD for
> > reading events from an IIO device.
> > We will want to add more ioct() numbers, so with this change the 'i'
> > 0x90-0x9F space is reserved for IIO ioctl() calls.
> >
> > Signed-off-by: Alexandru Ardelean <[email protected]>
> Hi Alex,
>
> Thanks for tidying this up. My bad from a long time ago to not register
> this at the time.
>
> > ---
> > Documentation/userspace-api/ioctl/ioctl-number.rst | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/Documentation/userspace-api/ioctl/ioctl-number.rst b/Documentation/userspace-api/ioctl/ioctl-number.rst
> > index a4c75a28c839..9ebde26b7e32 100644
> > --- a/Documentation/userspace-api/ioctl/ioctl-number.rst
> > +++ b/Documentation/userspace-api/ioctl/ioctl-number.rst
> > @@ -245,6 +245,7 @@ Code Seq# Include File Comments
> > 'i' 00-3F linux/i2o-dev.h conflict!
> > 'i' 0B-1F linux/ipmi.h conflict!
> > 'i' 80-8F linux/i8k.h
> > +'i' 90-9F `uapi/linux/iio/*.h` IIO
>
> I think the uapi/ bit is effectively implicit. I checked a few of them and the
> definitions are in uapi/linux/

ack

>
> > 'j' 00-3F linux/joystick.h
> > 'k' 00-0F linux/spi/spidev.h conflict!
> > 'k' 00-05 video/kyro.h conflict!
>