[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1318951776-19393-4-git-send-email-jic23@cam.ac.uk>
Date: Tue, 18 Oct 2011 16:29:33 +0100
From: Jonathan Cameron <jic23@....ac.uk>
To: linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org
Cc: linus.ml.walleij@...il.com, zdevai@...il.com,
linux@....linux.org.uk, arnd@...db.de,
broonie@...nsource.wolfsonmicro.com, gregkh@...e.de,
Jonathan Cameron <jic23@....ac.uk>
Subject: [PATCH 3/6] IIO:CORE add global list of registered IIO devices.
Needed for inkernel interfaces.
Signed-off-by: Jonathan Cameron <jic23@....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;
--
1.7.7
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists