Skip to contentSkip to conversation

Add initial configfs support for IIO

PATCH Superseded Daniel Baluta 3 participants 18 messages May 4, 2015 – May 7, 2015

Subsystems (2)

v5 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add initial configfs support for IIO

This patchset introduces IIO software triggers, offers a way of configuring them via configfs and adds the IIO hrtimer based interrupt source to be used with software triggers.

The arhitecture is now split in 3 parts, to remove all IIO trigger specific parts from IIO configfs core:

(1) IIO software triggers - are independent of configfs.
(2) IIO configfs - offers a generic way of creating IIO objects. So far we can create software triggers.
(3) IIO hrtimer trigger - is the first interrupt source for software triggers (with syfs to follow). Each trigger type can implement its own set of attributes.

Changes since v4:
* patch 1/4
- fixed "new line" nit in industrialio-sw-trigger.c
- added license header in sw_trigger.h
* patch 2/4
- none
* patch 3/4
- none
* patch 4/4
- removed "Further work" chapter in iio_configfs.txt
- added configfs-iio file in Documentation/ABI/testing

Changes since v3:
* addressed comments from Jonathan for previous version
* https://lkml.org/lkml/2015/4/6/111

Daniel Baluta (4):
iio: core: Introduce IIO software triggers
iio: core: Introduce IIO configfs support
iio: trigger: Introduce IIO hrtimer based trigger
iio: Documentation: Add IIO configfs documentation

 Documentation/ABI/testing/configfs-iio |  26 +++++
 Documentation/iio/iio_configfs.txt     |  63 +++++++++++
 drivers/iio/Kconfig                    |  16 +++
 drivers/iio/Makefile                   |   2 +
 drivers/iio/industrialio-configfs.c    | 117 +++++++++++++++++++
 drivers/iio/industrialio-sw-trigger.c  | 112 ++++++++++++++++++
 drivers/iio/trigger/Kconfig            |   9 ++
 drivers/iio/trigger/Makefile           |   2 +
 drivers/iio/trigger/iio-trig-hrtimer.c | 201 +++++++++++++++++++++++++++++++++
 include/linux/iio/sw_trigger.h         |  60 ++++++++++
 10 files changed, 608 insertions(+)
 create mode 100644 Documentation/ABI/testing/configfs-iio
 create mode 100644 Documentation/iio/iio_configfs.txt
 create mode 100644 drivers/iio/industrialio-configfs.c
 create mode 100644 drivers/iio/industrialio-sw-trigger.c
 create mode 100644 drivers/iio/trigger/iio-trig-hrtimer.c
 create mode 100644 include/linux/iio/sw_trigger.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v5 1/4 iio: core: Introduce IIO software triggers

A software trigger associates an IIO device trigger with a software interrupt source (e.g: timer, sysfs). This patch adds the generic infrastructure for handling software triggers.

Software interrupts sources are kept in a iio_trigger_types_list and registered separately when the associated kernel module is loaded.

Software triggers can be created directly from drivers or from user space via configfs interface.

---
 drivers/iio/Kconfig                   |   8 +++
 drivers/iio/Makefile                  |   1 +
 drivers/iio/industrialio-sw-trigger.c | 112 ++++++++++++++++++++++++++++++++++
 include/linux/iio/sw_trigger.h        |  60 ++++++++++++++++++
 4 files changed, 181 insertions(+)
 create mode 100644 drivers/iio/industrialio-sw-trigger.c
 create mode 100644 include/linux/iio/sw_trigger.h
drivers/iio/Kconfig +8 -0
index 4011eff..de7f1d9 100644
@@ -58,6 +58,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_TRIGGER
+	bool "Enable software triggers support"
+	depends on IIO_TRIGGER
+	help
+	 Provides IIO core support for software triggers. A software
+	 trigger can be created via configfs or directly by a driver
+	 using the API provided.
+
 source "drivers/iio/accel/Kconfig"
 source "drivers/iio/adc/Kconfig"
 source "drivers/iio/amplifiers/Kconfig"
drivers/iio/Makefile +1 -0
index 698afc2..df87975 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_IIO) += industrialio.o
 industrialio-y := industrialio-core.o industrialio-event.o inkern.o
 industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o
 industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o
+industrialio-$(CONFIG_IIO_SW_TRIGGER) += industrialio-sw-trigger.o
 industrialio-$(CONFIG_IIO_BUFFER_CB) += buffer_cb.o
 
 obj-$(CONFIG_IIO_TRIGGERED_BUFFER) += industrialio-triggered-buffer.o
drivers/iio/industrialio-sw-trigger.c new file +112 -0

112 lines not on this page · raw message

include/linux/iio/sw_trigger.h new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH v5 1/4] iio: core: Introduce IIO software triggers

Quoted 70 lines · Daniel Baluta

A software trigger associates an IIO device trigger with a software interrupt source (e.g: timer, sysfs). This patch adds the generic infrastructure for handling software triggers.

Software interrupts sources are kept in a iio_trigger_types_list and registered separately when the associated kernel module is loaded.

Software triggers can be created directly from drivers or from user space via configfs interface.

---
  drivers/iio/Kconfig                   |   8 +++
  drivers/iio/Makefile                  |   1 +
  drivers/iio/industrialio-sw-trigger.c | 112 ++++++++++++++++++++++++++++++++++
  include/linux/iio/sw_trigger.h        |  60 ++++++++++++++++++
  4 files changed, 181 insertions(+)

create mode 100644 drivers/iio/industrialio-sw-trigger.c create mode 100644 include/linux/iio/sw_trigger.h

drivers/iio/Kconfig +8 -0
index 4011eff..de7f1d9 100644
@@ -58,6 +58,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_TRIGGER
+	bool "Enable software triggers support"
+	depends on IIO_TRIGGER
+	help
+	 Provides IIO core support for software triggers. A software
+	 trigger can be created via configfs or directly by a driver
+	 using the API provided.
+
  source "drivers/iio/accel/Kconfig"
  source "drivers/iio/adc/Kconfig"
  source "drivers/iio/amplifiers/Kconfig"
drivers/iio/Makefile +1 -0
index 698afc2..df87975 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_IIO) += industrialio.o
  industrialio-y := industrialio-core.o industrialio-event.o inkern.o
  industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o
  industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o
+industrialio-$(CONFIG_IIO_SW_TRIGGER) += industrialio-sw-trigger.o
  industrialio-$(CONFIG_IIO_BUFFER_CB) += buffer_cb.o
 
  obj-$(CONFIG_IIO_TRIGGERED_BUFFER) += industrialio-triggered-buffer.o
