* Currently assumes nano seconds.
*/
-/* Event interface flags */
-#define IIO_BUSY_BIT_POS 1
-
/* naughty temporary hack to match these against the event version
- need to flattern these together */
enum iio_chan_type {
unsigned modified:1;
unsigned indexed:1;
};
-/* Meant for internal use only */
-void __iio_device_attr_deinit(struct device_attribute *dev_attr);
-int __iio_device_attr_init(struct device_attribute *dev_attr,
- const char *postfix,
- struct iio_chan_spec const *chan,
- ssize_t (*readfunc)(struct device *dev,
- struct device_attribute *attr,
- char *buf),
- ssize_t (*writefunc)(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len),
- bool generic);
+
#define IIO_ST(si, rb, sb, sh) \
{ .sign = si, .realbits = rb, .storagebits = sb, .shift = sh }
{ .type = IIO_TIMESTAMP, .channel = -1, \
.scan_index = _si, .scan_type = IIO_ST('s', 64, 64, 0) }
-int __iio_add_chan_devattr(const char *postfix,
- const char *group,
- struct iio_chan_spec const *chan,
- ssize_t (*func)(struct device *dev,
- struct device_attribute *attr,
- char *buf),
- ssize_t (*writefunc)(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len),
- int mask,
- bool generic,
- struct device *dev,
- struct list_head *attr_list);
/**
* iio_get_time_ns() - utility function to get a time stamp for events etc
**/
int ev_code,
s64 timestamp);
-/* Used to distinguish between bipolar and unipolar scan elemenents.
- * Whilst this may seem obvious, we may well want to change the representation
- * in the future!*/
-#define IIO_SIGNED(a) -(a)
-#define IIO_UNSIGNED(a) (a)
-
-extern dev_t iio_devt;
extern struct bus_type iio_bus_type;
/**
put_device(&dev->dev);
};
-/**
- * to_iio_dev() - get iio_dev for which we have the struct device
- * @d: the struct device
- **/
-static inline struct iio_dev *to_iio_dev(struct device *d)
-{
- return container_of(d, struct iio_dev, dev);
-};
-
/* Can we make this smaller? */
#define IIO_ALIGN L1_CACHE_BYTES
/**
void iio_free_device(struct iio_dev *dev);
/**
- * iio_put() - internal module reference count reduce
- **/
-void iio_put(void);
-
-/**
- * iio_get() - internal module reference count increase
- **/
-void iio_get(void);
-
-/**
- * iio_device_get_chrdev_minor() - get an unused minor number
- **/
-int iio_device_get_chrdev_minor(void);
-void iio_device_free_chrdev_minor(int val);
-
-/**
* iio_ring_enabled() - helper function to test if any form of ring is enabled
* @dev_info: IIO device info structure for device
**/
--- /dev/null
+/* The industrial I/O core function defs.
+ *
+ * Copyright (c) 2008 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.
+ *
+ * These definitions are meant for use only within the IIO core, not indvidual
+ * drivers.
+ */
+
+/**
+ * iio_device_get_chrdev_minor() - get an unused minor number
+ **/
+int iio_device_get_chrdev_minor(void);
+void iio_device_free_chrdev_minor(int val);
+
+
+/**
+ * iio_put() - internal module reference count reduce
+ **/
+void iio_put(void);
+
+/**
+ * iio_get() - internal module reference count increase
+ **/
+void iio_get(void);
+
+extern dev_t iio_devt;
+
+int __iio_add_chan_devattr(const char *postfix,
+ const char *group,
+ struct iio_chan_spec const *chan,
+ ssize_t (*func)(struct device *dev,
+ struct device_attribute *attr,
+ char *buf),
+ ssize_t (*writefunc)(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf,
+ size_t len),
+ int mask,
+ bool generic,
+ struct device *dev,
+ struct list_head *attr_list);
+
+/* Event interface flags */
+#define IIO_BUSY_BIT_POS 1
#include <linux/slab.h>
#include "iio.h"
#include "trigger_consumer.h"
+#include "iio_core.h"
#define IIO_ID_PREFIX "device"
#define IIO_ID_FORMAT IIO_ID_PREFIX "%d"
static DEFINE_SPINLOCK(iio_ida_lock);
dev_t iio_devt;
-EXPORT_SYMBOL(iio_devt);
#define IIO_DEV_MAX 256
struct bus_type iio_bus_type = {
};
/* Return a negative errno on failure */
-int iio_get_new_ida_val(struct ida *this_ida)
+static int iio_get_new_ida_val(struct ida *this_ida)
{
int ret;
int val;
return val;
}
-EXPORT_SYMBOL(iio_get_new_ida_val);
-void iio_free_ida_val(struct ida *this_ida, int id)
+static void iio_free_ida_val(struct ida *this_ida, int id)
{
spin_lock(&iio_ida_lock);
ida_remove(this_ida, id);
spin_unlock(&iio_ida_lock);
}
-EXPORT_SYMBOL(iio_free_ida_val);
int iio_push_event(struct iio_dev *dev_info,
int ev_line,
return 0;
}
+static
int __iio_device_attr_init(struct device_attribute *dev_attr,
const char *postfix,
struct iio_chan_spec const *chan,
return ret;
}
-void __iio_device_attr_deinit(struct device_attribute *dev_attr)
+static void __iio_device_attr_deinit(struct device_attribute *dev_attr)
{
kfree(dev_attr->attr.name);
}
struct iio_chan_spec const *chan)
{
- int ret = 0, i, mask;
+ int ret = 0, i, mask = 0;
char *postfix;
if (!chan->event_mask)
return 0;
static void iio_dev_release(struct device *device)
{
+ struct iio_dev *dev_info = container_of(device, struct iio_dev, dev);
iio_put();
- kfree(to_iio_dev(device));
+ kfree(dev_info);
}
static struct device_type iio_dev_type = {