Skip to contentSkip to conversation

Introduce support for creating IIO devices via configfs

PATCH In review Daniel Baluta 2 participants 5 messages Apr 25, 2016 – May 4, 2016 IIO

lore
Share & tools
lore
#0 lore raw

v2 cover Introduce support for creating IIO devices via configfs

For testing purposes is nice to have a quick way of creating IIO devices. This patch series introduces support for creating IIO devices via configs (patch 1), allowing users to register "device types". For the moment we support "dummy" device type (patch 2).

Patch 3 introduces configfs entries documentation for easier review.

Changes since v1:
* dropped the RFC tag
* fix coding style issues as per Jonathan suggestion
* fix configfs path in Documentation as per Lars observation (patch 3)
* allocate memory for indio_dev->name (patch 1)
* make iio_simple_dummy depend on SW_DEVICE config option in order to avoid compilation errors reported by kbuild robot.

Daniel Baluta (3):
iio: Add support for creating IIO devices via configfs
iio: dummy: Convert IIO dummy to configfs
Documentation: iio: Add IIO software devices docs

 Documentation/ABI/testing/configfs-iio |  13 +++
 drivers/iio/Kconfig                    |   8 ++
 drivers/iio/Makefile                   |   1 +
 drivers/iio/dummy/Kconfig              |   1 +
 drivers/iio/dummy/iio_simple_dummy.c   | 102 +++++++-----------
 drivers/iio/industrialio-sw-device.c   | 182 +++++++++++++++++++++++++++++++++
 include/linux/iio/sw_device.h          |  70 +++++++++++++
 7 files changed, 312 insertions(+), 65 deletions(-)
 create mode 100644 drivers/iio/industrialio-sw-device.c
 create mode 100644 include/linux/iio/sw_device.h
Signature · 1 line
2.5.0
#1 lore raw

PATCH v2 1/3 iio: Add support for creating IIO devices via configfs

This is similar with support for creating triggers via configfs. Devices will be hosted under:
* /config/iio/devices

We allow users to register "device types" under:
* /config/iio/devices/<device_types>/

---
 drivers/iio/Kconfig                  |   8 ++
 drivers/iio/Makefile                 |   1 +
 drivers/iio/industrialio-sw-device.c | 182 +++++++++++++++++++++++++++++++++++
 include/linux/iio/sw_device.h        |  70 ++++++++++++++
 4 files changed, 261 insertions(+)
 create mode 100644 drivers/iio/industrialio-sw-device.c
 create mode 100644 include/linux/iio/sw_device.h
drivers/iio/Kconfig +8 -0
index 505e921..6743b18 100644
@@ -46,6 +46,14 @@ config IIO_CONSUMERS_PER_TRIGGER
 	This value controls the maximum number of consumers that a
 	given trigger may handle. Default is 2.
 
+config IIO_SW_DEVICE
+	tristate "Enable software IIO device support"
+	select IIO_CONFIGFS
+	help
+	 Provides IIO core support for software devices. A software
+	 device can be created via configfs or directly by a driver
+	 using the API provided.
+
 config IIO_SW_TRIGGER
 	tristate "Enable software triggers support"
 	select IIO_CONFIGFS
drivers/iio/Makefile +1 -0
index 20f6490..87e4c43 100644
@@ -8,6 +8,7 @@ industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o
 industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o
 
 obj-$(CONFIG_IIO_CONFIGFS) += industrialio-configfs.o
+obj-$(CONFIG_IIO_SW_DEVICE) += industrialio-sw-device.o
 obj-$(CONFIG_IIO_SW_TRIGGER) += industrialio-sw-trigger.o
 obj-$(CONFIG_IIO_TRIGGERED_EVENT) += industrialio-triggered-event.o
 
drivers/iio/industrialio-sw-device.c new file +182 -0

182 lines not on this page · raw message

include/linux/iio/sw_device.h new file +70 -0

70 lines not on this page · raw message