drivers/iio/industrialio-sw-trigger.c new file +13 -0
new file mode 100644
index 0000000..f22aa63
@@ -0,0 +1,112 @@
+/*
+ * The Industrial I/O core, software trigger functions
+ *
+ * Copyright (c) 2015 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kmod.h>

drivers/iio/industrialio-sw-trigger.c line 23

Quoted 10 lines
drivers/iio/industrialio-sw-trigger.c new file +10 -0
+#include <linux/list.h>
+#include <linux/slab.h>
+
+#include <linux/iio/sw_trigger.h>
+
+static LIST_HEAD(iio_trigger_types_list);
+static DEFINE_RWLOCK(iio_trigger_types_lock);
+
+static
+struct iio_sw_trigger_type *iio_find_sw_trigger_type(char *name, unsigned len)

const char *name, there are a couple of other places where char * should be const char * below as well.

drivers/iio/industrialio-sw-trigger.c line 36

Quoted 13 lines
drivers/iio/industrialio-sw-trigger.c new file +13 -0
+{
+	struct iio_sw_trigger_type *t = NULL, *iter;
+
+	list_for_each_entry(iter, &iio_trigger_types_list, list)
+		if (!strncmp(iter->name, name, len)) {
+			t = iter;
+			break;
+		}
+
+	return t;
+}
+
+int iio_register_sw_trigger_type(struct iio_sw_trigger_type *t)

Kernel doc would be nice for the public API

Quoted 7 lines
drivers/iio/industrialio-sw-trigger.c new file +7 -0
+{
+	struct iio_sw_trigger_type *iter;
+	int ret = 0;
+
+	write_lock(&iio_trigger_types_lock);
+	iter = iio_find_sw_trigger_type(t->name, strlen(t->name));
+	if (iter)

drivers/iio/industrialio-sw-trigger.c line 53

Quoted 10 lines
drivers/iio/industrialio-sw-trigger.c new file +10 -0
+		ret = -EBUSY;
+	else
+		list_add_tail(&t->list, &iio_trigger_types_list);
+	write_unlock(&iio_trigger_types_lock);
+
+	return ret;
+}
+EXPORT_SYMBOL(iio_register_sw_trigger_type);
+
+int iio_unregister_sw_trigger_type(struct iio_sw_trigger_type *t)

I'd make the return type void. Either it is not registered and unregister is a noop, or it is registered and it will be successfully unregistered. Either way the operation won't fail.

drivers/iio/industrialio-sw-trigger.c line 42

Quoted 6 lines
drivers/iio/industrialio-sw-trigger.c new file +6 -0
+{
+	struct iio_sw_trigger_type *iter;
+	int ret = 0;
+
+	write_lock(&iio_trigger_types_lock);
+	iter = iio_find_sw_trigger_type(t->name, strlen(t->name));

Not sure if we need this. unregister should never be called without register succeeding before.

Quoted 44 lines
drivers/iio/industrialio-sw-trigger.c new file +44 -0
+	if (!iter)
+		ret = -EINVAL;
+	else
+		list_del(&t->list);
+	write_unlock(&iio_trigger_types_lock);
+
+	return ret;
+}
+EXPORT_SYMBOL(iio_unregister_sw_trigger_type);
+
+static
+struct iio_sw_trigger_type *iio_get_sw_trigger_type(char *name)
+{
+	struct iio_sw_trigger_type *t;
+
+	read_lock(&iio_trigger_types_lock);
+	t = iio_find_sw_trigger_type(name, strlen(name));
+	if (t && !try_module_get(t->owner))
+		t = NULL;
+	read_unlock(&iio_trigger_types_lock);
+
+	return t;
+}
+
+struct iio_sw_trigger *iio_sw_trigger_create(char *type, char *name)
+{
+	struct iio_sw_trigger *t;
+	struct iio_sw_trigger_type *tt;
+
+	tt = iio_get_sw_trigger_type(type);
+	if (!tt) {
+		pr_err("Invalid trigger type: %s\n", type);
+		return ERR_PTR(-EINVAL);
+	}
+	t = tt->ops->probe(name);
+	if (IS_ERR(t))
+		goto out_module_put;
+
+	return t;
+out_module_put:
+	module_put(tt->owner);
+	return t;
+}
+EXPORT_SYMBOL(iio_sw_trigger_create);

[...]

drivers/iio/industrialio-sw-trigger.c

Quoted 2 lines
drivers/iio/industrialio-sw-trigger.c new file +2 -0
+struct iio_sw_trigger_type {
+	char *name;

const

drivers/iio/industrialio-sw-trigger.c

Quoted 2 lines
drivers/iio/industrialio-sw-trigger.c new file +2 -0
+	struct module *owner;
+	struct iio_sw_trigger_ops *ops;

const

drivers/iio/industrialio-sw-trigger.c

Quoted 9 lines
drivers/iio/industrialio-sw-trigger.c new file +9 -0
+	struct list_head list;
+};
+
+struct iio_sw_trigger {
+	struct iio_trigger *trigger;
+	struct iio_sw_trigger_type *trigger_type;
+#ifdef CONFIG_CONFIGFS_FS
+	struct config_group group;
+#endif

The configfs specific bits should go into patch 2.

Quoted 24 lines
drivers/iio/industrialio-sw-trigger.c new file +23 -0
+};
+
+struct iio_sw_trigger_ops {
+	struct iio_sw_trigger* (*probe)(const char *);
+	int (*remove)(struct iio_sw_trigger *);
+};
+
+int iio_register_sw_trigger_type(struct iio_sw_trigger_type *);
+int iio_unregister_sw_trigger_type(struct iio_sw_trigger_type *);
+
+struct iio_sw_trigger *iio_sw_trigger_create(char *, char *);
+void iio_sw_trigger_destroy(struct iio_sw_trigger *);
+
+#ifdef CONFIG_CONFIGFS_FS
+static inline
+struct iio_sw_trigger *to_iio_sw_trigger(struct config_item *item)
+{
+	return container_of(to_config_group(item), struct iio_sw_trigger,
+			    group);
+}
+#endif
+
+#endif /* __IIO_SW_TRIGGER */
#3 lore raw

Re: [PATCH v5 1/4] iio: core: Introduce IIO software triggers

Quoted 83 lines · Lars-Peter Clausen
Quoted 82 lines · Daniel Baluta

A software trigger associates an IIO device trigger with a software interrupt source (e.g: timer, sysfs). This patch adds the generic infrastructure for handling software triggers.

Software interrupts sources are kept in a iio_trigger_types_list and registered separately when the associated kernel module is loaded.

Software triggers can be created directly from drivers or from user space via configfs interface.

---
  drivers/iio/Kconfig                   |   8 +++
  drivers/iio/Makefile                  |   1 +
  drivers/iio/industrialio-sw-trigger.c | 112
++++++++++++++++++++++++++++++++++
  include/linux/iio/sw_trigger.h        |  60 ++++++++++++++++++
  4 files changed, 181 insertions(+)

create mode 100644 drivers/iio/industrialio-sw-trigger.c create mode 100644 include/linux/iio/sw_trigger.h

drivers/iio/Kconfig +8 -0
index 4011eff..de7f1d9 100644
@@ -58,6 +58,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_TRIGGER
+       bool "Enable software triggers support"
+       depends on IIO_TRIGGER
+       help
+        Provides IIO core support for software triggers. A software
+        trigger can be created via configfs or directly by a driver
+        using the API provided.
+
  source "drivers/iio/accel/Kconfig"
  source "drivers/iio/adc/Kconfig"
  source "drivers/iio/amplifiers/Kconfig"
