IIO: in kernel pull interfaces.
Subsystems (6)
Jonathan Cameron
maintainerv5 cover IIO: in kernel pull interfaces.
Hi All,
Firstly this is an RFC rather than a final proposal because I know there is an issue with the provider being removed before the consumer. It will be easy to make this less likely to happen, but I am not entirely sure how to avoid any possible race (suggestion welcome).
Greg KH raised significant issues with how I originally proposed doing this map registration (consumer - provider association). Hence this version is a lot more conventional (you may well notice that even the header naming is lifted from the regulator framework). The original proposal registered this mapping completely independent of the iio drivers, thus requiring no in driver changes. This version requires passing the mapping through them. There are advantages to both approaches and we can always bolt the driver independent version back in if there is sufficient justification for it at a later date.
Note that this series is against the full IIO tree in staging.
All comments welcome.
Jonathan
Jonathan Cameron (5):
staging:iio:core add in kernel interface mapping and getting IIO
channels.
staging:iio: move iio data return types into types.h for use by
inkern
staging:iio::hwmon interface client driver. staging:iio:Documentation in kernel pull description.
stargate2: example of map configuration for iio to hwmon example.
arch/arm/mach-pxa/stargate2.c | 22 ++ drivers/staging/iio/Documentation/inkernel.txt | 59 ++++++ drivers/staging/iio/Kconfig | 16 ++- drivers/staging/iio/Makefile | 4 +- drivers/staging/iio/consumer.h | 103 ++++++++++ drivers/staging/iio/driver.h | 34 +++ drivers/staging/iio/iio.h | 6 - drivers/staging/iio/iio_core.h | 3 + drivers/staging/iio/iio_hwmon.c | 226 +++++++++++++++++++++ drivers/staging/iio/industrialio-core.c | 2 +- drivers/staging/iio/inkern.c | 256 ++++++++++++++++++++++++ drivers/staging/iio/machine.h | 30 +++ drivers/staging/iio/types.h | 4 + 13 files changed, 756 insertions(+), 9 deletions(-) create mode 100644 drivers/staging/iio/Documentation/inkernel.txt create mode 100644 drivers/staging/iio/consumer.h create mode 100644 drivers/staging/iio/driver.h create mode 100644 drivers/staging/iio/iio_hwmon.c create mode 100644 drivers/staging/iio/inkern.c create mode 100644 drivers/staging/iio/machine.h
Signature · 1 line
1.7.8.4
Jonathan Cameron
maintainerPATCH v5 1/5 staging:iio:core add in kernel interface mapping and getting IIO channels.
From: Jonathan Cameron <[email protected]>
Lifted from proposal for in kernel interface built on the out of staging branch.
Two elements here:
* Map as defined in "inkern.h"
* Matching code to actually get the iio_dev and channel that we want from the global list of IIO devices.
V2: As per Greg KH suggestion, move over to registration by passing the tables into the provider drivers (how regulator does it). This does not prevent us using the original more flexible approach if at a later date there is a usecase that demands it.
--- drivers/staging/iio/Kconfig | 7 +- drivers/staging/iio/Makefile | 2 +- drivers/staging/iio/consumer.h | 103 +++++++++++++ drivers/staging/iio/driver.h | 34 ++++ drivers/staging/iio/iio_core.h | 3 + drivers/staging/iio/industrialio-core.c | 2 +- drivers/staging/iio/inkern.c | 256 +++++++++++++++++++++++++++++++ drivers/staging/iio/machine.h | 30 ++++ 8 files changed, 434 insertions(+), 3 deletions(-)
drivers/staging/iio/Kconfig +6 -1
@@ -10,8 +10,14 @@ menuconfig IIO drivers for many different types of embedded sensors using a number of different physical interfaces (i2c, spi, etc). See drivers/staging/iio/Documentation for more information. + if IIO +config IIO_INKERN + bool "In kernel support for IIO" + help + Support in kernel users of IIO device drivers. + config IIO_BUFFER bool "Enable buffer support within IIO" help
@@ -96,5 +102,4 @@ config IIO_SIMPLE_DUMMY_BUFFER Add buffered data capture to the simple dummy driver. endif # IIO_SIMPLE_DUMMY - endif # IIO
drivers/staging/iio/Makefile +1 -1
@@ -1,9 +1,9 @@ # # Makefile for the industrial I/O core. # - obj-$(CONFIG_IIO) += industrialio.o industrialio-y := industrialio-core.o industrialio-event.o +industrialio-$(CONFIG_IIO_INKERN) += inkern.o industrialio-$(CONFIG_IIO_BUFFER) += industrialio-buffer.o industrialio-$(CONFIG_IIO_TRIGGER) += industrialio-trigger.o
drivers/staging/iio/consumer.h new file +103 -0
103 lines not on this page · raw message
drivers/staging/iio/driver.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Industrial I/O in kernel access map interface. +* +* Copyright (c) 2011 Jonathan Cameron +* +* 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. +*/ + +#ifndef _IIO_INKERN_H_ +#define _IIO_INKERN_H_ + +struct iio_map ; + +/** +* iio_map_array_register() - tell the core about inkernel consumers +* @indio_dev: provider device +* @map: array of mappings specifying association of channel with client +*/ +int iio_map_array_register (struct iio_dev *indio_dev, +struct iio_map *map); + +/** +* iio_map_array_unregister() - tell the core to remove consumer mappings +* @indio_dev: provider device +* @map: array of mappings to remove. Note these must have same memory +* addresses as those originally added not just equal parameter +* values. +*/ +int iio_map_array_unregister (struct iio_dev *indio_dev, +struct iio_map *map); + +#endif
drivers/staging/iio/iio_core.h +3 -0
@@ -12,6 +12,9 @@#ifndef _IIO_CORE_H_#define _IIO_CORE_H_ +#include <linux/device.h> + +extern struct device_type iio_dev_type; int __iio_add_chan_devattr(const char *postfix, struct iio_chan_spec const *chan,
drivers/staging/iio/industrialio-core.c +1 -1
@@ -567,7 +567,7 @@ static void iio_dev_release(struct device *device)iio_device_unregister_sysfs (indio_dev); } -static struct device_type iio_dev_type = { +struct device_type iio_dev_type = { .name ="iio_device" , .release = iio_dev_release, };
drivers/staging/iio/inkern.c new file +256 -0
256 lines not on this page · raw message
drivers/staging/iio/machine.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Industrial I/O in kernel access map definitions for board files. +* +* Copyright (c) 2011 Jonathan Cameron +* +* 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. +*/ + +/** +* struct iio_map - description of link between consumer and device channels +* @adc_channel_label: Label used to identify the channel on the provider. +* This is matched against the datasheet_name element +* of struct iio_chan_spec. +* @consumer_dev: Pointer to device structure for the consumer. +* Either this or consumer_dev_name must be supplied +* to allow the consumer to be identified. +* @consumer_dev_name: Name to uniquely identify the consumer if the +* device pointer is not available when registering this +* mapping. +* @consumer_channel: Unique name used to idenitify the channel on the +* consumer side. +*/ +struct iio_map { +const char *adc_channel_label; +struct device *consumer_dev; +const char *consumer_dev_name; +const char *consumer_channel; +};
Signature · 1 line
1.7.8.4
Re: [PATCH 1/5] staging:iio:core add in kernel interface mapping and getting IIO channels.
drivers/staging/iio/industrialio-core.c static void iio_dev_release(struct device *device) · line 573
Quoted 5 lines · Jonathan Cameron
drivers/staging/iio/industrialio-core.c +1
-1-static struct device_type iio_dev_type = { +struct device_type iio_dev_type = { .name ="iio_device" , .release = iio_dev_release, };
Why is this exported?
drivers/staging/iio/inkern.c line 37
Quoted 3 lines
drivers/staging/iio/inkern.c new file +3
-0+mutex_lock (&iio_map_list_lock); +while ((maps[i].consumer_dev !=NULL ) || + (maps[i].consumer_dev_name !=NULL )) {
I'd suggest just dropping the struct device - the reason we support the struct device directly in the regulator API is that we originally had only a struct device and kept the code around as a transition measure (though now it's so old we should be able to kill it off). This would simplify the code and the interface a bit.
Jonathan Cameron
maintainerRe: [PATCH 1/5] staging:iio:core add in kernel interface mapping and getting IIO channels.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 7 lines · Mark Brown
Quoted 3 lines · Jonathan Cameron
-static struct
device_typeiio_dev_type= { +structdevice_typeiio_dev_type= { .name = "iio_device", .release =iio_dev_release, };Why is this exported?
oops. Hangover from previous version I think. Thanks for pointing it out.
Quoted 10 lines
Quoted 3 lines
(quoted diff) +1
-0+ mutex_lock(&iio_map_list_lock); + while ((maps[i].consumer_dev!= NULL) || + (maps[i].consumer_dev_name != NULL)) {
I'd suggest just dropping the struct device - the reason we support the struct device directly in the regulator API is that we originally had only a struct device and kept the code around as a transition measure (though now it's so old we should be able to kill it off). This would simplify the code and the interface a bit.
Ah, that explains your comment on the 5th patch. Alright, I'll let this sit for a few days and if no one comes up with a good reason not to we'll go with just the dev_name option.
Jonathan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJPJv2CAAoJEFSFNJnE9BaIfRYP/R9nGQIY7sCm4UsdBZldyW93 8Eu0jPMXJs/YLgc7zSJisFqUQNS4BJjORVDh2AcV/hu7FXaxtD6QhxaC3/RMjwfa EgElSYU7N2yPThJLXh1w12qgvt6+zxAT+Gnv11pHeaf6gZrXU2IUBy1FlExCudpI hc+CnDSSHjZk6aJKWmockmcmwlSGLy4WV7nH4S907pzm2yXnI9UqvVaHwPVtO/Yl rZyrZo6T8C4Xw2GeB5QdZ4GNXRuNUOezc1OfqdK/FKj3lVo23ZsAfoMoKkS33ZWF zjU8deSJY6VSYhfJtnfv7ucv5GjjhbuWSGZP0VD/BR+eTjWD54EasVv5AqwOz/Iz wwbvanHTqsVrEBU76733wvWRFelZXgzYhFoQYEucQB5F4KCtqO1OTi62stDCXLLR Z9ygHH92t7TlsKbxaMGL8gU7jGDeIytuHgJW2BXd8ekwQr4fdY7eBwoW4A+TRSKl rCNSp5iuKIXjyQ8ZJviOKXlZDJa2/5mYuDO8juQFcYshe+X29pbsrybLPkBBKdhl GxOi8DtiMVPCiHB63bKGXhqe38jNeHK0hboiREHZgnEt1/a+ZkLDVnWtLQcUBuBo UfLfuzQju/DrtqnWj8asmRzpsA675Lh1xmdLU0tv/NEb/aOGnIAy3+BAhhiq2g1w OU87P/vuWQrgl1D/jUEh
=l3HK
-----END PGP SIGNATURE-----
Re: [PATCH 1/5] staging:iio:core add in kernel interface mapping and getting IIO channels.
Quoted 4 lines · Jonathan Cameron
Quoted 3 lines · Mark Brown
Quoted 1 line · Jonathan Cameron
+ =A0 =A0mutex_lock(&iio_map_list_lock); + =A0 =A0 =A0 while ((maps[i].=
consumer_dev
Quoted 1 line
Quoted 1 line
Quoted 1 line
!=3D NULL) || + =A0 =A0 =A0 =A0 =A0 =A0 =A0 (maps[i].consumer_dev_name =
!=3D NULL)) {
Quoted 9 lines
Quoted 7 lines
I'd suggest just dropping the struct device - the reason we support the struct device directly in the regulator API is that we originally had only a struct device and kept the code around as a transition measure (though now it's so old we should be able to kill it off). =A0This would simplify the code and the interface a bit.
Ah, that explains your comment on the 5th patch. =A0Alright, I'll let thi=
s
Quoted 2 lines
sit for a few days and if no one comes up with a good reason not to we'll go with just the
dev_nameoption.
I've just deleted the yse of struct device * from the pin control subsystem and I bet ark will have it deleted from regulator_consumer before long, so just let it go :-)
Thanks,
Linus Walleij
Jonathan Cameron
maintainerRe: [PATCH 1/5] staging:iio:core add in kernel interface mapping and getting IIO channels.
Quoted 14 lines · Linus Walleij
Quoted 13 lines · Jonathan Cameron
Quoted 11 lines · Mark Brown
Quoted 2 lines · Jonathan Cameron
+
mutex_lock(&iio_map_list_lock); + while ((maps[i].consumer_dev
!= NULL) || + (maps[i].consumer_dev_name != NULL)) {I'd suggest just dropping the struct device - the reason we support the struct device directly in the regulator API is that we originally had only a struct device and kept the code around as a transition measure (though now it's so old we should be able to kill it off). This would simplify the code and the interface a bit.
Quoted 8 lines
Quoted 3 lines
Ah, that explains your comment on the 5th patch. Alright, I'll let this sit for a few days and if no one comes up with a good reason not to we'll go with just the
dev_nameoption.I've just deleted the yse of struct device * from the pin control subsystem and I bet ark will have it deleted from
regulator_consumerbefore long, so just let it go :-)
struct device * use removed from IIO, but I won't be posting just yet as something has borked my i2c that'll need tracking down before I can test an updated version.
For reference in the meantime, the other change is that the iio_device_unregister sets the info pointer to NULL, thus providing a convenient way of knowing the parent device has gone away without i think allowing for any raceconditions (this will happen before the bus unregister which was what was causing me trouble).
Jonathan
Greg KH
maintainerRe: [PATCH 1/5] staging:iio:core add in kernel interface mapping and getting IIO channels.
In reply to Jonathan CameronQuoted 32 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Lifted from proposal for in kernel interface built on the out of staging branch.
Two elements here:
* Map as defined in "inkern.h"
* Matching code to actually get theiio_devand channel that we want from the global list of IIO devices.V2: As per Greg KH suggestion, move over to registration by passing the tables into the provider drivers (how regulator does it). This does not prevent us using the original more flexible approach if at a later date there is a usecase that demands it.
Signed-off-by Jonathan Cameron <[email protected]>--- drivers/staging/iio/Kconfig | 7 +- drivers/staging/iio/Makefile | 2 +- drivers/staging/iio/consumer.h | 103 +++++++++++++ drivers/staging/iio/driver.h | 34 ++++ drivers/staging/iio/iio_core.h | 3 + drivers/staging/iio/industrialio-core.c | 2 +- drivers/staging/iio/inkern.c | 256 +++++++++++++++++++++++++++++++ drivers/staging/iio/machine.h | 30 ++++ 8 files changed, 434 insertions(+), 3 deletions(-)drivers/staging/iio/Kconfig +0
-0
drivers/staging/iio/Kconfig menuconfig IIO · line 19
Quoted 10 lines
drivers/staging/iio/Kconfig +5
-0@@ -10,8 +10,14 @@ menuconfig IIO drivers for many different types of embedded sensors using a number of different physical interfaces (i2c, spi, etc). See drivers/staging/iio/Documentation for more information. + if IIO +config IIO_INKERN + bool "In kernel support for IIO" + help + Support in kernel users of IIO device drivers.
Of course you want this, all of the code in the kernel.org tree is "in kernel users" :)
Seriously, I still fail to understand what is so special here that makes this a totally different design pattern from all other busses, especially when you aren't even a bus at all, but rather a "interface" to userspace for different device types.
Why can't a driver just depend on this interface type, like all other interface types are, that way the built-in vs. as-a-module issues are all handled "automagically" by the config and build system.
confused,
greg k-h
Jonathan Cameron
maintainerRe: [PATCH 1/5] staging:iio:core add in kernel interface mapping and getting IIO channels.
Quoted 47 lines · Greg KH
Quoted 32 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Lifted from proposal for in kernel interface built on the out of staging branch.
Two elements here:
* Map as defined in "inkern.h"
* Matching code to actually get theiio_devand channel that we want from the global list of IIO devices.V2: As per Greg KH suggestion, move over to registration by passing the tables into the provider drivers (how regulator does it). This does not prevent us using the original more flexible approach if at a later date there is a usecase that demands it.
Signed-off-by Jonathan Cameron <[email protected]>--- drivers/staging/iio/Kconfig | 7 +- drivers/staging/iio/Makefile | 2 +- drivers/staging/iio/consumer.h | 103 +++++++++++++ drivers/staging/iio/driver.h | 34 ++++ drivers/staging/iio/iio_core.h | 3 + drivers/staging/iio/industrialio-core.c | 2 +- drivers/staging/iio/inkern.c | 256 +++++++++++++++++++++++++++++++ drivers/staging/iio/machine.h | 30 ++++ 8 files changed, 434 insertions(+), 3 deletions(-)drivers/staging/iio/Kconfig +0
-0drivers/staging/iio/Kconfig menuconfig IIO · line 19
Quoted 10 lines
drivers/staging/iio/Kconfig +5
-0@@ -10,8 +10,14 @@ menuconfig IIO drivers for many different types of embedded sensors using a number of different physical interfaces (i2c, spi, etc). See drivers/staging/iio/Documentation for more information. + if IIO +config IIO_INKERN + bool "In kernel support for IIO" + help + Support in kernel users of IIO device drivers.Of course you want this, all of the code in the kernel.org tree is "in kernel users" :)
Quoted 9 lines
Seriously, I still fail to understand what is so special here that makes this a totally different design pattern from all other busses, especially when you aren't even a bus at all, but rather a "interface" to userspace for different device types.
Why can't a driver just depend on this interface type, like all other interface types are, that way the built-in vs. as-a-module issues are all handled "automagically" by the config and build system.
Best simple comparison is with regulators. They provide voltages to consumers; This iio stuff is about providing readings of voltage (simplifying massively) to other users. All these adc's need their own driver to provide that voltage to those that care. The client drivers just want to ask 'what is the voltage?'.
So to do it as a conventional module dependency we need a separate dependency for every IIO device capable of providing a voltage to every driver that might want to read one.
There are a number of common use cases or which I'll list a few here.
a) Soc adc's. Typical soc might have an 8 channel adc. On a typical board 2 channels are used for input (touchscreen), 2 for monitoring the battery and
4 brought out to an edge connector. Which are used for what and how many of each are used is entirely under control of the board designer. Thus we could have each SoC type adc driver handle the logic necessary to register an input device, a hwmon device (and perhaps an IIO device). This is the usecase that Mark Brown originally brought up. Right now Arnd is blocking some SoC adc drivers that do this internally and sending them in the direction of IIO.
b) High spec devices used for input. This one we originally proposed doing via a bridge in userspace and piping back in via uinput. When I say high spec I meant 300+ dolar imu's etc. People do it for niche systems, but the part will never primarily be used for this so normally sits better in IIO, If we have borderline devices, they will end up in IIO. If this stuff had been in place earlier (as Dmitry pushed for) some of the existing parts in input might never have been accepted.
c) The other side is generating signals. People use arbitary waveform generators to produce inputs for all sort of strange devices.
So the question was whether to sit another subsystem under hwmon, input IIO etc, or to have IIO evolve into that underlying subsystem. Given with the channel mapping stuff we already had all the infrastructure in place to do this, a vague consensus said do it in IIO.
Now in many ways we'd love to have the IIO userspace stuff act as just another client, but that's a way off yet basically due to the huge number of special cases that would need to be handled. I'm personally not yet sure that will ever happen.
So in summary we don't do this as a simple dependency because of the combinatorial explosion in dependencies that would be needed and the connection modules that would be needed to glue it all together vs what is a simple mapping that will sit nicely in device tree etc.
Jonathan
Greg KH
maintainerRe: [PATCH 1/5] staging:iio:core add in kernel interface mapping and getting IIO channels.
Quoted 101 lines · Jonathan Cameron
Quoted 47 lines · Greg KH
Quoted 32 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Lifted from proposal for in kernel interface built on the out of staging branch.
Two elements here:
* Map as defined in "inkern.h"
* Matching code to actually get theiio_devand channel that we want from the global list of IIO devices.V2: As per Greg KH suggestion, move over to registration by passing the tables into the provider drivers (how regulator does it). This does not prevent us using the original more flexible approach if at a later date there is a usecase that demands it.
Signed-off-by Jonathan Cameron <[email protected]>--- drivers/staging/iio/Kconfig | 7 +- drivers/staging/iio/Makefile | 2 +- drivers/staging/iio/consumer.h | 103 +++++++++++++ drivers/staging/iio/driver.h | 34 ++++ drivers/staging/iio/iio_core.h | 3 + drivers/staging/iio/industrialio-core.c | 2 +- drivers/staging/iio/inkern.c | 256 +++++++++++++++++++++++++++++++ drivers/staging/iio/machine.h | 30 ++++ 8 files changed, 434 insertions(+), 3 deletions(-)drivers/staging/iio/Kconfig +0
-0drivers/staging/iio/Kconfig menuconfig IIO · line 19
Quoted 10 lines
drivers/staging/iio/Kconfig +5
-0@@ -10,8 +10,14 @@ menuconfig IIO drivers for many different types of embedded sensors using a number of different physical interfaces (i2c, spi, etc). See drivers/staging/iio/Documentation for more information. + if IIO +config IIO_INKERN + bool "In kernel support for IIO" + help + Support in kernel users of IIO device drivers.Of course you want this, all of the code in the kernel.org tree is "in kernel users" :)
Quoted 9 lines
Seriously, I still fail to understand what is so special here that makes this a totally different design pattern from all other busses, especially when you aren't even a bus at all, but rather a "interface" to userspace for different device types.
Why can't a driver just depend on this interface type, like all other interface types are, that way the built-in vs. as-a-module issues are all handled "automagically" by the config and build system.
Best simple comparison is with regulators. They provide voltages to consumers; This iio stuff is about providing readings of voltage (simplifying massively) to other users. All these adc's need their own driver to provide that voltage to those that care. The client drivers just want to ask 'what is the voltage?'.
So to do it as a conventional module dependency we need a separate dependency for every IIO device capable of providing a voltage to every driver that might want to read one.
There are a number of common use cases or which I'll list a few here.
a) Soc adc's. Typical soc might have an 8 channel adc. On a typical board 2 channels are used for input (touchscreen), 2 for monitoring the battery and
4 brought out to an edge connector. Which are used for what and how many of each are used is entirely under control of the board designer. Thus we could have each SoC type adc driver handle the logic necessary to register an input device, a hwmon device (and perhaps an IIO device). This is the usecase that Mark Brown originally brought up. Right now Arnd is blocking some SoC adc drivers that do this internally and sending them in the direction of IIO.b) High spec devices used for input. This one we originally proposed doing via a bridge in userspace and piping back in via uinput. When I say high spec I meant 300+ dolar imu's etc. People do it for niche systems, but the part will never primarily be used for this so normally sits better in IIO, If we have borderline devices, they will end up in IIO. If this stuff had been in place earlier (as Dmitry pushed for) some of the existing parts in input might never have been accepted.
c) The other side is generating signals. People use arbitary waveform generators to produce inputs for all sort of strange devices.
So the question was whether to sit another subsystem under hwmon, input IIO etc, or to have IIO evolve into that underlying subsystem. Given with the channel mapping stuff we already had all the infrastructure in place to do this, a vague consensus said do it in IIO.
Now in many ways we'd love to have the IIO userspace stuff act as just another client, but that's a way off yet basically due to the huge number of special cases that would need to be handled. I'm personally not yet sure that will ever happen.
Quoted 4 lines
So in summary we don't do this as a simple dependency because of the combinatorial explosion in dependencies that would be needed and the connection modules that would be needed to glue it all together vs what is a simple mapping that will sit nicely in device tree etc.
So, would the "keep looping until all dependancies are met" patches from Grant that have been floating around for a while, solve this issue? Modules would properly initialize only when the needed other bits are present, which solves the problems the regulators and other drivers have today.
If so, then I suggest we get that code into the tree soon, and then all of this "wierd" logic would go away, right?
thanks,
greg k-h
Re: [PATCH 1/5] staging:iio:core add in kernel interface mapping and getting IIO channels.
Quoted 8 lines · Greg KH
So, would the "keep looping until all dependancies are met" patches from Grant that have been floating around for a while, solve this issue? Modules would properly initialize only when the needed other bits are present, which solves the problems the regulators and other drivers have today.
If so, then I suggest we get that code into the tree soon, and then all of this "wierd" logic would go away, right?
Could you identify the logic you're talking about here? Looking at the last patch set I can find[1] this all looks very vanilla for this sort of subsystem? You've got a mapping mechanism and a get function but that's about it which is all pretty normal. Grant's changes make module probing nicer in that you don't need to worry about the order in which things get registered but I can't see anything here which is particularly related to that ordering.
All the code is doing is providing a mechanism for drivers that need IIO facilities to locate the thing that's providing their IIO facilities (which is in the general case going to be board specific on a totally unrelated chip in a different part of the system and discovered through reading the schematic) without requiring custom code in every single single IIO using device to do the mapping. Instead the boards use a standard subsystem facility to tell the IIO core what's wired where and then the core matches things up for them.
This is nothing to do with init ordering, it's all about the two devices finding each other at all.
Greg KH
maintainerRe: [PATCH 1/5] staging:iio:core add in kernel interface mapping and getting IIO channels.
Quoted 28 lines · Mark Brown
Quoted 8 lines · Greg KH
So, would the "keep looping until all dependancies are met" patches from Grant that have been floating around for a while, solve this issue? Modules would properly initialize only when the needed other bits are present, which solves the problems the regulators and other drivers have today.
If so, then I suggest we get that code into the tree soon, and then all of this "wierd" logic would go away, right?
Could you identify the logic you're talking about here? Looking at the last patch set I can find[1] this all looks very vanilla for this sort of subsystem? You've got a mapping mechanism and a get function but that's about it which is all pretty normal. Grant's changes make module probing nicer in that you don't need to worry about the order in which things get registered but I can't see anything here which is particularly related to that ordering.
All the code is doing is providing a mechanism for drivers that need IIO facilities to locate the thing that's providing their IIO facilities (which is in the general case going to be board specific on a totally unrelated chip in a different part of the system and discovered through reading the schematic) without requiring custom code in every single single IIO using device to do the mapping. Instead the boards use a standard subsystem facility to tell the IIO core what's wired where and then the core matches things up for them.
Quoted 2 lines
This is nothing to do with init ordering, it's all about the two devices finding each other at all.
Ok, if that's all this is for, they why name it "iio in-kernel logic"? That made me believe that this is something that is needed if anyone who happens to want to use the iio interface needs it.
If it's just "iio discovery" then call it that :)
thanks,
greg k-h
Re: [PATCH 1/5] staging:iio:core add in kernel interface mapping and getting IIO channels.
Quoted 10 lines · Greg KH
Quoted 2 lines · Mark Brown
This is nothing to do with init ordering, it's all about the two devices finding each other at all.
Ok, if that's all this is for, they why name it "iio in-kernel logic"? That made me believe that this is something that is needed if anyone who happens to want to use the iio interface needs it.
If it's just "iio discovery" then call it that :)
I think that's all due to the overall goal of the patch series - the original use case for IIO was purely for userspace users and what the patch series is doing is adding the ability to use IIO devices from within the kernel.
Jonathan Cameron
maintainerRe: [PATCH 1/5] staging:iio:core add in kernel interface mapping and getting IIO channels.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 11 lines · Mark Brown
Quoted 9 lines · Greg KH
Quoted 2 lines · Mark Brown
This is nothing to do with init ordering, it's all about the two devices finding each other at all.
Ok, if that's all this is for, they why name it "iio in-kernel logic"? That made me believe that this is something that is needed if anyone who happens to want to use the iio interface needs it.
Quoted 6 lines
Quoted 1 line
If it's just "iio discovery" then call it that :)
I think that's all due to the overall goal of the patch series - the original use case for IIO was purely for userspace users and what the patch series is doing is adding the ability to use IIO devices from within the kernel.
That was my thinking. Happy to take suggestions for clearer naming!
Jonathan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJPNDilAAoJEFSFNJnE9BaI4wMP/21QLUcAzWgrlK+Vv5c8TAvf pXDQ2iZgtaA/JcTVpTh6VwI4cXJYI4Oq/MrokZaLJBS1avx9QEiyHjoXS8khLyi0 hKU0J5xgG61y6h/MMugqt06O4rIuuByOSuk7uWAvv9TN19ukVDsYG84Ct44XJeKb MfOVPm/YDRpHMAOvWPgEGJAfa3CcYPTf6E5MBsjcx2+kLxkzvNwpA5LAw+nLwq+q wEYNubsgp2U16S+Nf9Sqwhzzrg7UDbqOwWT/VkU1M9g5VtGcFYrAMhrnK36dTSXj Rkl1o7UIW6tRWggIvQ9TInYS+PMybumdGNL3zjxJcTCfGoxeGlMH5mGsviCIMDrg exDRyAoE6fiT6RxFe8OADwBuDunk5RQcZRq9LIC+lH68qq9n3FrqerCBue52yVL5 fzKgsQSlOfpvbSQPqGZh76xKSEXpANIJD8cLSaa6spO5QmwzK6hRtExWD84mtcgB k7s+G9vEoHo7CeaLZbwdbsdk3CZ3+PXgtWDOhx6+e4JhIoIR7UneFhJBw6jlkSFf 9a4cr6rW48M4Vh8Z3u6rsMl+ZJbiD5LXfKNtGhmOKPGHtEsxYCuJk3HXZO+voE0q 44RlIO0ijt8bV0xJcxSWI3+ArIhHEN9bW/8Zx8ELUoFA+Rs29SUAlHhEL0XGoHKZ H3RbDS7Cj9ji4gVxzocn
=hQ9x
-----END PGP SIGNATURE-----
Re: [PATCH 1/5] staging:iio:core add in kernel interface mapping and getting IIO channels.
Quoted 6 lines · Jonathan Cameron
[Mark]
Quoted 3 lines
the original use case for IIO was purely for userspace users and what the patch series is doing is adding the ability to use IIO devices from within the kernel.
That was my thinking. =A0Happy to take suggestions for clearer naming!
I would suggest not adding a config option at all but default-enable the in-kernel interface. To me that part is certainly the key component, userspace IIO to me is just some obscurity ...
Yours,
Linus Walleij
Jonathan Cameron
maintainerPATCH v5 2/5 staging:iio: move iio data return types into types.h for use by inkern
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
In kernel interfaces need these, so make them available.
--- drivers/staging/iio/iio.h | 6 ------ drivers/staging/iio/types.h | 4 ++++ 2 files changed, 4 insertions(+), 6 deletions(-)
drivers/staging/iio/iio.h +0 -6
@@ -197,12 +197,6 @@ static inline s64 iio_get_time_ns(void)#define INDIO_ALL_BUFFER_MODES \ (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE) -/* Vast majority of this is set by the industrialio subsystem on a -* call to iio_device_register. */ -#define IIO_VAL_INT 1 -#define IIO_VAL_INT_PLUS_MICRO 2 -#define IIO_VAL_INT_PLUS_NANO 3 -struct iio_trigger ;/* forward declaration */ struct iio_dev ;
drivers/staging/iio/types.h +4 -0
@@ -46,4 +46,8 @@ enum iio_modifier { IIO_MOD_LIGHT_IR, }; +#define IIO_VAL_INT 1 +#define IIO_VAL_INT_PLUS_MICRO 2 +#define IIO_VAL_INT_PLUS_NANO 3 +#endif /* _IIO_TYPES_H_ */
Signature · 1 line
1.7.8.4
Jonathan Cameron
maintainerPATCH v5 3/5 staging:iio::hwmon interface client driver.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Direct copy of version proposed for the non staging branch. Needed here to allow testing of more advanced inkernel interface code.
Minimal support of simple in, curr and temp attributes so far.
--- drivers/staging/iio/Kconfig | 9 ++ drivers/staging/iio/Makefile | 2 + drivers/staging/iio/iio_hwmon.c | 226 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+), 0 deletions(-)
drivers/staging/iio/Kconfig +9 -0
@@ -18,6 +18,15 @@ config IIO_INKERN help Support in kernel users of IIO device drivers. +config IIO_ST_HWMON + tristate "Hwmon driver that uses channels specified via iio maps" + depends on HWMON + depends on IIO_INKERN + help + This is a platform driver that in combination with a suitable + map allows IIO devices to provide basic hwmon functionality + for those channels specified in the map. + config IIO_BUFFER bool "Enable buffer support within IIO" help
drivers/staging/iio/Makefile +2 -0
@@ -17,6 +17,8 @@ iio_dummy-$(CONFIG_IIO_SIMPLE_DUMMY_BUFFER) += iio_simple_dummy_buffer.o obj-$(CONFIG_IIO_DUMMY_EVGEN) += iio_dummy_evgen.o +obj-$(CONFIG_IIO_ST_HWMON) += iio_hwmon.o + obj-y += accel/ obj-y += adc/ obj-y += addac/
drivers/staging/iio/iio_hwmon.c new file +226 -0
226 lines not on this page · raw message
Signature · 1 line
1.7.8.4
Jonathan Cameron
maintainerPATCH v5 4/5 staging:iio:Documentation in kernel pull description.
In reply to Jonathan CameronVery basic description of the way iio consumers work and how to use this functionality.
--- drivers/staging/iio/Documentation/inkernel.txt | 59 ++++++++++++++++++++++++ 1 files changed, 59 insertions(+), 0 deletions(-)
drivers/staging/iio/Documentation/inkernel.txt new file +59 -0
@@ -0,0 +1,59 @@ +Industrial I/O Subsystemm in kernel consumers. + +The IIO subsystem can act as a layer under other elements of the kernel +providing a means of obtaining adc type readings or of driving dac type +signals. The functionality supported will grow as use cases arise. + +Describing the channel mapping (iio/machine.h) + +Channel associations are described using: + +struct iio_map { + const char *adc_channel_label; + struct device *consumer_dev; + const char *consumer_dev_name; + const char *consumer_channel; +}; + +adc_channel label identifies the channel on the IIO device by being +matched against the datasheet_name field of the iio_chan_spec. + +consumer_dev or consumer_dev_name allow identification of the consumer device. +These are then used to find the channel mapping from the consumer device (see +below). + +Finally consumer_channel is a string identifying the channel to the consumer. +(Perhaps 'battery_voltage' or similar). + +An array of these structures is then passed to the IIO driver. + +Supporting in kernel interfaces in the driver (driver.h) + +The driver must provide datasheet_name values for its channels and +must pass the iio_map structures and a pointer to its own iio_dev structure + on to the core via a call to iio_map_array_register. On removal, +iio_map_array_unregister reverses this process. + +The result of this is that the IIO core now has all the information needed +to associate a given channel with the consumer requesting it. + +Acting as an IIO consumer (consumer.h) + +The consumer first has to obtain an iio_channel structure from the core +by calling iio_channel_get(). The correct channel is identified by: + +* matching dev or dev_name against consumer_dev and consumer_dev_name +* matching consumer_channel against consumer_channel in the map + +There are then a number of functions that can be used to get information +about this channel such as it's current reading. + +e.g. +iio_st_read_channel_raw() - get a reading +iio_st_read_channel_type() - get the type of channel + +There is also provision for retrieving all of the channels associated +with a given consumer. This is useful for generic drivers such as +iio_hwmon where the number and naming of channels is not known by the +consumer driver. To do this, use iio_st_channel_get_all. +
Signature · 1 line
1.7.8.4
Jonathan Cameron
maintainerPATCH v5 5/5 stargate2: example of map configuration for iio to hwmon example.
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
Do not commit.
--- arch/arm/mach-pxa/stargate2.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-)
arch/arm/mach-pxa/stargate2.c +22 -0
@@ -54,6 +54,8 @@#include <linux/mfd/da903x.h> #include <linux/sht15.h> +#include "../../../drivers/staging/iio/machine.h" +#include "devices.h" #include "generic.h"
@@ -406,6 +408,23 @@ static struct i2c_pxa_platform_data i2c_pdata = { .fast_mode = 1, }; +static struct platform_device iio_hwmon_test = { + .name ="iio_hwmon" , +}; + +static struct iio_map max1363_consumer_map[] = { + { + .adc_channel_label ="AIN1" , + .consumer_dev = &iio_hwmon_test.dev, + .consumer_channel ="testchan1" , + }, { + .adc_channel_label ="AIN2" , + .consumer_dev = &iio_hwmon_test.dev, + .consumer_channel ="testchan2" , + }, + {} +}; +static void __init imote2_stargate2_init (void ) {
@@ -561,6 +580,7 @@ static struct i2c_board_info __initdata imote2_i2c_board_info[] = {* pull up resistors are missing. */ .irq = PXA_GPIO_TO_IRQ(99), + .platform_data = max1363_consumer_map, }, { /* ITS400 Sensor board only */ .type = "tsl2561", .addr = 0x49,
@@ -945,6 +965,7 @@ static struct i2c_board_info __initdata stargate2_i2c_board_info[] = {* pull up resistors are missing. */ .irq = PXA_GPIO_TO_IRQ(99), + .platform_data = max1363_consumer_map, }, { /* ITS400 Sensor board only */ .type = "tsl2561", .addr = 0x49,
@@ -977,6 +998,7 @@ static struct platform_device *stargate2_devices[] = { &stargate2_sram, &smc91x_device, &sht15, + &iio_hwmon_test, };static void __init stargate2_init (void )
Signature · 1 line
1.7.8.4
Re: [PATCH 5/5] stargate2: example of map configuration for iio to hwmon example.
arch/arm/mach-pxa/stargate2.c static struct i2c_pxa_platform_data i2c_pdata = { · line 419
Quoted 5 lines · Jonathan Cameron
arch/arm/mach-pxa/stargate2.c +5
-0+static struct iio_map max1363_consumer_map[] = { + { + .adc_channel_label ="AIN1" , + .consumer_dev = &iio_hwmon_test.dev, + .consumer_channel ="testchan1" ,
I do think it's better to use dev_name here rather than a struct device pointer - for several of the buses it's not actually possible to get a struct device until a device has been instantiated which isn't helpful for setting up the mappings.
Jonathan Cameron
maintainerRe: [PATCH 5/5] stargate2: example of map configuration for iio to hwmon example.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 10 lines · Mark Brown
Quoted 3 lines · Jonathan Cameron
+static struct
iio_mapmax1363_consumer_map[] = { + { +
.adc_channel_label = "AIN1", + .consumer_dev =
&iio_hwmon_test.dev, + .consumer_channel = "testchan1",I do think it's better to use
dev_namehere rather than a struct device pointer - for several of the buses it's not actually possible to get a struct device until a device has been instantiated which isn't helpful for setting up the mappings.
We allow both. In cases like this where the dev pointer is explicitly available what gain do we get from not using it?
I could easily enough fake an example for using dev_name as well I suppose or add a commented out version in here to make it obvious that both options would be fine. Note this example is actually garbage anyway as that particular chip is simply wired to some screw terminals on the side of this board.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJPJvy+AAoJEFSFNJnE9BaI8GwQAIRQ2MP+UhVUGiPVQpTIVxIV B+3GvoDhdF8GEaWLMb5jXS6p1kQ9m1IxSfTfzBPa/lLDMpZMH72FD2nguNFID0qK aRu2zv7ooEAdhBMPYJJC9XUlq1vl7Mas82zH8zK2z/iIuIUJTJlO/l+vgpu+EhFJ H5DODW9oRuWpbNMbpTKExf+fyMRkp/o+0It++Zk4eJPs4q1ajAYnDpDeIeUVyyIM 5OTQSvrGVL8uRtHhcqaJkVNUizhR+eMgDYef25dgTO2CnKjoO5q3CjikcoG6RYrQ tVvZw0slGULry2jGcf1K/scxiuIjCtYGIPFkeorxtAow6JB3QRvQP01JYa+4gpb1 HSp0dkvmUF4V0JS52bxzp788C9hpAG7Vd7Mul3M+7BuwYxAOYgD8eL5tfuQWPaCJ nN/YlXUDw1Oy3obBKZvma1o18zaQvclF74FIAw4AMz/8r8QC3vcpvUqR58YP7B2Z qYheZKIIII4kZmG09QcYVjXB3O1IvP9B9EN/QPXYTp8vHQ55wVPA6ZQQzpeSnDeC 5PW0TaNMqroYdb2BuPZ4+gVNt3rqmDNTaexxdgWJtHAKiukh6EbNEfEsTk/LTOHn s+jTnpni3h+z+tgTRvxgGmW40EyUlrmnR/c0vBohvcknOI1ugrViRr88RCsSX01S Wv/kaVXUcT5visYRcHls
=Z0kq
-----END PGP SIGNATURE-----
Re: [PATCH 5/5] stargate2: example of map configuration for iio to hwmon example.
Quoted 7 lines · Jonathan Cameron
Quoted 5 lines · Mark Brown
Quoted 3 lines · Jonathan Cameron
+static struct
iio_mapmax1363_consumer_map[] = { + { +
.adc_channel_label = "AIN1", + .consumer_dev =
&iio_hwmon_test.dev, + .consumer_channel = "testchan1",
Quoted 7 lines
Quoted 4 lines
I do think it's better to use
dev_namehere rather than a struct device pointer - for several of the buses it's not actually possible to get a struct device until a device has been instantiated which isn't helpful for setting up the mappings.We allow both. In cases like this where the dev pointer is explicitly available what gain do we get from not using it?
You avoid user confusion from having two ways of doing the same thing and you save a little complexity in the implementation. The user confusion does happen in practice.
Jonathan Cameron
maintainerRe: [PATCH 5/5] stargate2: example of map configuration for iio to hwmon example.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 15 lines · Mark Brown
Quoted 13 lines · Jonathan Cameron
Quoted 12 lines · Mark Brown
Quoted 3 lines · Jonathan Cameron
+static struct
iio_mapmax1363_consumer_map[] = { + { +
.adc_channel_label = "AIN1", + .consumer_dev =
&iio_hwmon_test.dev, + .consumer_channel = "testchan1",I do think it's better to use
dev_namehere rather than a struct device pointer - for several of the buses it's not actually possible to get a struct device until a device has been instantiated which isn't helpful for setting up the mappings.
Quoted 6 lines
Quoted 2 lines
We allow both. In cases like this where the dev pointer is explicitly available what gain do we get from not using it?
You avoid user confusion from having two ways of doing the same thing and you save a little complexity in the implementation. The user confusion does happen in practice.
Good reasoning. Will drop the dev pointer option. -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJPJxBHAAoJEFSFNJnE9BaIGUwP/2SQjWhWZP28GWpWemx5Av7O 5CUKvDZ/qk+ehevvp0fOKOD/DvciSNWDd/dTmGRllbYzpz7RkbGmV9sm+BFydqyG beTzbF5h5vuvCNfvVrXwePh2/fcm3kSMIOYQSnaDmn5rmZTR0qK6nkh1GdBtMa2T Hbk+qjdQFcrAvQcL1R4FQO+kq2xS/F3zQAt1rqxu4e+JWQjYDmGCK9zeWjJDmakv 2DDeUUezNIA0tjvQy9EUOdybtoKvBlmgTujwCX2qpeyJTll2yxPuWFx8nB7oNGCQ ljoa9YO6mpRgiAQNpnvOeMLtAwa3EjEZLf1XBRRXUPoAvehcPLdL5C3IaxzpmaTY r7qXAPWwMPGIj5pTXdP1mQleZiepdKi3oOWygBjG8nKDqcLjuiMBPaE+S6xjIn4O dseszmeWhOsQgdBr3CpkaqBZrT3NDKcHkaFyThCQCDBIATTEK5LVgGVi9KX3toAe Emov7mOW+xSTJ2CLtbrmmjRm/mJSCXUVPBurD+LTXJnxOmCipTmd0Gt/s8dzPyd0 uaY4XBSypYjUvakFgazuZ13pgDvfbQe329ShRNzM4CAPboy8q/X1W/JDsZvfJqrj oo04TKVxjbg44FjzhbxxBIavq+BUIdJMW4/MCt5YRq5rZPHq5E0TAbZ4tQpmvHUJ I9UZthFWchN/lD2AEteV
=QK3s
-----END PGP SIGNATURE-----
Re: [PATCH 5/5] stargate2: example of map configuration for iio to hwmon example.
In reply to Mark BrownQuoted 5 lines · Mark Brown
Quoted 4 lines · Jonathan Cameron
Quoted 3 lines · Mark Brown
Quoted 1 line · Jonathan Cameron
+static struct
iio_mapmax1363_consumer_map[] =3D { + =A0 =A0 =A0 =A0=
{ +
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
.adc_channel_label =3D "AIN1", + =A0 =A0 =A0 =A0 =A0 =A0 .consumer_de=
v =3D
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
&iio_hwmon_test.dev, + =A0 =A0 =A0 =A0 =A0 =A0 .consumer_channel =3D =
"testchan1",
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines
I do think it's better to use
dev_namehere rather than a struct device pointer - for several of the buses it's not actually possible to get a struct device until a device has been instantiated which isn't helpful for setting up the mappings.
Quoted 6 lines
Quoted 2 lines
We allow both. =A0In cases like this where the dev pointer is explicitly available what gain do we get from not using it?
You avoid user confusion from having two ways of doing the same thing and you save a little complexity in the implementation. =A0The user confusion does happen in practice.
The clockdev API is stricter and only allows for names I noticed.
So I guess this pattern comes from the regulator framework struct regulator_consumer_supply design pattern initially.
We allow both struct device * in regulators and pin muxes. So, not having it for ADCs could be confusing as well.
But we should then try to rid it from the kernel at large, no big deal, I have only one in-kernel user of this ATM I think so I can kill it off fro= m
the pin control API if you think you can kill it from regulators.
I just want to make sure that this is the direction we want to go...
Yours,
Linus Walleij
Re: [PATCH 5/5] stargate2: example of map configuration for iio to hwmon example.
Quoted 8 lines · Linus Walleij
On Mon, Jan 30, 2012 at 10:22 PM, Mark Brown
Quoted 3 lines
You avoid user confusion from having two ways of doing the same thing and you save a little complexity in the implementation. The user confusion does happen in practice.
So I guess this pattern comes from the regulator framework struct
regulator_consumer_supplydesign pattern initially.
Yes, and the only reason the regulator API does this is historical.
Quoted 3 lines
But we should then try to rid it from the kernel at large, no big deal, I have only one in-kernel user of this ATM I think so I can kill it off from the pin control API if you think you can kill it from regulators.
Well volunteered :)
On Sun, Jan 29, 2012 at 12:46 PM, Jonathan Cameron <[email protected]> wrote= :
Quoted 1 line
Firstly this is an RFC rather than a final proposal because I know there =
is
Quoted 1 line
an issue with the provider being removed before the consumer. =A0It will =
be easy
Quoted 1 line
to make this less likely to happen, but I am not entirely sure how to avo=
id
Quoted 1 line
any possible race (suggestion welcome).
I basically think this looks good... :-)
Yours,
Linus Walleij