Signature · 1 line
2.5.0
#2 lore raw

PATCH v2 2/3 iio: dummy: Convert IIO dummy to configfs

In reply to Daniel Baluta

We register a new device type named "dummy", this will create a configfs entry under:
* /config/iio/devices/dummy.

Creating dummy devices is now as simple as:

$ mkdir /config/iio/devices/dummy/my_dummy_device
---
 drivers/iio/dummy/Kconfig            |   1 +
 drivers/iio/dummy/iio_simple_dummy.c | 102 +++++++++++++----------------------
 2 files changed, 38 insertions(+), 65 deletions(-)
drivers/iio/dummy/Kconfig +1 -0
index 71805ce..aa5824d 100644
@@ -10,6 +10,7 @@ config IIO_DUMMY_EVGEN
 
 config IIO_SIMPLE_DUMMY
        tristate "An example driver with no hardware requirements"
+       depends on IIO_SW_DEVICE
        help
 	 Driver intended mainly as documentation for how to write
 	 a driver. May also be useful for testing userspace code
drivers/iio/dummy/iio_simple_dummy.c +37 -65

180 lines not on this page · raw message

Signature · 1 line
2.5.0
#3 lore raw

PATCH v2 3/3 Documentation: iio: Add IIO software devices docs

In reply to Daniel Baluta
---
 Documentation/ABI/testing/configfs-iio | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Documentation/ABI/testing/configfs-iio +13 -0
index 2483756..aebda53 100644
@@ -19,3 +19,16 @@ KernelVersion:	4.4
 Description:
 		High resolution timers directory. Creating a directory here
 		will result in creating a hrtimer trigger in the IIO subsystem.
+
+What:		/config/iio/devices
+Date:		April 2016
+KernelVersion:	4.7
+Description:
+		Industrial IO software devices directory.
+
+What:		/config/iio/devices/dummy
+Date:		April 2016
+KernelVersion:	4.7
+Description:
+		Dummy IIO devices directory. Creating a directory here will result
+		in creating a dummy IIO device in the IIO subystem.
Signature · 1 line
2.5.0
maintainer
#4 lore raw
In reply to Daniel Baluta
Quoted 6 lines · Daniel Baluta

For testing purposes is nice to have a quick way of creating IIO devices. This patch series introduces support for creating IIO devices via configs (patch 1), allowing users to register "device types". For the moment we support "dummy" device type (patch 2).

Patch 3 introduces configfs entries documentation for easier review.

I guess that this is similar enough to the trigger stuff that already had all the debate about interfaces that no one has any issues with this.

All applied to the togreg branch of iio.git - they'll sit there for a few weeks anyway (in testing for most of that) so if anyone does have any issues I can back them out.

Jonathan

Quoted 25 lines

Changes since v1:
* dropped the RFC tag
* fix coding style issues as per Jonathan suggestion
* fix configfs path in Documentation as per Lars observation (patch 3)
* allocate memory for indio_dev->name (patch 1)
* make iio_simple_dummy depend on SW_DEVICE config option in order to avoid compilation errors reported by kbuild robot.

Daniel Baluta (3):
iio: Add support for creating IIO devices via configfs
iio: dummy: Convert IIO dummy to configfs
Documentation: iio: Add IIO software devices docs

 Documentation/ABI/testing/configfs-iio |  13 +++
 drivers/iio/Kconfig                    |   8 ++
 drivers/iio/Makefile                   |   1 +
 drivers/iio/dummy/Kconfig              |   1 +
 drivers/iio/dummy/iio_simple_dummy.c   | 102 +++++++-----------
 drivers/iio/industrialio-sw-device.c   | 182 +++++++++++++++++++++++++++++++++
 include/linux/iio/sw_device.h          |  70 +++++++++++++
 7 files changed, 312 insertions(+), 65 deletions(-)
 create mode 100644 drivers/iio/industrialio-sw-device.c
 create mode 100644 include/linux/iio/sw_device.h