drivers/iio/Makefile +1 -0
index 698afc2..df87975 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_IIO) += industrialio.o
  industrialio-y := industrialio-core.o industrialio-event.o inkern.o
  industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o
  industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o
+industrialio-$(CONFIG_IIO_SW_TRIGGER) += industrialio-sw-trigger.o
  industrialio-$(CONFIG_IIO_BUFFER_CB) += buffer_cb.o
 
  obj-$(CONFIG_IIO_TRIGGERED_BUFFER) += industrialio-triggered-buffer.o
drivers/iio/industrialio-sw-trigger.c new file +6 -0
new file mode 100644
index 0000000..f22aa63
@@ -0,0 +1,112 @@
+/*
+ * The Industrial I/O core, software trigger functions
+ *
+ * Copyright (c) 2015 Intel Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify

it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */

drivers/iio/industrialio-sw-trigger.c new file +11 -0
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kmod.h>
+#include <linux/list.h>
+#include <linux/slab.h>
+
+#include <linux/iio/sw_trigger.h>
+
+static LIST_HEAD(iio_trigger_types_list);
+static DEFINE_RWLOCK(iio_trigger_types_lock);
Quoted 8 lines
Quoted 4 lines
drivers/iio/industrialio-sw-trigger.c new file +3 -0
+
+static
+struct iio_sw_trigger_type *iio_find_sw_trigger_type(char *name, unsigned

len)

const char *name, there are a couple of other places where char * should be const char * below as well.

Agree. I will fix this.

Quoted 17 lines
Quoted 4 lines
drivers/iio/industrialio-sw-trigger.c new file +3 -0
+{
+       struct iio_sw_trigger_type *t = NULL, *iter;
+

drivers/iio/industrialio-sw-trigger.c line 36

Quoted 10 lines
drivers/iio/industrialio-sw-trigger.c new file +10 -0
+       list_for_each_entry(iter, &iio_trigger_types_list, list)
+               if (!strncmp(iter->name, name, len)) {
+                       t = iter;
+                       break;
+               }
+
+       return t;
+}
+
+int iio_register_sw_trigger_type(struct iio_sw_trigger_type *t)

Kernel doc would be nice for the public API

ok.

Quoted 15 lines
Quoted 15 lines
drivers/iio/industrialio-sw-trigger.c new file +14 -0
+{
+       struct iio_sw_trigger_type *iter;
+       int ret = 0;
+
+       write_lock(&iio_trigger_types_lock);
+       iter = iio_find_sw_trigger_type(t->name, strlen(t->name));
+       if (iter)
+               ret = -EBUSY;
+       else
+               list_add_tail(&t->list, &iio_trigger_types_list);
+       write_unlock(&iio_trigger_types_lock);
+
+       return ret;
+}
Quoted 8 lines

drivers/iio/industrialio-sw-trigger.c line 53

Quoted 3 lines
drivers/iio/industrialio-sw-trigger.c new file +3 -0
+EXPORT_SYMBOL(iio_register_sw_trigger_type);
+
+int iio_unregister_sw_trigger_type(struct iio_sw_trigger_type *t)

I'd make the return type void. Either it is not registered and unregister is a noop, or it is registered and it will be successfully unregistered. Either way the operation won't fail.

I don't have a strong preference for this. Likely the drivers will not check for the return code of the function, but would be nice to let them the possibility to do so.

I'm looking at unregister_filesystem for example:

http://lxr.free-electrons.com/source/fs/filesystems.c#L101

Quoted 12 lines

drivers/iio/industrialio-sw-trigger.c line 42

Quoted 7 lines
drivers/iio/industrialio-sw-trigger.c new file +6 -0
+{
+       struct iio_sw_trigger_type *iter;
+       int ret = 0;
+
+       write_lock(&iio_trigger_types_lock);
+       iter = iio_find_sw_trigger_type(t->name, strlen(t->name));

Not sure if we need this. unregister should never be called without register succeeding before.

Famous last words :). I can change it if you really have a preference for this. I don't see any drawbacks as it is now. Also the Linux kernel code seems to use both patterns.

Quoted 60 lines
Quoted 45 lines
drivers/iio/industrialio-sw-trigger.c new file +44 -0
+       if (!iter)
+               ret = -EINVAL;
+       else
+               list_del(&t->list);
+       write_unlock(&iio_trigger_types_lock);
+
+       return ret;
+}
+EXPORT_SYMBOL(iio_unregister_sw_trigger_type);
+
+static
+struct iio_sw_trigger_type *iio_get_sw_trigger_type(char *name)
+{
+       struct iio_sw_trigger_type *t;
+
+       read_lock(&iio_trigger_types_lock);
+       t = iio_find_sw_trigger_type(name, strlen(name));
+       if (t && !try_module_get(t->owner))
+               t = NULL;
+       read_unlock(&iio_trigger_types_lock);
+
+       return t;
+}
+
+struct iio_sw_trigger *iio_sw_trigger_create(char *type, char *name)
+{
+       struct iio_sw_trigger *t;
+       struct iio_sw_trigger_type *tt;
+
+       tt = iio_get_sw_trigger_type(type);
+       if (!tt) {
+               pr_err("Invalid trigger type: %s\n", type);
+               return ERR_PTR(-EINVAL);
+       }
+       t = tt->ops->probe(name);
+       if (IS_ERR(t))
+               goto out_module_put;
+
+       return t;
+out_module_put:
+       module_put(tt->owner);
+       return t;
+}
+EXPORT_SYMBOL(iio_sw_trigger_create);

[...]

drivers/iio/industrialio-sw-trigger.c

Quoted 3 lines
drivers/iio/industrialio-sw-trigger.c new file +2 -0
+struct iio_sw_trigger_type {
+       char *name;

const

drivers/iio/industrialio-sw-trigger.c

Quoted 2 lines
drivers/iio/industrialio-sw-trigger.c new file +2 -0
+       struct module *owner;
+       struct iio_sw_trigger_ops *ops;

const

Quoted 12 lines

drivers/iio/industrialio-sw-trigger.c

Quoted 9 lines
drivers/iio/industrialio-sw-trigger.c new file +9 -0
+       struct list_head list;
+};
+
+struct iio_sw_trigger {
+       struct iio_trigger *trigger;
+       struct iio_sw_trigger_type *trigger_type;
+#ifdef CONFIG_CONFIGFS_FS
+       struct config_group group;
+#endif

The configfs specific bits should go into patch 2.

Agree.

Quoted 19 lines
Quoted 19 lines
drivers/iio/industrialio-sw-trigger.c new file +18 -0
+};
+
+struct iio_sw_trigger_ops {
+       struct iio_sw_trigger* (*probe)(const char *);
+       int (*remove)(struct iio_sw_trigger *);
+};
+
+int iio_register_sw_trigger_type(struct iio_sw_trigger_type *);
+int iio_unregister_sw_trigger_type(struct iio_sw_trigger_type *);
+
+struct iio_sw_trigger *iio_sw_trigger_create(char *, char *);
+void iio_sw_trigger_destroy(struct iio_sw_trigger *);
+
+#ifdef CONFIG_CONFIGFS_FS
+static inline
+struct iio_sw_trigger *to_iio_sw_trigger(struct config_item *item)
+{
+       return container_of(to_config_group(item), struct iio_sw_trigger,
Quoted 8 lines

drivers/iio/industrialio-sw-trigger.c

Quoted 6 lines
drivers/iio/industrialio-sw-trigger.c new file +5 -0
+                           group);
+}
+#endif
+
+#endif /* __IIO_SW_TRIGGER */

