linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@cam.ac.uk>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
	linus.ml.walleij@gmail.com, zdevai@gmail.com,
	linux@arm.linux.org.uk, arnd@arndb.de,
	broonie@opensource.wolfsonmicro.com, gregkh@suse.de
Subject: Re: [PATCH 3/6] IIO:CORE add global list of registered IIO devices.
Date: Wed, 19 Oct 2011 14:46:03 +0100	[thread overview]
Message-ID: <4E9ED49B.1070005@cam.ac.uk> (raw)
In-Reply-To: <4E9DE2AB.3090208@cam.ac.uk>

On 10/18/11 21:33, Jonathan Cameron wrote:
> On 10/18/11 19:25, Lars-Peter Clausen wrote:
>> On 10/18/2011 05:29 PM, Jonathan Cameron wrote:
>>> Needed for inkernel interfaces.
>>>
>>
>> The bus_type structure keeps a list of all devices registered on that bus, so
>> you should be able to use bus_for_each_dev and bus_find_device for iterating
>> over the iio devices.
> I hadn't realised that but don't think it will work anyway. There are several
> other things than iio_dev based devices that sit on our bus unfortunately.
> None are in these initial merges but they will turn up later.
> The most common are iio_triggers but there are also a few weird ones such
> as the event generator for the dummy driver and the sysfstrig control device.  
> We could play some games to allow these to be identified, but it's going
> to be a mess. Probably easier to just maintain a second list as we are doing
> here.  Interesting suggestion though. Thanks and feel free to point out if there
> is a simple way around the identification issue.
Actually looking into it this morning - this is trivial to do.
We can just check that the device_type is set appropriately before doing anything
else.

Thanks Lars-Peter your suggestion is should clean things up nicely.

New version coming up.
>>
>>> Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
>>> ---
>>>  drivers/iio/iio.c       |    9 +++++++++
>>>  include/linux/iio/iio.h |    1 +
>>>  2 files changed, 10 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/drivers/iio/iio.c b/drivers/iio/iio.c
>>> index 9e6acc1..246a093 100644
>>> --- a/drivers/iio/iio.c
>>> +++ b/drivers/iio/iio.c
>>> @@ -15,6 +15,9 @@
>>>  #include <linux/iio/iio.h>
>>>  #include <linux/iio/sysfs.h>
>>>  
>>> +static DEFINE_MUTEX(iio_device_list_lock);
>>> +static LIST_HEAD(iio_device_list);
>>> +
>>>  static DEFINE_IDA(iio_ida);
>>>  
>>>  static struct bus_type iio_bus_type = {
>>> @@ -91,6 +94,9 @@ static void iio_dev_release(struct device *device)
>>>  {
>>>  	struct iio_dev *indio_dev = container_of(device, struct iio_dev, dev);
>>>  	iio_device_unregister_sysfs(indio_dev);
>>> +	mutex_lock(&iio_device_list_lock);
>>> +	list_del(&indio_dev->dev_list_entry);
>>> +	mutex_unlock(&iio_device_list_lock);
>>>  }
>>>  
>>>  static struct device_type iio_dev_type = {
>>> @@ -559,6 +565,9 @@ int iio_device_register(struct iio_dev *indio_dev)
>>>  	if (ret)
>>>  		goto error_free_sysfs;
>>>  
>>> +	mutex_lock(&iio_device_list_lock);
>>> +	list_add(&indio_dev->dev_list_entry, &iio_device_list);
>>> +	mutex_unlock(&iio_device_list_lock);
>>>  	return 0;
>>>  
>>>  error_free_sysfs:
>>> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
>>> index beedc5c..f14e7dc 100644
>>> --- a/include/linux/iio/iio.h
>>> +++ b/include/linux/iio/iio.h
>>> @@ -192,6 +192,7 @@ struct iio_info {
>>>   * @info:		[DRIVER] callbacks and constant info from driver
>>>   * @groups:		[INTERN] attribute groups
>>>   * @groupcounter:	[INTERN] index of next attribute group
>>> + * @dev_list_entry:	[INTERN] entry in global list of iio devices
>>>   **/
>>>  struct iio_dev {
>>>  	int				id;
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

  reply	other threads:[~2011-10-19 13:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-18 15:29 [RFC PATCH 0/6] IIO in kernel interfaces Jonathan Cameron
2011-10-18 15:29 ` [PATCH 1/6] IIO: core: add datasheet_name to chan_spec Jonathan Cameron
2011-10-18 15:29 ` [PATCH 2/6] IIO:ADC:max1363 add datasheet_name entries Jonathan Cameron
2011-10-18 15:29 ` [PATCH 3/6] IIO:CORE add global list of registered IIO devices Jonathan Cameron
2011-10-18 18:25   ` Lars-Peter Clausen
2011-10-18 20:33     ` Jonathan Cameron
2011-10-19 13:46       ` Jonathan Cameron [this message]
2011-10-19 15:02         ` Lars-Peter Clausen
2011-10-18 15:29 ` [PATCH 4/6] IIO:Core add in kernel interface mapping and getting IIO channels Jonathan Cameron
2011-10-18 15:29 ` [PATCH 5/6] IIO:Temporary example hwmon interface Jonathan Cameron
2011-10-18 15:29 ` [PATCH 6/6] stargate2: example of map configuration for iio to hwmon example Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E9ED49B.1070005@cam.ac.uk \
    --to=jic23@cam.ac.uk \
    --cc=arnd@arndb.de \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=gregkh@suse.de \
    --cc=lars@metafoo.de \
    --cc=linus.ml.walleij@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=zdevai@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).