staging:iio: header reorganization
authorJonathan Cameron <jic23@cam.ac.uk>
Wed, 26 Oct 2011 16:41:32 +0000 (17:41 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 27 Nov 2011 00:35:04 +0000 (16:35 -0800)
Issue brought up by Lars-Peter Clausen. This is a varient of what
he suggested.

io/iio.h for driver stuff (has to include types.h)
Sub files for the bits drivers may or may not use
iio/sysfs.h
iio/buffer.h (contents of current buffer_generic.h)
(obviously anything offering events will need events.h as well)
iio/types.h for the enums that matter to both
iio_chan_type, iio_modifier
iio/events.h for the event code stuff
IIO_EVENT_CODE and friends.  + everything in chrdev.h  So this
is the stuff that userspace cares about.
Also include iio_event_type, iio_event_direction

Thus iio drivers include iio.h + as required
events.h
sysfs.h
buffer.h

in kernel users (once that interface is merged) will need inkern.h
which will pull in types.h

Userspace will need just events.h (which pulls in types.h) to get
everything they need to know about.  Buffer userspace access doesn't
currently need any core defines. All information about the data
format is passed through sysfs.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
48 files changed:
drivers/staging/iio/accel/adis16201_core.c
drivers/staging/iio/accel/adis16203_core.c
drivers/staging/iio/accel/adis16204_core.c
drivers/staging/iio/accel/adis16209_core.c
drivers/staging/iio/accel/adis16240_core.c
drivers/staging/iio/accel/lis3l02dq_core.c
drivers/staging/iio/accel/sca3000_core.c
drivers/staging/iio/accel/sca3000_ring.c
drivers/staging/iio/adc/ad7192.c
drivers/staging/iio/adc/ad7280a.c
drivers/staging/iio/adc/ad7291.c
drivers/staging/iio/adc/ad7298_core.c
drivers/staging/iio/adc/ad7298_ring.c
drivers/staging/iio/adc/ad7476_core.c
drivers/staging/iio/adc/ad7476_ring.c
drivers/staging/iio/adc/ad7606_core.c
drivers/staging/iio/adc/ad7606_ring.c
drivers/staging/iio/adc/ad7793.c
drivers/staging/iio/adc/ad7816.c
drivers/staging/iio/adc/ad7887_core.c
drivers/staging/iio/adc/ad7887_ring.c
drivers/staging/iio/adc/ad799x_core.c
drivers/staging/iio/adc/ad799x_ring.c
drivers/staging/iio/adc/adt7310.c
drivers/staging/iio/adc/adt7410.c
drivers/staging/iio/adc/max1363_core.c
drivers/staging/iio/adc/max1363_ring.c
drivers/staging/iio/addac/adt7316.c
drivers/staging/iio/buffer.h [new file with mode: 0644]
drivers/staging/iio/buffer_generic.h [deleted file]
drivers/staging/iio/cdc/ad7150.c
drivers/staging/iio/chrdev.h [deleted file]
drivers/staging/iio/dac/ad5504.c
drivers/staging/iio/events.h [new file with mode: 0644]
drivers/staging/iio/gyro/adis16260_core.c
drivers/staging/iio/iio.h
drivers/staging/iio/iio_simple_dummy.c
drivers/staging/iio/iio_simple_dummy_events.c
drivers/staging/iio/impedance-analyzer/ad5933.c
drivers/staging/iio/imu/adis16400_core.c
drivers/staging/iio/industrialio-buffer.c
drivers/staging/iio/industrialio-core.c
drivers/staging/iio/kfifo_buf.h
drivers/staging/iio/light/tsl2563.c
drivers/staging/iio/meter/ade7758_core.c
drivers/staging/iio/ring_sw.h
drivers/staging/iio/sysfs.h
drivers/staging/iio/types.h [new file with mode: 0644]

index 1c5dad537844879e811b850a756344d02a6c6e09..1283519317565ff18572aba9aaf8eca668f01b6d 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 
 #include "adis16201.h"
 
index 8a3337442afde851d4e98f9772aeef83194e7f8f..5483b59aea32b04e8d725df6bdf769dbadc2f4b8 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 
 #include "adis16203.h"
 
index 644ac8e4d2aa3cce8931518d2a5cb87082401d64..462f215f8c8d3e864c8db79ebf738fe79db5e754 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 
 #include "adis16204.h"
 
index 0a8571b18b393a0161bacfc15c75d224670c1e5f..827499f70af6f198955339cbba414d87344769b3 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 
 #include "adis16209.h"
 
index b8be2925d61c1ae468bdbfa847a8a1fdc7888809..8123fe3bd22746933f52819df0a8320a4a299969 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 
 #include "adis16240.h"
 
index 559545a423335261e3d64139f8ff7bc0ef6980e9..358a9f6cbb0afa8afb4eb980be642d425f1862e9 100644 (file)
@@ -25,7 +25,8 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../events.h"
+#include "../buffer.h"
 
 #include "lis3l02dq.h"
 
index a44a70589db9eb026b08e92f5de9b505167393bb..8a46983275bc6106353c45d68e86d59080888597 100644 (file)
@@ -20,7 +20,8 @@
 #include <linux/module.h>
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../events.h"
+#include "../buffer.h"
 
 #include "sca3000.h"
 
index 4a9a01dccd0c5b0a7b14dce700f804862a12f482..685ded8fb857ed891006f468e37d3ed537dd428a 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 #include "../ring_hw.h"
 #include "sca3000.h"
 
index d8bf559fef876ab380cf8cbce5e034918fa3b41c..39ba05db2c0279bbf3163bec84268ec8023a28b8 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 #include "../ring_sw.h"
 #include "../trigger.h"
 #include "../trigger_consumer.h"
index f45b66bf6105335cb9f2631554d74b751a392511..8f4fac1ce7ae685b2a97f6c24a333ea771942c69 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
+#include "../events.h"
 
 #include "ad7280a.h"
 
index 10e79e8ee64d98922f3adb3f75d141843a5ad81a..e5f352bc4368c5afe82250db22c1bf7e71769ff4 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
+#include "../events.h"
 
 /*
  * Simplified handling
index c1de73a1ca912d735fa10f414dc729918a7256ce..445b07116d74bfc1debada27d08c41127a5b2d12 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 
 #include "ad7298.h"
 
index 47630d506a63b6384f262727f89d5ea9cfceaf72..192328edeb29c453ccd22ac7a9ec4178cbacbf31 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/spi/spi.h>
 
 #include "../iio.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 #include "../ring_sw.h"
 #include "../trigger_consumer.h"
 
index fd79facc6cae0a9baaa4685c29f6fd36e0fadcc3..13473133bbe2fa827e99ee2abf05e486a5b6def3 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 
 #include "ad7476.h"
 
index e82c1a433f4f5a984cc78a4c80e743369e795082..09618873986e44aa0f458f91f54cac6277facf44 100644 (file)
@@ -14,7 +14,7 @@
 #include <linux/spi/spi.h>
 
 #include "../iio.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 #include "../ring_sw.h"
 #include "../trigger_consumer.h"
 
index 54423ab196fe244517c683fcfa2278d7416851ca..53174831663c394f64ac1fbcd220ee1bf42d0024 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 
 #include "ad7606.h"
 
index 20927fd537288a7555133bb4a477a8ccf5baad25..af6780a4fe7dbd13a1c24e8853477ab1c402f980 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/slab.h>
 
 #include "../iio.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 #include "../ring_sw.h"
 #include "../trigger_consumer.h"
 
index 999f8f746cff5c7122d60675a4b9955466d8c052..17fde6669eff241378f0e45e45184acd66fff997 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 #include "../ring_sw.h"
 #include "../trigger.h"
 #include "../trigger_consumer.h"
index bdb90492b8a54514e8bb61b53c130dfc0f042e0f..7a344a2716154af32a11c9a3cfee1436bf678d2e 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
+#include "../events.h"
 
 /*
  * AD7816 config masks
index 609dcd5f2ddca796e255638114e8598bfeb58bba..a7baa9bb0eaa0bfdaa0255545a89798852f1f419 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 
 
 #include "ad7887.h"
index cb74cada561174199d38b20077385fd9aa54b662..fbe21b5bd3dd38766320fb4b64e29d29eedf3841 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/spi/spi.h>
 
 #include "../iio.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 #include "../ring_sw.h"
 #include "../trigger_consumer.h"
 
index ee6cd792bec8ab2b2f5a341bbc135d96586fd9d5..64ac31666739ab7e8a61e8d3813199d4c6155009 100644 (file)
@@ -35,7 +35,8 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../events.h"
+#include "../buffer.h"
 
 #include "ad799x.h"
 
index e3f4698d7815a5361b729e11ddc79875a1d53618..b215a1f5a02b813c087db93be5555b69c9182fcb 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/bitops.h>
 
 #include "../iio.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 #include "../ring_sw.h"
 #include "../trigger_consumer.h"
 
index c9e0be3b1cf316fc0b7cdb2ce585ccd8a91c2258..c937ac1838f273433e7087013461da73dd46ccbc 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-
+#include "../events.h"
 /*
  * ADT7310 registers definition
  */
index a289e429dc419418e6eae55f544f6fb1736fc372..16467a7ef4a4ea949ff3983ddb9311e65e215943 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
+#include "../events.h"
 
 /*
  * ADT7410 registers definition
index eb699ade34b0407f9175692f00cdd7803d101944..73b209f23c73f8e9f50840781706a1fb3e900ef4 100644 (file)
@@ -34,7 +34,8 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../events.h"
+#include "../buffer.h"
 
 #include "max1363.h"
 
index df6893e058ccc213e7865de647cd43839d059504..a87fbe8b0ee9700328b2f6c0e9577d6b5830761d 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/bitops.h>
 
 #include "../iio.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 #include "../ring_sw.h"
 #include "../trigger_consumer.h"
 
index 8df24704ff2648439ad5db7b103adc450e1d7729..13c39292d3f2fbb5ebad81a3ca023168d0aee152 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/module.h>
 
 #include "../iio.h"
+#include "../events.h"
 #include "../sysfs.h"
 #include "adt7316.h"
 
diff --git a/drivers/staging/iio/buffer.h b/drivers/staging/iio/buffer.h
new file mode 100644 (file)
index 0000000..9de581e
--- /dev/null
@@ -0,0 +1,227 @@
+/* The industrial I/O core - generic buffer interfaces.
+ *
+ * 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.
+ */
+
+#ifndef _IIO_BUFFER_GENERIC_H_
+#define _IIO_BUFFER_GENERIC_H_
+#include <linux/sysfs.h>
+#include "iio.h"
+
+#ifdef CONFIG_IIO_BUFFER
+
+struct iio_buffer;
+
+/**
+ * struct iio_buffer_access_funcs - access functions for buffers.
+ * @mark_in_use:       reference counting, typically to prevent module removal
+ * @unmark_in_use:     reduce reference count when no longer using buffer
+ * @store_to:          actually store stuff to the buffer
+ * @read_last:         get the last element stored
+ * @read_first_n:      try to get a specified number of elements (must exist)
+ * @mark_param_change: notify buffer that some relevant parameter has changed
+ *                     Often this means the underlying storage may need to
+ *                     change.
+ * @request_update:    if a parameter change has been marked, update underlying
+ *                     storage.
+ * @get_bytes_per_datum:get current bytes per datum
+ * @set_bytes_per_datum:set number of bytes per datum
+ * @get_length:                get number of datums in buffer
+ * @set_length:                set number of datums in buffer
+ * @is_enabled:                query if buffer is currently being used
+ * @enable:            enable the buffer
+ *
+ * The purpose of this structure is to make the buffer element
+ * modular as event for a given driver, different usecases may require
+ * different buffer designs (space efficiency vs speed for example).
+ *
+ * It is worth noting that a given buffer implementation may only support a
+ * small proportion of these functions.  The core code 'should' cope fine with
+ * any of them not existing.
+ **/
+struct iio_buffer_access_funcs {
+       void (*mark_in_use)(struct iio_buffer *buffer);
+       void (*unmark_in_use)(struct iio_buffer *buffer);
+
+       int (*store_to)(struct iio_buffer *buffer, u8 *data, s64 timestamp);
+       int (*read_last)(struct iio_buffer *buffer, u8 *data);
+       int (*read_first_n)(struct iio_buffer *buffer,
+                           size_t n,
+                           char __user *buf);
+
+       int (*mark_param_change)(struct iio_buffer *buffer);
+       int (*request_update)(struct iio_buffer *buffer);
+
+       int (*get_bytes_per_datum)(struct iio_buffer *buffer);
+       int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
+       int (*get_length)(struct iio_buffer *buffer);
+       int (*set_length)(struct iio_buffer *buffer, int length);
+
+       int (*is_enabled)(struct iio_buffer *buffer);
+       int (*enable)(struct iio_buffer *buffer);
+};
+
+/**
+ * struct iio_buffer_setup_ops - buffer setup related callbacks
+ * @preenable:         [DRIVER] function to run prior to marking buffer enabled
+ * @postenable:                [DRIVER] function to run after marking buffer enabled
+ * @predisable:                [DRIVER] function to run prior to marking buffer
+ *                     disabled
+ * @postdisable:       [DRIVER] function to run after marking buffer disabled
+ */
+struct iio_buffer_setup_ops {
+       int                             (*preenable)(struct iio_dev *);
+       int                             (*postenable)(struct iio_dev *);
+       int                             (*predisable)(struct iio_dev *);
+       int                             (*postdisable)(struct iio_dev *);
+};
+
+/**
+ * struct iio_buffer - general buffer structure
+ * @indio_dev:         industrial I/O device structure
+ * @owner:             module that owns the buffer (for ref counting)
+ * @length:            [DEVICE] number of datums in buffer
+ * @bytes_per_datum:   [DEVICE] size of individual datum including timestamp
+ * @bpe:               [DEVICE] size of individual channel value
+ * @scan_el_attrs:     [DRIVER] control of scan elements if that scan mode
+ *                     control method is used
+ * @scan_count:        [INTERN] the number of elements in the current scan mode
+ * @scan_mask:         [INTERN] bitmask used in masking scan mode elements
+ * @scan_timestamp:    [INTERN] does the scan mode include a timestamp
+ * @access:            [DRIVER] buffer access functions associated with the
+ *                     implementation.
+ * @flags:             [INTERN] file ops related flags including busy flag.
+ **/
+struct iio_buffer {
+       struct iio_dev                          *indio_dev;
+       struct module                           *owner;
+       int                                     length;
+       int                                     bytes_per_datum;
+       int                                     bpe;
+       struct attribute_group                  *scan_el_attrs;
+       int                                     scan_count;
+       long                                    *scan_mask;
+       bool                                    scan_timestamp;
+       const struct iio_buffer_access_funcs    *access;
+       const struct iio_buffer_setup_ops               *setup_ops;
+       struct list_head                        scan_el_dev_attr_list;
+       struct attribute_group                  scan_el_group;
+       wait_queue_head_t                       pollq;
+       bool                                    stufftoread;
+       unsigned long                           flags;
+       const struct attribute_group *attrs;
+};
+
+/**
+ * iio_buffer_init() - Initialize the buffer structure
+ * @buffer: buffer to be initialized
+ * @indio_dev: the iio device the buffer is assocated with
+ **/
+void iio_buffer_init(struct iio_buffer *buffer,
+                         struct iio_dev *indio_dev);
+
+void iio_buffer_deinit(struct iio_buffer *buffer);
+
+/**
+ * __iio_update_buffer() - update common elements of buffers
+ * @buffer:            buffer that is the event source
+ * @bytes_per_datum:   size of individual datum including timestamp
+ * @length:            number of datums in buffer
+ **/
+static inline void __iio_update_buffer(struct iio_buffer *buffer,
+                                      int bytes_per_datum, int length)
+{
+       buffer->bytes_per_datum = bytes_per_datum;
+       buffer->length = length;
+}
+
+int iio_scan_mask_query(struct iio_buffer *buffer, int bit);
+
+/**
+ * iio_scan_mask_set() - set particular bit in the scan mask
+ * @buffer: the buffer whose scan mask we are interested in
+ * @bit: the bit to be set.
+ **/
+int iio_scan_mask_set(struct iio_buffer *buffer, int bit);
+
+#define to_iio_buffer(d)                               \
+       container_of(d, struct iio_buffer, dev)
+
+/**
+ * iio_buffer_register() - register the buffer with IIO core
+ * @indio_dev: device with the buffer to be registered
+ **/
+int iio_buffer_register(struct iio_dev *indio_dev,
+                       const struct iio_chan_spec *channels,
+                       int num_channels);
+
+/**
+ * iio_buffer_unregister() - unregister the buffer from IIO core
+ * @indio_dev: the device with the buffer to be unregistered
+ **/
+void iio_buffer_unregister(struct iio_dev *indio_dev);
+
+/**
+ * iio_buffer_read_length() - attr func to get number of datums in the buffer
+ **/
+ssize_t iio_buffer_read_length(struct device *dev,
+                              struct device_attribute *attr,
+                              char *buf);
+/**
+ * iio_buffer_write_length() - attr func to set number of datums in the buffer
+ **/
+ssize_t iio_buffer_write_length(struct device *dev,
+                             struct device_attribute *attr,
+                             const char *buf,
+                             size_t len);
+/**
+ * iio_buffer_read_bytes_per_datum() - attr for number of bytes in whole datum
+ **/
+ssize_t iio_buffer_read_bytes_per_datum(struct device *dev,
+                                       struct device_attribute *attr,
+                                       char *buf);
+/**
+ * iio_buffer_store_enable() - attr to turn the buffer on
+ **/
+ssize_t iio_buffer_store_enable(struct device *dev,
+                               struct device_attribute *attr,
+                               const char *buf,
+                               size_t len);
+/**
+ * iio_buffer_show_enable() - attr to see if the buffer is on
+ **/
+ssize_t iio_buffer_show_enable(struct device *dev,
+                              struct device_attribute *attr,
+                              char *buf);
+#define IIO_BUFFER_LENGTH_ATTR DEVICE_ATTR(length, S_IRUGO | S_IWUSR,  \
+                                          iio_buffer_read_length,      \
+                                          iio_buffer_write_length)
+#define IIO_BUFFER_BYTES_PER_DATUM_ATTR                                        \
+       DEVICE_ATTR(bytes_per_datum, S_IRUGO | S_IWUSR,                 \
+                   iio_buffer_read_bytes_per_datum, NULL)
+
+#define IIO_BUFFER_ENABLE_ATTR DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,  \
+                                          iio_buffer_show_enable,      \
+                                          iio_buffer_store_enable)
+
+int iio_sw_buffer_preenable(struct iio_dev *indio_dev);
+
+#else /* CONFIG_IIO_BUFFER */
+
+static inline int iio_buffer_register(struct iio_dev *indio_dev,
+                                          struct iio_chan_spec *channels,
+                                          int num_channels)
+{
+       return 0;
+}
+
+static inline void iio_buffer_unregister(struct iio_dev *indio_dev)
+{};
+
+#endif /* CONFIG_IIO_BUFFER */
+
+#endif /* _IIO_BUFFER_GENERIC_H_ */
diff --git a/drivers/staging/iio/buffer_generic.h b/drivers/staging/iio/buffer_generic.h
deleted file mode 100644 (file)
index 9e8f010..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-/* The industrial I/O core - generic buffer interfaces.
- *
- * 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.
- */
-
-#ifndef _IIO_BUFFER_GENERIC_H_
-#define _IIO_BUFFER_GENERIC_H_
-#include <linux/sysfs.h>
-#include "iio.h"
-#include "chrdev.h"
-
-#ifdef CONFIG_IIO_BUFFER
-
-struct iio_buffer;
-
-/**
- * struct iio_buffer_access_funcs - access functions for buffers.
- * @mark_in_use:       reference counting, typically to prevent module removal
- * @unmark_in_use:     reduce reference count when no longer using buffer
- * @store_to:          actually store stuff to the buffer
- * @read_last:         get the last element stored
- * @read_first_n:      try to get a specified number of elements (must exist)
- * @mark_param_change: notify buffer that some relevant parameter has changed
- *                     Often this means the underlying storage may need to
- *                     change.
- * @request_update:    if a parameter change has been marked, update underlying
- *                     storage.
- * @get_bytes_per_datum:get current bytes per datum
- * @set_bytes_per_datum:set number of bytes per datum
- * @get_length:                get number of datums in buffer
- * @set_length:                set number of datums in buffer
- * @is_enabled:                query if buffer is currently being used
- * @enable:            enable the buffer
- *
- * The purpose of this structure is to make the buffer element
- * modular as event for a given driver, different usecases may require
- * different buffer designs (space efficiency vs speed for example).
- *
- * It is worth noting that a given buffer implementation may only support a
- * small proportion of these functions.  The core code 'should' cope fine with
- * any of them not existing.
- **/
-struct iio_buffer_access_funcs {
-       void (*mark_in_use)(struct iio_buffer *buffer);
-       void (*unmark_in_use)(struct iio_buffer *buffer);
-
-       int (*store_to)(struct iio_buffer *buffer, u8 *data, s64 timestamp);
-       int (*read_last)(struct iio_buffer *buffer, u8 *data);
-       int (*read_first_n)(struct iio_buffer *buffer,
-                           size_t n,
-                           char __user *buf);
-
-       int (*mark_param_change)(struct iio_buffer *buffer);
-       int (*request_update)(struct iio_buffer *buffer);
-
-       int (*get_bytes_per_datum)(struct iio_buffer *buffer);
-       int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
-       int (*get_length)(struct iio_buffer *buffer);
-       int (*set_length)(struct iio_buffer *buffer, int length);
-
-       int (*is_enabled)(struct iio_buffer *buffer);
-       int (*enable)(struct iio_buffer *buffer);
-};
-
-/**
- * struct iio_buffer_setup_ops - buffer setup related callbacks
- * @preenable:         [DRIVER] function to run prior to marking buffer enabled
- * @postenable:                [DRIVER] function to run after marking buffer enabled
- * @predisable:                [DRIVER] function to run prior to marking buffer
- *                     disabled
- * @postdisable:       [DRIVER] function to run after marking buffer disabled
- */
-struct iio_buffer_setup_ops {
-       int                             (*preenable)(struct iio_dev *);
-       int                             (*postenable)(struct iio_dev *);
-       int                             (*predisable)(struct iio_dev *);
-       int                             (*postdisable)(struct iio_dev *);
-};
-
-/**
- * struct iio_buffer - general buffer structure
- * @indio_dev:         industrial I/O device structure
- * @owner:             module that owns the buffer (for ref counting)
- * @length:            [DEVICE] number of datums in buffer
- * @bytes_per_datum:   [DEVICE] size of individual datum including timestamp
- * @bpe:               [DEVICE] size of individual channel value
- * @scan_el_attrs:     [DRIVER] control of scan elements if that scan mode
- *                     control method is used
- * @scan_count:        [INTERN] the number of elements in the current scan mode
- * @scan_mask:         [INTERN] bitmask used in masking scan mode elements
- * @scan_timestamp:    [INTERN] does the scan mode include a timestamp
- * @access:            [DRIVER] buffer access functions associated with the
- *                     implementation.
- * @flags:             [INTERN] file ops related flags including busy flag.
- **/
-struct iio_buffer {
-       struct iio_dev                          *indio_dev;
-       struct module                           *owner;
-       int                                     length;
-       int                                     bytes_per_datum;
-       int                                     bpe;
-       struct attribute_group                  *scan_el_attrs;
-       int                                     scan_count;
-       long                                    *scan_mask;
-       bool                                    scan_timestamp;
-       const struct iio_buffer_access_funcs    *access;
-       const struct iio_buffer_setup_ops               *setup_ops;
-       struct list_head                        scan_el_dev_attr_list;
-       struct attribute_group                  scan_el_group;
-       wait_queue_head_t                       pollq;
-       bool                                    stufftoread;
-       unsigned long                           flags;
-       const struct attribute_group *attrs;
-};
-
-/**
- * iio_buffer_init() - Initialize the buffer structure
- * @buffer: buffer to be initialized
- * @indio_dev: the iio device the buffer is assocated with
- **/
-void iio_buffer_init(struct iio_buffer *buffer,
-                         struct iio_dev *indio_dev);
-
-void iio_buffer_deinit(struct iio_buffer *buffer);
-
-/**
- * __iio_update_buffer() - update common elements of buffers
- * @buffer:            buffer that is the event source
- * @bytes_per_datum:   size of individual datum including timestamp
- * @length:            number of datums in buffer
- **/
-static inline void __iio_update_buffer(struct iio_buffer *buffer,
-                                      int bytes_per_datum, int length)
-{
-       buffer->bytes_per_datum = bytes_per_datum;
-       buffer->length = length;
-}
-
-int iio_scan_mask_query(struct iio_buffer *buffer, int bit);
-
-/**
- * iio_scan_mask_set() - set particular bit in the scan mask
- * @buffer: the buffer whose scan mask we are interested in
- * @bit: the bit to be set.
- **/
-int iio_scan_mask_set(struct iio_buffer *buffer, int bit);
-
-#define to_iio_buffer(d)                               \
-       container_of(d, struct iio_buffer, dev)
-
-/**
- * iio_buffer_register() - register the buffer with IIO core
- * @indio_dev: device with the buffer to be registered
- **/
-int iio_buffer_register(struct iio_dev *indio_dev,
-                       const struct iio_chan_spec *channels,
-                       int num_channels);
-
-/**
- * iio_buffer_unregister() - unregister the buffer from IIO core
- * @indio_dev: the device with the buffer to be unregistered
- **/
-void iio_buffer_unregister(struct iio_dev *indio_dev);
-
-/**
- * iio_buffer_read_length() - attr func to get number of datums in the buffer
- **/
-ssize_t iio_buffer_read_length(struct device *dev,
-                              struct device_attribute *attr,
-                              char *buf);
-/**
- * iio_buffer_write_length() - attr func to set number of datums in the buffer
- **/
-ssize_t iio_buffer_write_length(struct device *dev,
-                             struct device_attribute *attr,
-                             const char *buf,
-                             size_t len);
-/**
- * iio_buffer_read_bytes_per_datum() - attr for number of bytes in whole datum
- **/
-ssize_t iio_buffer_read_bytes_per_datum(struct device *dev,
-                                       struct device_attribute *attr,
-                                       char *buf);
-/**
- * iio_buffer_store_enable() - attr to turn the buffer on
- **/
-ssize_t iio_buffer_store_enable(struct device *dev,
-                               struct device_attribute *attr,
-                               const char *buf,
-                               size_t len);
-/**
- * iio_buffer_show_enable() - attr to see if the buffer is on
- **/
-ssize_t iio_buffer_show_enable(struct device *dev,
-                              struct device_attribute *attr,
-                              char *buf);
-#define IIO_BUFFER_LENGTH_ATTR DEVICE_ATTR(length, S_IRUGO | S_IWUSR,  \
-                                          iio_buffer_read_length,      \
-                                          iio_buffer_write_length)
-#define IIO_BUFFER_BYTES_PER_DATUM_ATTR                                        \
-       DEVICE_ATTR(bytes_per_datum, S_IRUGO | S_IWUSR,                 \
-                   iio_buffer_read_bytes_per_datum, NULL)
-
-#define IIO_BUFFER_ENABLE_ATTR DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,  \
-                                          iio_buffer_show_enable,      \
-                                          iio_buffer_store_enable)
-
-int iio_sw_buffer_preenable(struct iio_dev *indio_dev);
-
-#else /* CONFIG_IIO_BUFFER */
-
-static inline int iio_buffer_register(struct iio_dev *indio_dev,
-                                          struct iio_chan_spec *channels,
-                                          int num_channels)
-{
-       return 0;
-}
-
-static inline void iio_buffer_unregister(struct iio_dev *indio_dev)
-{};
-
-#endif /* CONFIG_IIO_BUFFER */
-
-#endif /* _IIO_BUFFER_GENERIC_H_ */
index a761ca94a17e26d77e2cbce9a7f5b74dc4ea1fda..abe65096c11040e69475825f509d4919521c5312 100644 (file)
@@ -15,7 +15,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-
+#include "../events.h"
 /*
  * AD7150 registers definition
  */