--

Thanks a lot Lars!

Daniel.

#4 lore raw

PATCH v5 2/4 iio: core: Introduce IIO configfs support

In reply to Daniel Baluta

This creates an IIO configfs subystem named "iio", with a default "triggers" group.

Triggers group is used for handling software triggers. To create a new software trigger one must create a directory inside the trigger directory.

Software trigger name MUST follow the following convention:
* <trigger-type>-<trigger-name>
Where:
* <trigger_type>, specifies the interrupt source (e.g: hrtimer)
* <trigger-name>, specifies the IIO device trigger name

Failing to follow this convention will result in an directory creation error.

E.g, assuming that hrtimer trigger type is registered with IIO software trigger core:

$ mkdir /config/iio/triggers/hrtimer-instance1
---
 drivers/iio/Kconfig                 |   8 +++
 drivers/iio/Makefile                |   1 +
 drivers/iio/industrialio-configfs.c | 117 ++++++++++++++++++++++++++++++++++++
 3 files changed, 126 insertions(+)
 create mode 100644 drivers/iio/industrialio-configfs.c
drivers/iio/Kconfig +8 -0
index de7f1d9..c310156 100644
@@ -18,6 +18,14 @@ config IIO_BUFFER
 	  Provide core support for various buffer based data
 	  acquisition methods.
 
+config IIO_CONFIGFS
+	tristate "Enable IIO configuration via configfs"
+	select CONFIGFS_FS
+	help
+	  This allows configuring various IIO bits through configfs
+	  (e.g. software triggers). For more info see
+	  Documentation/iio/iio_configfs.txt.
+
 if IIO_BUFFER
 
 config IIO_BUFFER_CB
drivers/iio/Makefile +1 -0
index df87975..31aead3 100644
@@ -10,6 +10,7 @@ industrialio-$(CONFIG_IIO_SW_TRIGGER) += industrialio-sw-trigger.o
 industrialio-$(CONFIG_IIO_BUFFER_CB) += buffer_cb.o
 
 obj-$(CONFIG_IIO_TRIGGERED_BUFFER) += industrialio-triggered-buffer.o
+obj-$(CONFIG_IIO_CONFIGFS) += industrialio-configfs.o
 obj-$(CONFIG_IIO_KFIFO_BUF) += kfifo_buf.o
 
 obj-y += accel/
drivers/iio/industrialio-configfs.c new file +117 -0

117 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

Re: [PATCH v5 2/4] iio: core: Introduce IIO configfs support

Quoted 12 lines · Daniel Baluta

This creates an IIO configfs subystem named "iio", with a default "triggers" group.

Triggers group is used for handling software triggers. To create a new software trigger one must create a directory inside the trigger directory.

Software trigger name MUST follow the following convention:
* <trigger-type>-<trigger-name>
Where:
* <trigger_type>, specifies the interrupt source (e.g: hrtimer)
* <trigger-name>, specifies the IIO device trigger name

Quoted 7 lines

Failing to follow this convention will result in an directory creation error.

E.g, assuming that hrtimer trigger type is registered with IIO software trigger core:

$ mkdir /config/iio/triggers/hrtimer-instance1

Nice, short and clean. Looks pretty good. It's a bit of a shame that we can't have a per type directory, but if that's how configfs works I guess there is not much choice.

[...]

Quoted 5 lines
drivers/iio/industrialio-configfs.c new file +5 -0
+static struct config_group *trigger_make_group(struct config_group *group,
+					       const char *name)
+{
+	char *type_name;
+	char *trigger_name;

drivers/iio/industrialio-configfs.c line 36

Quoted 10 lines
drivers/iio/industrialio-configfs.c new file +10 -0
+	char buf[MAX_NAME_LEN];
+	struct iio_sw_trigger *t;
+
+	snprintf(buf, MAX_NAME_LEN, "%s", name);
+
+	/* group name should have the form <trigger-type>-<trigger-name> */
+	type_name = buf;
+	trigger_name = strchr(buf, '-');
+	if (!trigger_name) {
+		pr_err("Unable to locate '-' in %s. Use <type>-<name>.\n", buf);

Do we want to print this side channel message? Makes it pretty easy to spam the kernel log with a rouge application.

Quoted 12 lines
drivers/iio/industrialio-configfs.c new file +12 -0
+		return ERR_PTR(-EINVAL);
+	}
+
+	/* replace - with \0, this nicely separates the two strings */
+	*trigger_name = '\0';
+	trigger_name++;
+
+	t = iio_sw_trigger_create(type_name, trigger_name);
+	if (IS_ERR(t))
+		return ERR_CAST(t);
+
+	config_item_set_name(&t->group.cg_item, name);

drivers/iio/industrialio-configfs.c line 58

Quoted 10 lines
drivers/iio/industrialio-configfs.c new file +10 -0
+
+	return &t->group;
+}
+
+static void trigger_drop_group(struct config_group *group,
+			       struct config_item *item)
+{
+	struct iio_sw_trigger *t = to_iio_sw_trigger(item);
+
+	if (t)

t will never be NULL.

Quoted 3 lines
drivers/iio/industrialio-configfs.c new file +3 -0
+		iio_sw_trigger_destroy(t);
+	config_item_put(item);
+}
maintainer
#6 lore raw

Re: [PATCH v5 2/4] iio: core: Introduce IIO configfs support

Quoted 22 lines · Lars-Peter Clausen
Quoted 1 line · Daniel Baluta

This creates an IIO configfs subystem named "iio", with a default

"triggers"

Quoted 3 lines

group.

Triggers group is used for handling software triggers. To create a

new software

Quoted 9 lines

trigger one must create a directory inside the trigger directory.

Software trigger name MUST follow the following convention:
* <trigger-type>-<trigger-name>
Where:
* <trigger_type>, specifies the interrupt source (e.g: hrtimer)
* <trigger-name>, specifies the IIO device trigger name

Failing to follow this convention will result in an directory

creation error.

Quoted 2 lines

E.g, assuming that hrtimer trigger type is registered with IIO

software

Quoted 2 lines

trigger core:

Quoted 9 lines
Quoted 2 lines
$ mkdir /config/iio/triggers/hrtimer-instance1

Nice, short and clean. Looks pretty good. It's a bit of a shame that we

can't have a per type directory, but if that's how configfs works I guess
there is not much choice.

We could but an intermediate mkdir would be needed from user space which would have odd semantics!

Quoted 50 lines

[...]

Quoted 1 line

+static struct config_group *trigger_make_group(struct config_group

*group,

Quoted 4 lines
drivers/iio/industrialio-configfs.c new file +4 -0
+					       const char *name)
+{
+	char *type_name;
+	char *trigger_name;

drivers/iio/industrialio-configfs.c line 36

Quoted 10 lines
drivers/iio/industrialio-configfs.c new file +10 -0
+	char buf[MAX_NAME_LEN];
+	struct iio_sw_trigger *t;
+
+	snprintf(buf, MAX_NAME_LEN, "%s", name);
+
+	/* group name should have the form <trigger-type>-<trigger-name> */
+	type_name = buf;
+	trigger_name = strchr(buf, '-');
+	if (!trigger_name) {
+		pr_err("Unable to locate '-' in %s. Use <type>-<name>.\n", buf);

Do we want to print this side channel message? Makes it pretty easy to spam
the kernel log with a rouge application.

Quoted 12 lines
drivers/iio/industrialio-configfs.c new file +12 -0
+		return ERR_PTR(-EINVAL);
+	}
+
+	/* replace - with \0, this nicely separates the two strings */
+	*trigger_name = '\0';
+	trigger_name++;
+
+	t = iio_sw_trigger_create(type_name, trigger_name);
+	if (IS_ERR(t))
+		return ERR_CAST(t);
+
+	config_item_set_name(&t->group.cg_item, name);

drivers/iio/industrialio-configfs.c line 58

Quoted 10 lines
drivers/iio/industrialio-configfs.c new file +10 -0
+
+	return &t->group;
+}
+
+static void trigger_drop_group(struct config_group *group,
+			       struct config_item *item)
+{
+	struct iio_sw_trigger *t = to_iio_sw_trigger(item);
+
+	if (t)

t will never be NULL.

Quoted 3 lines
drivers/iio/industrialio-configfs.c new file +3 -0
+		iio_sw_trigger_destroy(t);
+	config_item_put(item);
+}
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
#7 lore raw

Re: [PATCH v5 2/4] iio: core: Introduce IIO configfs support

In reply to Lars-Peter Clausen
Quoted 40 lines · Lars-Peter Clausen
Quoted 14 lines · Daniel Baluta

This creates an IIO configfs subystem named "iio", with a default "triggers"
group.

Triggers group is used for handling software triggers. To create a new software
trigger one must create a directory inside the trigger directory.

Software trigger name MUST follow the following convention:
* <trigger-type>-<trigger-name>
Where:
* <trigger_type>, specifies the interrupt source (e.g: hrtimer)
* <trigger-name>, specifies the IIO device trigger name

Quoted 8 lines

Failing to follow this convention will result in an directory creation error.

E.g, assuming that hrtimer trigger type is registered with IIO software trigger core:

$ mkdir /config/iio/triggers/hrtimer-instance1

Nice, short and clean. Looks pretty good. It's a bit of a shame that we can't have a per type directory, but if that's how configfs works I guess there is not much choice.

[...]

Quoted 11 lines

+static struct config_group *trigger_make_group(struct config_group *group,

drivers/iio/industrialio-configfs.c new file +9 -0
+                           const char *name)
+{
+    char *type_name;
+    char *trigger_name;
+    char buf[MAX_NAME_LEN];
+    struct iio_sw_trigger *t;
+
+    snprintf(buf, MAX_NAME_LEN, "%s", name);
+
Quoted 8 lines

drivers/iio/industrialio-configfs.c line 36

Quoted 5 lines
drivers/iio/industrialio-configfs.c new file +5 -0
+    /* group name should have the form <trigger-type>-<trigger-name> */
+    type_name = buf;
+    trigger_name = strchr(buf, '-');
+    if (!trigger_name) {
+        pr_err("Unable to locate '-' in %s. Use <type>-<name>.\n", buf);

Do we want to print this side channel message? Makes it pretty easy to spam the kernel log with a rouge application.

I think this is useful, people can get crazy for random -EINVAL errors :). Also the same is done in drivers/usb/gadget/configfs.c.

Quoted 17 lines
Quoted 17 lines
drivers/iio/industrialio-configfs.c new file +16 -0
+        return ERR_PTR(-EINVAL);
+    }
+
+    /* replace - with \0, this nicely separates the two strings */
+    *trigger_name = '\0';
+    trigger_name++;
+
+    t = iio_sw_trigger_create(type_name, trigger_name);
+    if (IS_ERR(t))
+        return ERR_CAST(t);
+
+    config_item_set_name(&t->group.cg_item, name);
+
+    return &t->group;
+}
+
Quoted 8 lines

drivers/iio/industrialio-configfs.c line 58

Quoted 6 lines
drivers/iio/industrialio-configfs.c new file +6 -0
+static void trigger_drop_group(struct config_group *group,
+                   struct config_item *item)
+{
+    struct iio_sw_trigger *t = to_iio_sw_trigger(item);
+
+    if (t)

t will never be NULL.

Agree, will fix in v6.

Quoted 5 lines
Quoted 4 lines
drivers/iio/industrialio-configfs.c new file +3 -0
+        iio_sw_trigger_destroy(t);
+    config_item_put(item);
+}
#8 lore raw

PATCH v5 3/4 iio: trigger: Introduce IIO hrtimer based trigger

In reply to Daniel Baluta

This patch registers a new IIO software trigger interrupt source based on high resolution timers.

Notice that if configfs is enabled we create sampling_frequency attribute allowing users to change hrtimer period (1/sampling_frequency).

The IIO hrtimer trigger has a long history, this patch is based on an older version from Marten and Lars-Peter.

---
 drivers/iio/trigger/Kconfig            |   9 ++
 drivers/iio/trigger/Makefile           |   2 +
 drivers/iio/trigger/iio-trig-hrtimer.c | 201 +++++++++++++++++++++++++++++++++
 3 files changed, 212 insertions(+)
 create mode 100644 drivers/iio/trigger/iio-trig-hrtimer.c
drivers/iio/trigger/Kconfig +9 -0
index 7999612..454665a 100644
@@ -5,6 +5,15 @@
 
 menu "Triggers - standalone"
 
+config IIO_HRTIMER_TRIGGER
+	tristate "High resolution timer trigger"
+	select IIO_SW_TRIGGER
+	help
+	  Provides a frequency based IIO trigger using hrtimers.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called iio-trig-hrtimer.
+
 config IIO_INTERRUPT_TRIGGER
 	tristate "Generic interrupt trigger"
 	help
drivers/iio/trigger/Makefile +2 -0
index 0694dae..fe06eb5 100644
@@ -3,5 +3,7 @@
 #
 
 # When adding new entries keep the list in alphabetical order