diff --git a/drivers/staging/iio/chrdev.h b/drivers/staging/iio/chrdev.h
deleted file mode 100644 (file)
index d8e736f..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* The industrial I/O core - character device related
- *
- * 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.
- */
-
-#ifndef _IIO_CHRDEV_H_
-#define _IIO_CHRDEV_H_
-
-/**
- * struct iio_event_data - The actual event being pushed to userspace
- * @id:                event identifier
- * @timestamp: best estimate of time of event occurrence (often from
- *             the interrupt handler)
- */
-struct iio_event_data {
-       u64     id;
-       s64     timestamp;
-};
-
-#define IIO_GET_EVENT_FD_IOCTL _IOR('i', 0x90, int)
-#endif
index 60dd6404d689d2dafa0805eb132432588475fc79..72040cc7376407fb0eee0f2beafd0a557b736921 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
+#include "../events.h"
 #include "dac.h"
 #include "ad5504.h"
 
diff --git a/drivers/staging/iio/events.h b/drivers/staging/iio/events.h
new file mode 100644 (file)
index 0000000..08cf3d1
--- /dev/null
@@ -0,0 +1,72 @@
+/* The industrial I/O - event passing to userspace
+ *
+ * Copyright (c) 2008-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_EVENTS_H_
+#define _IIO_EVENTS_H_
+
+#include <linux/ioctl.h>
+#include "types.h"
+
+/**
+ * struct iio_event_data - The actual event being pushed to userspace
+ * @id:                event identifier
+ * @timestamp: best estimate of time of event occurrence (often from
+ *             the interrupt handler)
+ */
+struct iio_event_data {
+       u64     id;
+       s64     timestamp;
+};
+
+#define IIO_GET_EVENT_FD_IOCTL _IOR('i', 0x90, int)
+
+enum iio_event_type {
+       IIO_EV_TYPE_THRESH,
+       IIO_EV_TYPE_MAG,
+       IIO_EV_TYPE_ROC,
+       IIO_EV_TYPE_THRESH_ADAPTIVE,
+       IIO_EV_TYPE_MAG_ADAPTIVE,
+};
+
+enum iio_event_direction {
+       IIO_EV_DIR_EITHER,
+       IIO_EV_DIR_RISING,
+       IIO_EV_DIR_FALLING,
+};
+
+#define IIO_EVENT_CODE(chan_type, diff, modifier, direction,           \
+                      type, chan, chan1, chan2)                        \
+       (((u64)type << 56) | ((u64)diff << 55) |                        \
+        ((u64)direction << 48) | ((u64)modifier << 40) |               \
+        ((u64)chan_type << 32) | (chan2 << 16) | chan1 | chan)
+
+
+#define IIO_EV_DIR_MAX 4
+#define IIO_EV_BIT(type, direction)                    \
+       (1 << (type*IIO_EV_DIR_MAX + direction))
+
+#define IIO_MOD_EVENT_CODE(channelclass, number, modifier,             \
+                          type, direction)                             \
+       IIO_EVENT_CODE(channelclass, 0, modifier, direction, type, number, 0, 0)
+
+#define IIO_UNMOD_EVENT_CODE(channelclass, number, type, direction)    \
+       IIO_EVENT_CODE(channelclass, 0, 0, direction, type, number, 0, 0)
+
+#define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF)
+
+#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xCF)
+
+#define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF)
+
+/* Event code number extraction depends on which type of event we have.
+ * Perhaps review this function in the future*/
+#define IIO_EVENT_CODE_EXTRACT_NUM(mask) (mask & 0xFFFF)
+
+#define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 40) & 0xFF)
+
+#endif
index aaa3967f8c03c562a67bf0a346a10a73d1a3ffda..40da95554fa2cff9d4724d029ad02aceaafc8d3a 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 
 #include "adis16260.h"
 
index f3d88cd7e8a0698992eb36636a63a7d3e37ff026..cf95f74dc9db047a98718fb5016c5645af98391c 100644 (file)
@@ -7,13 +7,12 @@
  * under the terms of the GNU General Public License version 2 as published by
  * the Free Software Foundation.
  */
-
 #ifndef _INDUSTRIAL_IO_H_
 #define _INDUSTRIAL_IO_H_
 
 #include <linux/device.h>
 #include <linux/cdev.h>
-
+#include "types.h"
 /* IIO TODO LIST */
 /*
  * Provide means of adjusting timer accuracy.
@@ -25,42 +24,6 @@ enum iio_data_type {
        IIO_PROCESSED,
 };
 
-enum iio_chan_type {
-       /* real channel types */
-       IIO_VOLTAGE,
-       IIO_CURRENT,
-       IIO_POWER,
-       IIO_ACCEL,
-       IIO_ANGL_VEL,
-       IIO_MAGN,
-       IIO_LIGHT,
-       IIO_INTENSITY,
-       IIO_PROXIMITY,
-       IIO_TEMP,
-       IIO_INCLI,
-       IIO_ROT,
-       IIO_ANGL,
-       IIO_TIMESTAMP,
-       IIO_CAPACITANCE,
-};
-
-enum iio_modifier {
-       IIO_NO_MOD,
-       IIO_MOD_X,
-       IIO_MOD_Y,
-       IIO_MOD_Z,
-       IIO_MOD_X_AND_Y,
-       IIO_MOD_X_ANX_Z,
-       IIO_MOD_Y_AND_Z,
-       IIO_MOD_X_AND_Y_AND_Z,
-       IIO_MOD_X_OR_Y,
-       IIO_MOD_X_OR_Z,
-       IIO_MOD_Y_OR_Z,
-       IIO_MOD_X_OR_Y_OR_Z,
-       IIO_MOD_LIGHT_BOTH,
-       IIO_MOD_LIGHT_IR,
-};
-
 /* Could add the raw attributes as well - allowing buffer only devices */
 enum iio_chan_info_enum {
        IIO_CHAN_INFO_SCALE_SHARED,
index af0c99236d4f5ac76b754e63a7548498aae612de..06c022e20943ae734e243b84da08fc5b6880fe6e 100644 (file)
@@ -21,7 +21,8 @@
 
 #include "iio.h"
 #include "sysfs.h"
-#include "buffer_generic.h"
+#include "events.h"
+#include "buffer.h"
 #include "iio_simple_dummy.h"
 
 /*
index 9f00cff7ddd505d8a7ef8dc8d2995ca703b3ca4f..449c7a5ece800392fba63b150c4639ab0ee95062 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "iio.h"
 #include "sysfs.h"
+#include "events.h"
 #include "iio_simple_dummy.h"
 
 /* Evgen 'fakes' interrupt events for this example */
index ece770766426f9255603c913631143b79d9ffc00..430743dfe9e05596758a584bc2276fa89e0a12a2 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 #include "../ring_sw.h"
 
 #include "ad5933.h"
index d082a37c4fb75433d5643cc1f3af83952000e0b6..e6df4921b55b24174b3c9f256d1fa664c583d8a9 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 #include "adis16400.h"
 
 enum adis16400_chip_variant {
index ecf1e2f6d2dc280e4b29749d8251710a18c91144..f757bb78d88e649280e0ca2e1efcf224459d9632 100644 (file)
@@ -24,7 +24,7 @@
 #include "iio.h"
 #include "iio_core.h"
 #include "sysfs.h"
-#include "buffer_generic.h"
+#include "buffer.h"
 
 static const char * const iio_endian_prefix[] = {
        [IIO_BE] = "be",
index f5c111cb1dba43310424857638d1fa1d6ea10dee..1c53b9acae81029dd7b9c14d14ee17baae84e1be 100644 (file)
@@ -25,8 +25,8 @@
 #include "iio.h"
 #include "iio_core.h"
 #include "iio_core_trigger.h"
-#include "chrdev.h"
 #include "sysfs.h"
+#include "events.h"
 
 /* IDA to assign each registered device a unique id*/
 static DEFINE_IDA(iio_ida);
index a15598bb9fdb33898b8ad9aaa9dce752bc7d10a1..cc2bd9a1ccfe66b2d13934b16c7219a243ffd636 100644 (file)
@@ -1,7 +1,7 @@
 
 #include <linux/kfifo.h>
 #include "iio.h"
-#include "buffer_generic.h"
+#include "buffer.h"
 
 extern const struct iio_buffer_access_funcs kfifo_access_funcs;
 
index 6a1794508f67f9d29818381d98c6a91177dd2d50..32dfce0a644fcd37628aae60bad106cb2c8484a6 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
+#include "../events.h"
 #include "tsl2563.h"
 
 /* Use this many bits for fraction part. */
index c5dafbdf3bda604bbf928316ab88923ef3ff37fe..7028e87acb4130808d8630908c9ff95f0b3a7565 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../buffer_generic.h"
+#include "../buffer.h"
 #include "meter.h"
 #include "ade7758.h"
 
index a3e15784c2259fc6e6a4e73debe1dba8dcc6e881..e6a6e2c409600e57b6fc6fe3661b1b4cc26e5a5f 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifndef _IIO_RING_SW_H_
 #define _IIO_RING_SW_H_
-#include "buffer_generic.h"
+#include "buffer.h"
 
 /**
  * ring_sw_access_funcs - access functions for a software ring buffer
index 868952b5ba63b56529badf4376e3e259272fb675..bfedb73b850e4f44a17f8c1aa5d578539978319b 100644 (file)
@@ -114,47 +114,4 @@ struct iio_const_attr {
 #define IIO_CONST_ATTR_TEMP_SCALE(_string)             \
        IIO_CONST_ATTR(in_temp_scale, _string)
 
-enum iio_event_type {
-       IIO_EV_TYPE_THRESH,
-       IIO_EV_TYPE_MAG,
-       IIO_EV_TYPE_ROC,
-       IIO_EV_TYPE_THRESH_ADAPTIVE,
-       IIO_EV_TYPE_MAG_ADAPTIVE,
-};
-
-enum iio_event_direction {
-       IIO_EV_DIR_EITHER,
-       IIO_EV_DIR_RISING,
-       IIO_EV_DIR_FALLING,
-};
-
-#define IIO_EVENT_CODE(chan_type, diff, modifier, direction,           \
-                      type, chan, chan1, chan2)                        \
-       (((u64)type << 56) | ((u64)diff << 55) |                        \
-        ((u64)direction << 48) | ((u64)modifier << 40) |               \
-        ((u64)chan_type << 32) | (chan2 << 16) | chan1 | chan)
-
-#define IIO_EV_DIR_MAX 4
-#define IIO_EV_BIT(type, direction)                    \
-       (1 << (type*IIO_EV_DIR_MAX + direction))
-
-#define IIO_MOD_EVENT_CODE(channelclass, number, modifier,             \
-                          type, direction)                             \
-       IIO_EVENT_CODE(channelclass, 0, modifier, direction, type, number, 0, 0)
-
-#define IIO_UNMOD_EVENT_CODE(channelclass, number, type, direction)    \
-       IIO_EVENT_CODE(channelclass, 0, 0, direction, type, number, 0, 0)
-
-#define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF)
-
-#define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0xCF)
-
-#define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF)
-
-/* Event code number extraction depends on which type of event we have.
- * Perhaps review this function in the future*/
-#define IIO_EVENT_CODE_EXTRACT_NUM(mask) (mask & 0xFFFF)
-
-#define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 40) & 0xFF)
-
 #endif /* _INDUSTRIAL_IO_SYSFS_H_ */
diff --git a/drivers/staging/iio/types.h b/drivers/staging/iio/types.h
new file mode 100644 (file)
index 0000000..f1f5ca2
--- /dev/null
@@ -0,0 +1,49 @@
+/* industrial I/O data types needed both in and out of kernel
+ *
+ * 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.
+ */
+
+#ifndef _IIO_TYPES_H_
+#define _IIO_TYPES_H_
+
+enum iio_chan_type {
+       /* real channel types */
+       IIO_VOLTAGE,
+       IIO_CURRENT,
+       IIO_POWER,
+       IIO_ACCEL,
+       IIO_ANGL_VEL,
+       IIO_MAGN,
+       IIO_LIGHT,
+       IIO_INTENSITY,
+       IIO_PROXIMITY,
+       IIO_TEMP,
+       IIO_INCLI,
+       IIO_ROT,
+       IIO_ANGL,
+       IIO_TIMESTAMP,
+       IIO_CAPACITANCE,
+};
+
+enum iio_modifier {
+       IIO_NO_MOD,
+       IIO_MOD_X,
+       IIO_MOD_Y,
+       IIO_MOD_Z,
+       IIO_MOD_X_AND_Y,
+       IIO_MOD_X_ANX_Z,
+       IIO_MOD_Y_AND_Z,
+       IIO_MOD_X_AND_Y_AND_Z,
+       IIO_MOD_X_OR_Y,
+       IIO_MOD_X_OR_Z,
+       IIO_MOD_Y_OR_Z,
+       IIO_MOD_X_OR_Y_OR_Z,
+       IIO_MOD_LIGHT_BOTH,
+       IIO_MOD_LIGHT_IR,
+};
+
+#endif /* _IIO_TYPES_H_ */