+
+obj-$(CONFIG_IIO_HRTIMER_TRIGGER) += iio-trig-hrtimer.o
 obj-$(CONFIG_IIO_INTERRUPT_TRIGGER) += iio-trig-interrupt.o
 obj-$(CONFIG_IIO_SYSFS_TRIGGER) += iio-trig-sysfs.o
drivers/iio/trigger/iio-trig-hrtimer.c new file +201 -0

201 lines not on this page · raw message

Signature · 1 line
1.9.1
#9 lore raw

Re: [PATCH v5 3/4] iio: trigger: Introduce IIO hrtimer based trigger

On 05/04/2015 12:50 PM, Daniel Baluta wrote:
[...]

drivers/iio/trigger/iio-trig-hrtimer.c line 76

Quoted 3 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +3 -0
+IIO_HRTIMER_INFO_ATTR(sampling_frequency, S_IRUGO | S_IWUSR,
+		      iio_hrtimer_info_show_sampling_frequency,
+		      iio_hrtimer_info_store_sampling_frequency);

I wonder if the sampling frequency should be configurable the regular IIO API, just like any other IIO device. But things like min/max sampling frequency should be configured in configfs.

[...]

Quoted 2 lines
(quoted diff) +2 -0
+#endif /* CONFIGFS_FS */
+

[...]

Quoted 2 lines
(quoted diff) +2 -0
+static struct iio_sw_trigger *iio_trig_hrtimer_probe(const char *name)
+{

[...]

drivers/iio/trigger/iio-trig-hrtimer.c line 160

Quoted 4 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +4 -0
+#ifdef CONFIG_CONFIGFS_FS
+	config_group_init_type_name(&trig_info->swt.group, name,
+				    &iio_hrtimer_type);
+#endif

This should probably have a helper function in the sw trigger core, that gets stubbed out when CONFIG_FS is disabled. Otherwise we'll see the same #ifdef in every software trigger driver. [...]

drivers/iio/trigger/iio-trig-hrtimer.c line 179

Quoted 12 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +12 -0
+}
+
+static int iio_trig_hrtimer_remove(struct iio_sw_trigger *swt)
+{
+	struct iio_hrtimer_info *trig_info;
+
+	trig_info = iio_trigger_get_drvdata(swt->trigger);
+
+	hrtimer_cancel(&trig_info->timer);
+
+	iio_trigger_unregister(swt->trigger);
+	iio_trigger_free(swt->trigger);

There is a bit of a race condition here. hrtimer_cancel() should be called between unregister and free, otherwise it might be re-armed before it is unregistered.

drivers/iio/trigger/iio-trig-hrtimer.c line 185

Quoted 6 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +6 -0
+	kfree(trig_info);
+
+	return 0;
+}
+
+struct iio_sw_trigger_ops iio_trig_hrtimer_ops = {

const

Quoted 3 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +3 -0
+	.probe		= iio_trig_hrtimer_probe,
+	.remove		= iio_trig_hrtimer_remove,
+};

[...]

maintainer
#10 lore raw

Re: [PATCH v5 3/4] iio: trigger: Introduce IIO hrtimer based trigger

Quoted 10 lines · Lars-Peter Clausen

On 05/04/2015 12:50 PM, Daniel Baluta wrote:
[...]

drivers/iio/trigger/iio-trig-hrtimer.c line 76

Quoted 3 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +3 -0
+IIO_HRTIMER_INFO_ATTR(sampling_frequency, S_IRUGO | S_IWUSR,
+		      iio_hrtimer_info_show_sampling_frequency,
+		      iio_hrtimer_info_store_sampling_frequency);

I wonder if the sampling frequency should be configurable the regular IIO
API, just like any other IIO device. But things like min/max sampling frequency should be configured in configfs.

Would have to be in the trigger dir rather than device... Makes sense to put it there. Limits on it here seem like a sensible idea.

Quoted 57 lines

[...]

Quoted 2 lines
(quoted diff) +2 -0
+#endif /* CONFIGFS_FS */
+

[...]

Quoted 1 line

+static struct iio_sw_trigger *iio_trig_hrtimer_probe(const char

*name)

Quoted 1 line

+{

[...]

drivers/iio/trigger/iio-trig-hrtimer.c line 160

Quoted 4 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +4 -0
+#ifdef CONFIG_CONFIGFS_FS
+	config_group_init_type_name(&trig_info->swt.group, name,
+				    &iio_hrtimer_type);
+#endif

This should probably have a helper function in the sw trigger core, that
gets stubbed out when CONFIG_FS is disabled. Otherwise we'll see the same
#ifdef in every software trigger driver.
[...]

drivers/iio/trigger/iio-trig-hrtimer.c line 179

Quoted 12 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +12 -0
+}
+
+static int iio_trig_hrtimer_remove(struct iio_sw_trigger *swt)
+{
+	struct iio_hrtimer_info *trig_info;
+
+	trig_info = iio_trigger_get_drvdata(swt->trigger);
+
+	hrtimer_cancel(&trig_info->timer);
+
+	iio_trigger_unregister(swt->trigger);
+	iio_trigger_free(swt->trigger);

There is a bit of a race condition here. hrtimer_cancel() should be called
between unregister and free, otherwise it might be re-armed before it is
unregistered.

drivers/iio/trigger/iio-trig-hrtimer.c line 185

Quoted 6 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +6 -0
+	kfree(trig_info);
+
+	return 0;
+}
+
+struct iio_sw_trigger_ops iio_trig_hrtimer_ops = {

const

drivers/iio/trigger/iio-trig-hrtimer.c line 188

Quoted 3 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +3 -0
+	.probe		= iio_trig_hrtimer_probe,
+	.remove		= iio_trig_hrtimer_remove,
+};

[...]

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
#11 lore raw

Re: [PATCH v5 3/4] iio: trigger: Introduce IIO hrtimer based trigger

Quoted 13 lines · Jonathan Cameron
Quoted 10 lines · Lars-Peter Clausen

On 05/04/2015 12:50 PM, Daniel Baluta wrote:
[...]

drivers/iio/trigger/iio-trig-hrtimer.c line 76

Quoted 3 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +3 -0
+IIO_HRTIMER_INFO_ATTR(sampling_frequency, S_IRUGO | S_IWUSR,
+		      iio_hrtimer_info_show_sampling_frequency,
+		      iio_hrtimer_info_store_sampling_frequency);

I wonder if the sampling frequency should be configurable the regular IIO
API, just like any other IIO device. But things like min/max sampling frequency should be configured in configfs.

Quoted 2 lines

Would have to be in the trigger dir rather than device... Makes sense to put it there. Limits on it here seem like a sensible idea.

But then each trigger will have sampling_frequency right? This is not what we want.

Quoted 9 lines
Quoted 9 lines

[...]

Quoted 2 lines
(quoted diff) +2 -0
+#endif /* CONFIGFS_FS */
+

[...]

Quoted 1 line

+static struct iio_sw_trigger *iio_trig_hrtimer_probe(const char

*name)

Quoted 1 line

+{

[...]

Quoted 11 lines
Quoted 11 lines

drivers/iio/trigger/iio-trig-hrtimer.c line 160

Quoted 4 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +4 -0
+#ifdef CONFIG_CONFIGFS_FS
+	config_group_init_type_name(&trig_info->swt.group, name,
+				    &iio_hrtimer_type);
+#endif

This should probably have a helper function in the sw trigger core, that
gets stubbed out when CONFIG_FS is disabled. Otherwise we'll see the same
#ifdef in every software trigger driver.
[...]

Agree with this. Will fix.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +10 -0
+}
+
+static int iio_trig_hrtimer_remove(struct iio_sw_trigger *swt)
+{
+	struct iio_hrtimer_info *trig_info;
+
+	trig_info = iio_trigger_get_drvdata(swt->trigger);
+
+	hrtimer_cancel(&trig_info->timer);
+
Quoted 8 lines
Quoted 8 lines

drivers/iio/trigger/iio-trig-hrtimer.c line 179

Quoted 2 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +2 -0
+	iio_trigger_unregister(swt->trigger);
+	iio_trigger_free(swt->trigger);

There is a bit of a race condition here. hrtimer_cancel() should be called
between unregister and free, otherwise it might be re-armed before it is
unregistered.

So this can be re-armed only if the buffer is re-enabled between hrtimer_cancel and iio_trigger_unregister :). I'm trying to understand how the race can happen.

Quoted 9 lines
Quoted 9 lines

drivers/iio/trigger/iio-trig-hrtimer.c line 185

Quoted 7 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +6 -0
+	kfree(trig_info);
+
+	return 0;
+}
+
+struct iio_sw_trigger_ops iio_trig_hrtimer_ops = {

const

Agree.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +3 -0
+	.probe		= iio_trig_hrtimer_probe,
+	.remove		= iio_trig_hrtimer_remove,
+};

[...]

maintainer
#12 lore raw

Re: [PATCH v5 3/4] iio: trigger: Introduce IIO hrtimer based trigger

Quoted 12 lines · Daniel Baluta
Quoted 9 lines · Jonathan Cameron
Quoted 6 lines · Lars-Peter Clausen

On 05/04/2015 12:50 PM, Daniel Baluta wrote:
[...]

Quoted 3 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +3 -0
+IIO_HRTIMER_INFO_ATTR(sampling_frequency, S_IRUGO | S_IWUSR,
+              iio_hrtimer_info_show_sampling_frequency,
+              iio_hrtimer_info_store_sampling_frequency);
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

I wonder if the sampling frequency should be configurable the regular IIO
API, just like any other IIO device. But things like min/max sampling frequency should be configured in configfs.

Would have to be in the trigger dir rather than device... Makes sense to put it there. Limits on it here seem like a sensible idea.

But then each trigger will have sampling_frequency right? This is not what we want.

I'm confused now. Why not? Each hrtimer trigger created in configfs should have it's own sampling frequency should it not?

Quoted 62 lines
Quoted 10 lines
Quoted 10 lines

[...]

Quoted 2 lines
(quoted diff) +2 -0
+#endif /* CONFIGFS_FS */
+

[...]

Quoted 1 line

+static struct iio_sw_trigger *iio_trig_hrtimer_probe(const char

*name)

Quoted 1 line

+{

[...]

Quoted 11 lines
Quoted 11 lines

drivers/iio/trigger/iio-trig-hrtimer.c line 160

Quoted 4 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +4 -0
+#ifdef CONFIG_CONFIGFS_FS
+    config_group_init_type_name(&trig_info->swt.group, name,
+                    &iio_hrtimer_type);
+#endif

This should probably have a helper function in the sw trigger core, that
gets stubbed out when CONFIG_FS is disabled. Otherwise we'll see the same
#ifdef in every software trigger driver.
[...]

Agree with this. Will fix.

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +10 -0
+}
+
+static int iio_trig_hrtimer_remove(struct iio_sw_trigger *swt)
+{
+    struct iio_hrtimer_info *trig_info;
+
+    trig_info = iio_trigger_get_drvdata(swt->trigger);
+
+    hrtimer_cancel(&trig_info->timer);
+
Quoted 8 lines
Quoted 8 lines

drivers/iio/trigger/iio-trig-hrtimer.c line 179

Quoted 2 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +2 -0
+    iio_trigger_unregister(swt->trigger);
+    iio_trigger_free(swt->trigger);

There is a bit of a race condition here. hrtimer_cancel() should be called
between unregister and free, otherwise it might be re-armed before it is
unregistered.

So this can be re-armed only if the buffer is re-enabled between hrtimer_cancel and iio_trigger_unregister :). I'm trying to understand how the race can happen.

Quoted 9 lines
Quoted 9 lines

drivers/iio/trigger/iio-trig-hrtimer.c line 185

Quoted 7 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +6 -0
+    kfree(trig_info);
+
+    return 0;
+}
+
+struct iio_sw_trigger_ops iio_trig_hrtimer_ops = {

const

Agree.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +3 -0
+    .probe        = iio_trig_hrtimer_probe,
+    .remove        = iio_trig_hrtimer_remove,
+};

[...]

#13 lore raw

Re: [PATCH v5 3/4] iio: trigger: Introduce IIO hrtimer based trigger

Quoted 17 lines · Jonathan Cameron
Quoted 16 lines · Daniel Baluta
Quoted 13 lines · Jonathan Cameron
Quoted 10 lines · Lars-Peter Clausen

On 05/04/2015 12:50 PM, Daniel Baluta wrote:
[...]

drivers/iio/trigger/iio-trig-hrtimer.c line 76

Quoted 3 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +3 -0
+IIO_HRTIMER_INFO_ATTR(sampling_frequency, S_IRUGO | S_IWUSR,
+              iio_hrtimer_info_show_sampling_frequency,
+              iio_hrtimer_info_store_sampling_frequency);

I wonder if the sampling frequency should be configurable the regular IIO
API, just like any other IIO device. But things like min/max sampling frequency should be configured in configfs.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Would have to be in the trigger dir rather than device... Makes sense to put it there. Limits on it here seem like a sensible idea.

But then each trigger will have sampling_frequency right? This is not what we want.

I'm confused now. Why not? Each hrtimer trigger created in configfs should have it's own sampling frequency should it not?

I was referring to triggers in general, not just hrtimer triggers.

But I see now that we can set trig->dev.groups to point to our specific attributes. This
should work.

Anyhow, I'm not convinced that sampling_frequency should be configured from sysfs.
We create the trigger from configfs:

$ mkdir /config/triggers/hrtimer-instance0

Then, likely we have to do something like this:

$ echo 100 > /sys/bus/iio/trigger7/sampling_frequency

How is the user application going to know which is the exact directory for hrtimer-instance0 ?

Daniel.

maintainer
#14 lore raw

Re: [PATCH v5 3/4] iio: trigger: Introduce IIO hrtimer based trigger

Quoted 37 lines · Daniel Baluta
Quoted 17 lines · Jonathan Cameron
Quoted 16 lines · Daniel Baluta
Quoted 13 lines · Jonathan Cameron
Quoted 10 lines · Lars-Peter Clausen

On 05/04/2015 12:50 PM, Daniel Baluta wrote:
[...]

drivers/iio/trigger/iio-trig-hrtimer.c line 76

Quoted 3 lines
drivers/iio/trigger/iio-trig-hrtimer.c new file +3 -0
+IIO_HRTIMER_INFO_ATTR(sampling_frequency, S_IRUGO | S_IWUSR,
+              iio_hrtimer_info_show_sampling_frequency,
+              iio_hrtimer_info_store_sampling_frequency);

I wonder if the sampling frequency should be configurable the regular IIO
API, just like any other IIO device. But things like min/max sampling frequency should be configured in configfs.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Would have to be in the trigger dir rather than device... Makes sense to put it there. Limits on it here seem like a sensible idea.

But then each trigger will have sampling_frequency right? This is not what we want.

I'm confused now. Why not? Each hrtimer trigger created in configfs should have it's own sampling frequency should it not?

I was referring to triggers in general, not just hrtimer triggers.

But I see now that we can set trig->dev.groups to point to our specific attributes. This
should work.

Anyhow, I'm not convinced that sampling_frequency should be configured from sysfs.
We create the trigger from configfs:

$ mkdir /config/triggers/hrtimer-instance0
Quoted 9 lines

Then, likely we have to do something like this:

$ echo 100 > /sys/bus/iio/trigger7/sampling_frequency

How is the user application going to know which is the exact directory for hrtimer-instance0 ?

Daniel.

Find it by name like we normally do?

J

#15 lore raw

Re: [PATCH v5 3/4] iio: trigger: Introduce IIO hrtimer based trigger

Quoted 40 lines · Jonathan Cameron
Quoted 39 lines · Daniel Baluta
Quoted 17 lines · Jonathan Cameron
Quoted 16 lines · Daniel Baluta
Quoted 13 lines · Jonathan Cameron
Quoted 10 lines · Lars-Peter Clausen

On 05/04/2015 12:50 PM, Daniel Baluta wrote:
[...]

Review

Quoted 3 lines
(quoted diff) +3 -0
+IIO_HRTIMER_INFO_ATTR(sampling_frequency, S_IRUGO | S_IWUSR,
+              iio_hrtimer_info_show_sampling_frequency,
+              iio_hrtimer_info_store_sampling_frequency);

I wonder if the sampling frequency should be configurable the regular IIO
API, just like any other IIO device. But things like min/max sampling frequency should be configured in configfs.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Would have to be in the trigger dir rather than device... Makes sense to put it there. Limits on it here seem like a sensible idea.

But then each trigger will have sampling_frequency right? This is not what we want.

I'm confused now. Why not? Each hrtimer trigger created in configfs should have it's own sampling frequency should it not?

I was referring to triggers in general, not just hrtimer triggers.

But I see now that we can set trig->dev.groups to point to our specific attributes. This
should work.

Anyhow, I'm not convinced that sampling_frequency should be configured from sysfs.
We create the trigger from configfs:

$ mkdir /config/triggers/hrtimer-instance0

Then, likely we have to do something like this:

Quoted 8 lines
Quoted 7 lines
$ echo 100 > /sys/bus/iio/trigger7/sampling_frequency

How is the user application going to know which is the exact directory for hrtimer-instance0 ?

Daniel.

Find it by name like we normally do?

Ok :). I will move this to sysfs and send v6.

thanks,
Daniel.

#16 lore raw

Re: [PATCH v5 3/4] iio: trigger: Introduce IIO hrtimer based trigger

Quoted 43 lines · Daniel Baluta
Quoted 42 lines · Jonathan Cameron
Quoted 41 lines · Daniel Baluta
Quoted 17 lines · Jonathan Cameron
Quoted 16 lines · Daniel Baluta
Quoted 13 lines · Jonathan Cameron
Quoted 10 lines · Lars-Peter Clausen

On 05/04/2015 12:50 PM, Daniel Baluta wrote:
[...]

Review

Quoted 3 lines
(quoted diff) +3 -0
+IIO_HRTIMER_INFO_ATTR(sampling_frequency, S_IRUGO | S_IWUSR,
+              iio_hrtimer_info_show_sampling_frequency,
+              iio_hrtimer_info_store_sampling_frequency);

I wonder if the sampling frequency should be configurable the regular IIO
API, just like any other IIO device. But things like min/max sampling frequency should be configured in configfs.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Would have to be in the trigger dir rather than device... Makes sense to put it there. Limits on it here seem like a sensible idea.

But then each trigger will have sampling_frequency right? This is not what we want.

I'm confused now. Why not? Each hrtimer trigger created in configfs should have it's own sampling frequency should it not?

I was referring to triggers in general, not just hrtimer triggers.

But I see now that we can set trig->dev.groups to point to our specific attributes. This
should work.

Anyhow, I'm not convinced that sampling_frequency should be configured from sysfs.
We create the trigger from configfs:

$ mkdir /config/triggers/hrtimer-instance0

Then, likely we have to do something like this:

$ echo 100 > /sys/bus/iio/trigger7/sampling_frequency
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

How is the user application going to know which is the exact directory for hrtimer-instance0 ?

Daniel.

Find it by name like we normally do?

Ok :). I will move this to sysfs and send v6.

If you add the min/max properties you could still control the frequency via configfs by setting min and max to the same. In that case the sysfs property would merely inform applications about the currently selected frequency.

- Lars

#17 lore raw

PATCH v5 4/4 iio: Documentation: Add IIO configfs documentation

In reply to Daniel Baluta
---
 Documentation/ABI/testing/configfs-iio | 26 ++++++++++++++
 Documentation/iio/iio_configfs.txt     | 63 ++++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+)
 create mode 100644 Documentation/ABI/testing/configfs-iio
 create mode 100644 Documentation/iio/iio_configfs.txt
Documentation/ABI/testing/configfs-iio new file +26 -0
new file mode 100644
index 0000000..a143135
@@ -0,0 +1,26 @@
+What:		/config/iio
+Date:		May 2015
+KernelVersion:	4.2
+Contact:	[email protected]
+Description:
+		This represents Industrial IO configuration entry point
+		directory. It contains sub-groups corresponding to IIO
+		objects.
+
+What:		/config/iio/triggers
+Date:		May 2015
+KernelVersion:	4.2
+Description:
+		Industrial IO software triggers directory.
+
+What:		/config/iio/triggers/hrtimer-name
+Date:		May 2015
+KernelVersion:	4.2
+Description:
+		High resolution timer instance.
+
+What:		/config/iio/triggers/hrtimer-name/sampling_frequency
+Date:		May 2015
+KernelVersion:	4.2
+Description:
+		Sampling frequency for this hrtimer instance.
Documentation/iio/iio_configfs.txt new file +63 -0

63 lines not on this page · raw message

Signature · 1 line
1.9.1