staging:iio: rename ring_generic.h -> buffer_generic.h
authorJonathan Cameron <jic23@cam.ac.uk>
Wed, 21 Sep 2011 10:15:56 +0000 (11:15 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 27 Sep 2011 00:31:53 +0000 (17:31 -0700)
Nothing in this file is specific to RING buffers so rename it.

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
32 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/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/ad7780.c
drivers/staging/iio/adc/ad7793.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/max1363_core.c
drivers/staging/iio/adc/max1363_ring.c
drivers/staging/iio/buffer_generic.h [new file with mode: 0644]
drivers/staging/iio/gyro/adis16260_core.c
drivers/staging/iio/impedance-analyzer/ad5933.c
drivers/staging/iio/imu/adis16400_core.c
drivers/staging/iio/industrialio-ring.c
drivers/staging/iio/kfifo_buf.h
drivers/staging/iio/meter/ade7758_core.c
drivers/staging/iio/ring_generic.h [deleted file]
drivers/staging/iio/ring_sw.h

index 2785460b38532708052094a6d90797c508ac2c00..eb6a1a8b0825e2e72b035c307c8b8552935b9e36 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "adis16201.h"
 
index 27079a95d4b19dc07e08a784603b7ef632607414..561e7a9f7d40a1e8ac7b93fa22bfab5d04b7996f 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "adis16203.h"
 
index b0d6a2e725777f8600d557c0c8a543691fa8d44a..507f282ac30e6a5b63d821abd57ebb4ba529489d 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "adis16204.h"
 
index 97dca8866df45fa676734b9b69b6ec307d226e6b..2dd24c3e5cd7d1977b4aae4690051eaad763d8fa 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "adis16209.h"
 
index 282a746dc5dd9e2fc62c2c03887dff8755f97779..10e02498861fde10f24b5836fc88869c8b79140c 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "adis16240.h"
 
index 6d600f68c1d2e258a14e02798c68626ac4b1d06a..fd53fd51ebfa3946732aefa2437fc7462c442d52 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "lis3l02dq.h"
 
index 394b04eb1aa7f7eeb2f7c9fb3692d8f39cc71ca5..2fe35788da48c9cde0584d6d8fbaffb574f86158 100644 (file)
@@ -21,7 +21,7 @@
 #include <linux/module.h>
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "sca3000.h"
 
index 2a83e8aa81576f1bdd263ff8c226cc4765bebaa0..f5198578c6a02dcc2e9e1dc868ec3cb45eddfb87 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 #include "../ring_hw.h"
 #include "sca3000.h"
 
index 4b5649085a25b3c6766eadc2ee092438c9de9b07..8d080ab68a3a02fc625a3ba30cf74bd227c4425e 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 #include "../ring_sw.h"
 #include "../trigger.h"
 #include "../trigger_consumer.h"
index a627bfe208af0b0590c9fcd5d905be6b3c41c4a8..cf91ccd8543cc94d619505f514ccfa44433001ca 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "ad7298.h"
 
index 2315ee98913126170997369f1a34f0c482d57bf6..1cd5f61ed7d62a6ff32b0311bdaa520089d83fc1 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/spi/spi.h>
 
 #include "../iio.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 #include "../ring_sw.h"
 #include "../trigger_consumer.h"
 
index edf25ce897078fb511fbe6f67f48f00bc4bc4aee..d574a2ee9adfb1559712db3ce3d39211b79b6a13 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "ad7476.h"
 
index e48181a56ad1f933c9a4fd9c8bcd2619925cc8fc..854d94971fc4cdb67818a9fbade4c4566b239fdb 100644 (file)
@@ -14,7 +14,7 @@
 #include <linux/spi/spi.h>
 
 #include "../iio.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 #include "../ring_sw.h"
 #include "../trigger_consumer.h"
 
index f22f668c6bcfc22450358f72961ccb5477172fe7..f8eba67833403ccb633e616fc864cc4b72742bb9 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "ad7606.h"
 
index 15bdec6831721687b306d33b6a89ecf76f5de3f8..20afb3e24abe9a9ed0b198bf503777b34da9f73d 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/slab.h>
 
 #include "../iio.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 #include "../ring_sw.h"
 #include "../trigger_consumer.h"
 
index 46d1f8f3fe82a832dead752a2b578588c5b0c16d..4b6f8c6640ead903ace3d60cb0350449851fdf92 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
 
 #include "ad7780.h"
 
index e21593d097a5d122cfbfbe001d83798424d6d81c..11ba79e476ebdc2a4bff6f5b40cc8f8d9420306d 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 #include "../ring_sw.h"
 #include "../trigger.h"
 #include "../trigger_consumer.h"
index cdd7c130aa165ca640134816533ee1999bdd69f1..4a8ffb5735b5e1b6fc1b7a3327a39f04a8f3aa16 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 
 #include "ad7887.h"
index 678c877eba85fb4cefd3c543172f6dc435810b07..96274d6057d9b0ba16dd513d944a2e6e8dad7b88 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/spi/spi.h>
 
 #include "../iio.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 #include "../ring_sw.h"
 #include "../trigger_consumer.h"
 
index ae64ee95cdd04210a8da7ef7588f9b001145c76c..d5fbda7857cd666e51fd48a278f80d9192ca8a28 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "ad799x.h"
 
index 8177de5277e4687ecc920012cf0ad9c40ccc10de..c1d38c589ecd4eed39c84bf1e3bf4cf510f82074 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/bitops.h>
 
 #include "../iio.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 #include "../ring_sw.h"
 #include "../trigger_consumer.h"
 
index b7c46aeceb5bbe80fca21e4f14cbbc245de2dbe5..e0f87917051c428885df6c5e30a1f9a47e7843d9 100644 (file)
@@ -34,7 +34,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "max1363.h"
 
index 570c68650c8c282403139a83b9d21aedb9bd0e9d..91e29c5abc68bf4b8ec2ae0ffa1bbeecd04ade84 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/bitops.h>
 
 #include "../iio.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 #include "../ring_sw.h"
 #include "../trigger_consumer.h"
 
diff --git a/drivers/staging/iio/buffer_generic.h b/drivers/staging/iio/buffer_generic.h
new file mode 100644 (file)
index 0000000..a1256c1
--- /dev/null
@@ -0,0 +1,226 @@
+/* The industrial I/O core - generic ring 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_ring_buffer;
+
+/**
+ * struct iio_ring_access_funcs - access functions for ring buffers.
+ * @mark_in_use:       reference counting, typically to prevent module removal
+ * @unmark_in_use:     reduce reference count when no longer using ring buffer
+ * @store_to:          actually store stuff to the ring 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 ring 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 ring
+ * @set_length:                set number of datums in ring
+ * @is_enabled:                query if ring is currently being used
+ * @enable:            enable the ring
+ *
+ * The purpose of this structure is to make the ring buffer element
+ * modular as event for a given driver, different usecases may require
+ * different ring designs (space efficiency vs speed for example).
+ *
+ * It is worth noting that a given ring implementation may only support a small
+ * proportion of these functions.  The core code 'should' cope fine with any of
+ * them not existing.
+ **/
+struct iio_ring_access_funcs {
+       void (*mark_in_use)(struct iio_ring_buffer *ring);
+       void (*unmark_in_use)(struct iio_ring_buffer *ring);
+
+       int (*store_to)(struct iio_ring_buffer *ring, u8 *data, s64 timestamp);
+       int (*read_last)(struct iio_ring_buffer *ring, u8 *data);
+       int (*read_first_n)(struct iio_ring_buffer *ring,
+                           size_t n,
+                           char __user *buf);
+
+       int (*mark_param_change)(struct iio_ring_buffer *ring);
+       int (*request_update)(struct iio_ring_buffer *ring);
+
+       int (*get_bytes_per_datum)(struct iio_ring_buffer *ring);
+       int (*set_bytes_per_datum)(struct iio_ring_buffer *ring, size_t bpd);
+       int (*get_length)(struct iio_ring_buffer *ring);
+       int (*set_length)(struct iio_ring_buffer *ring, int length);
+
+       int (*is_enabled)(struct iio_ring_buffer *ring);
+       int (*enable)(struct iio_ring_buffer *ring);
+};
+
+/**
+ * struct iio_ring_setup_ops - buffer setup related callbacks
+ * @preenable:         [DRIVER] function to run prior to marking ring enabled
+ * @postenable:                [DRIVER] function to run after marking ring enabled
+ * @predisable:                [DRIVER] function to run prior to marking ring disabled
+ * @postdisable:       [DRIVER] function to run after marking ring disabled
+ */
+struct iio_ring_setup_ops {
+       int                             (*preenable)(struct iio_dev *);
+       int                             (*postenable)(struct iio_dev *);
+       int                             (*predisable)(struct iio_dev *);
+       int                             (*postdisable)(struct iio_dev *);
+};
+
+/**
+ * struct iio_ring_buffer - general ring buffer structure
+ * @dev:               ring buffer device struct
+ * @indio_dev:         industrial I/O device structure
+ * @owner:             module that owns the ring buffer (for ref counting)
+ * @length:            [DEVICE] number of datums in ring
+ * @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] ring access functions associated with the
+ *                     implementation.
+ * @flags:             [INTERN] file ops related flags including busy flag.
+ **/
+struct iio_ring_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_ring_access_funcs      *access;
+       const struct iio_ring_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_ring_buffer_init() - Initialize the buffer structure
+ * @ring: buffer to be initialized
+ * @dev_info: the iio device the buffer is assocated with
+ **/
+void iio_ring_buffer_init(struct iio_ring_buffer *ring,
+                         struct iio_dev *dev_info);
+
+void iio_ring_buffer_deinit(struct iio_ring_buffer *ring);
+
+/**
+ * __iio_update_ring_buffer() - update common elements of ring buffers
+ * @ring:              ring buffer that is the event source
+ * @bytes_per_datum:   size of individual datum including timestamp
+ * @length:            number of datums in ring
+ **/
+static inline void __iio_update_ring_buffer(struct iio_ring_buffer *ring,
+                                           int bytes_per_datum, int length)
+{
+       ring->bytes_per_datum = bytes_per_datum;
+       ring->length = length;
+}
+
+int iio_scan_mask_query(struct iio_ring_buffer *ring, int bit);
+
+/**
+ * iio_scan_mask_set() - set particular bit in the scan mask
+ * @ring: the ring buffer whose scan mask we are interested in
+ * @bit: the bit to be set.
+ **/
+int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit);
+
+#define to_iio_ring_buffer(d)                          \
+       container_of(d, struct iio_ring_buffer, dev)
+
+/**
+ * iio_ring_buffer_register() - register the buffer with IIO core
+ * @indio_dev: device with the buffer to be registered
+ **/
+int iio_ring_buffer_register(struct iio_dev *indio_dev,
+                            const struct iio_chan_spec *channels,
+                            int num_channels);
+
+/**
+ * iio_ring_buffer_unregister() - unregister the buffer from IIO core
+ * @indio_dev: the device with the buffer to be unregistered
+ **/
+void iio_ring_buffer_unregister(struct iio_dev *indio_dev);
+
+/**
+ * iio_read_ring_length() - attr func to get number of datums in the buffer
+ **/
+ssize_t iio_read_ring_length(struct device *dev,
+                            struct device_attribute *attr,
+                            char *buf);
+/**
+ * iio_write_ring_length() - attr func to set number of datums in the buffer
+ **/
+ssize_t iio_write_ring_length(struct device *dev,
+                             struct device_attribute *attr,
+                             const char *buf,
+                             size_t len);
+/**
+ * iio_read_ring_bytes_per_datum() - attr for number of bytes in whole datum
+ **/
+ssize_t iio_read_ring_bytes_per_datum(struct device *dev,
+                         struct device_attribute *attr,
+                         char *buf);
+/**
+ * iio_store_ring_enable() - attr to turn the buffer on
+ **/
+ssize_t iio_store_ring_enable(struct device *dev,
+                             struct device_attribute *attr,
+                             const char *buf,
+                             size_t len);
+/**
+ * iio_show_ring_enable() - attr to see if the buffer is on
+ **/
+ssize_t iio_show_ring_enable(struct device *dev,
+                            struct device_attribute *attr,
+                            char *buf);
+#define IIO_RING_LENGTH_ATTR DEVICE_ATTR(length, S_IRUGO | S_IWUSR,    \
+                                        iio_read_ring_length,          \
+                                        iio_write_ring_length)
+#define IIO_RING_BYTES_PER_DATUM_ATTR DEVICE_ATTR(bytes_per_datum, S_IRUGO | S_IWUSR,  \
+                                     iio_read_ring_bytes_per_datum, NULL)
+#define IIO_RING_ENABLE_ATTR DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, \
+                                        iio_show_ring_enable,          \
+                                        iio_store_ring_enable)
+
+int iio_sw_ring_preenable(struct iio_dev *indio_dev);
+
+#else /* CONFIG_IIO_BUFFER */
+
+static inline int iio_ring_buffer_register(struct iio_dev *indio_dev,
+                                          struct iio_chan_spec *channels,
+                                          int num_channels)
+{
+       return 0;
+}
+
+static inline void iio_ring_buffer_unregister(struct iio_dev *indio_dev)
+{};
+
+#endif /* CONFIG_IIO_BUFFER */
+
+#endif /* _IIO_BUFFER_GENERIC_H_ */
index 73157b21252bd14f8ef45cb139ebfa80a7be8edf..8058d6699841127dc8d57a63625cefd27820bfeb 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 
 #include "adis16260.h"
 
index 25223d8baf5163a4a1caa974243b43bbb888315c..fb8316182777bce08a791241944060d7bfed5d6d 100644 (file)
@@ -20,7 +20,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 #include "../ring_sw.h"
 
 #include "ad5933.h"
index 19dacfb6e1744e95cfbacbeb2517f8a870820c96..b041b46539daa588138fc9fedeb0431afb68aa8d 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 #include "adis16400.h"
 
 enum adis16400_chip_variant {
index e048d348bbd71d374973861ec01679d55e440eef..6f9d9e7858c73e6ffcb17c27e44fc6255ef9c030 100644 (file)
@@ -23,7 +23,7 @@
 #include "iio.h"
 #include "iio_core.h"
 #include "sysfs.h"
-#include "ring_generic.h"
+#include "buffer_generic.h"
 
 static const char * const iio_endian_prefix[] = {
        [IIO_BE] = "be",
index fb48523748e68e00e59d93f1108e29f58ec9806e..66a80c658400f171a9985eb0bc1b628e5fac8de5 100644 (file)
@@ -1,7 +1,7 @@
 
 #include <linux/kfifo.h>
 #include "iio.h"
-#include "ring_generic.h"
+#include "buffer_generic.h"
 
 extern const struct iio_ring_access_funcs kfifo_access_funcs;
 
index 1661f31184beb1a516243fc99c9dd1ce3e19a956..9a0dc1ea80e141ef900996b4c22d39fd492598ad 100644 (file)
@@ -21,7 +21,7 @@
 
 #include "../iio.h"
 #include "../sysfs.h"
-#include "../ring_generic.h"
+#include "../buffer_generic.h"
 #include "meter.h"
 #include "ade7758.h"
 
diff --git a/drivers/staging/iio/ring_generic.h b/drivers/staging/iio/ring_generic.h
deleted file mode 100644 (file)
index 6a89ec0..0000000
+++ /dev/null
@@ -1,226 +0,0 @@
-/* The industrial I/O core - generic ring 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_RING_GENERIC_H_
-#define _IIO_RING_GENERIC_H_
-#include <linux/sysfs.h>
-#include "iio.h"
-#include "chrdev.h"
-
-#ifdef CONFIG_IIO_BUFFER
-
-struct iio_ring_buffer;
-
-/**
- * struct iio_ring_access_funcs - access functions for ring buffers.
- * @mark_in_use:       reference counting, typically to prevent module removal
- * @unmark_in_use:     reduce reference count when no longer using ring buffer
- * @store_to:          actually store stuff to the ring 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 ring 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 ring
- * @set_length:                set number of datums in ring
- * @is_enabled:                query if ring is currently being used
- * @enable:            enable the ring
- *
- * The purpose of this structure is to make the ring buffer element
- * modular as event for a given driver, different usecases may require
- * different ring designs (space efficiency vs speed for example).
- *
- * It is worth noting that a given ring implementation may only support a small
- * proportion of these functions.  The core code 'should' cope fine with any of
- * them not existing.
- **/
-struct iio_ring_access_funcs {
-       void (*mark_in_use)(struct iio_ring_buffer *ring);
-       void (*unmark_in_use)(struct iio_ring_buffer *ring);
-
-       int (*store_to)(struct iio_ring_buffer *ring, u8 *data, s64 timestamp);
-       int (*read_last)(struct iio_ring_buffer *ring, u8 *data);
-       int (*read_first_n)(struct iio_ring_buffer *ring,
-                           size_t n,
-                           char __user *buf);
-
-       int (*mark_param_change)(struct iio_ring_buffer *ring);
-       int (*request_update)(struct iio_ring_buffer *ring);
-
-       int (*get_bytes_per_datum)(struct iio_ring_buffer *ring);
-       int (*set_bytes_per_datum)(struct iio_ring_buffer *ring, size_t bpd);
-       int (*get_length)(struct iio_ring_buffer *ring);
-       int (*set_length)(struct iio_ring_buffer *ring, int length);
-
-       int (*is_enabled)(struct iio_ring_buffer *ring);
-       int (*enable)(struct iio_ring_buffer *ring);
-};
-
-/**
- * struct iio_ring_setup_ops - buffer setup related callbacks
- * @preenable:         [DRIVER] function to run prior to marking ring enabled
- * @postenable:                [DRIVER] function to run after marking ring enabled
- * @predisable:                [DRIVER] function to run prior to marking ring disabled
- * @postdisable:       [DRIVER] function to run after marking ring disabled
- */
-struct iio_ring_setup_ops {
-       int                             (*preenable)(struct iio_dev *);
-       int                             (*postenable)(struct iio_dev *);
-       int                             (*predisable)(struct iio_dev *);
-       int                             (*postdisable)(struct iio_dev *);
-};
-
-/**
- * struct iio_ring_buffer - general ring buffer structure
- * @dev:               ring buffer device struct
- * @indio_dev:         industrial I/O device structure
- * @owner:             module that owns the ring buffer (for ref counting)
- * @length:            [DEVICE] number of datums in ring
- * @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] ring access functions associated with the
- *                     implementation.
- * @flags:             [INTERN] file ops related flags including busy flag.
- **/
-struct iio_ring_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_ring_access_funcs      *access;
-       const struct iio_ring_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_ring_buffer_init() - Initialize the buffer structure
- * @ring: buffer to be initialized
- * @dev_info: the iio device the buffer is assocated with
- **/
-void iio_ring_buffer_init(struct iio_ring_buffer *ring,
-                         struct iio_dev *dev_info);
-
-void iio_ring_buffer_deinit(struct iio_ring_buffer *ring);
-
-/**
- * __iio_update_ring_buffer() - update common elements of ring buffers
- * @ring:              ring buffer that is the event source
- * @bytes_per_datum:   size of individual datum including timestamp
- * @length:            number of datums in ring
- **/
-static inline void __iio_update_ring_buffer(struct iio_ring_buffer *ring,
-                                           int bytes_per_datum, int length)
-{
-       ring->bytes_per_datum = bytes_per_datum;
-       ring->length = length;
-}
-
-int iio_scan_mask_query(struct iio_ring_buffer *ring, int bit);
-
-/**
- * iio_scan_mask_set() - set particular bit in the scan mask
- * @ring: the ring buffer whose scan mask we are interested in
- * @bit: the bit to be set.
- **/
-int iio_scan_mask_set(struct iio_ring_buffer *ring, int bit);
-
-#define to_iio_ring_buffer(d)                          \
-       container_of(d, struct iio_ring_buffer, dev)
-
-/**
- * iio_ring_buffer_register() - register the buffer with IIO core
- * @indio_dev: device with the buffer to be registered
- **/
-int iio_ring_buffer_register(struct iio_dev *indio_dev,
-                            const struct iio_chan_spec *channels,
-                            int num_channels);
-
-/**
- * iio_ring_buffer_unregister() - unregister the buffer from IIO core
- * @indio_dev: the device with the buffer to be unregistered
- **/
-void iio_ring_buffer_unregister(struct iio_dev *indio_dev);
-
-/**
- * iio_read_ring_length() - attr func to get number of datums in the buffer
- **/
-ssize_t iio_read_ring_length(struct device *dev,
-                            struct device_attribute *attr,
-                            char *buf);
-/**
- * iio_write_ring_length() - attr func to set number of datums in the buffer
- **/
-ssize_t iio_write_ring_length(struct device *dev,
-                             struct device_attribute *attr,
-                             const char *buf,
-                             size_t len);
-/**
- * iio_read_ring_bytes_per_datum() - attr for number of bytes in whole datum
- **/
-ssize_t iio_read_ring_bytes_per_datum(struct device *dev,
-                         struct device_attribute *attr,
-                         char *buf);
-/**
- * iio_store_ring_enable() - attr to turn the buffer on
- **/
-ssize_t iio_store_ring_enable(struct device *dev,
-                             struct device_attribute *attr,
-                             const char *buf,
-                             size_t len);
-/**
- * iio_show_ring_enable() - attr to see if the buffer is on
- **/
-ssize_t iio_show_ring_enable(struct device *dev,
-                            struct device_attribute *attr,
-                            char *buf);
-#define IIO_RING_LENGTH_ATTR DEVICE_ATTR(length, S_IRUGO | S_IWUSR,    \
-                                        iio_read_ring_length,          \
-                                        iio_write_ring_length)
-#define IIO_RING_BYTES_PER_DATUM_ATTR DEVICE_ATTR(bytes_per_datum, S_IRUGO | S_IWUSR,  \
-                                     iio_read_ring_bytes_per_datum, NULL)
-#define IIO_RING_ENABLE_ATTR DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, \
-                                        iio_show_ring_enable,          \
-                                        iio_store_ring_enable)
-
-int iio_sw_ring_preenable(struct iio_dev *indio_dev);
-
-#else /* CONFIG_IIO_BUFFER */
-
-static inline int iio_ring_buffer_register(struct iio_dev *indio_dev,
-                                          struct iio_chan_spec *channels,
-                                          int num_channels)
-{
-       return 0;
-}
-
-static inline void iio_ring_buffer_unregister(struct iio_dev *indio_dev)
-{};
-
-#endif /* CONFIG_IIO_BUFFER */
-
-#endif /* _IIO_RING_GENERIC_H_ */
index 15271639534b16eed168a7bdbbf85bba1083b84a..2835c9940ed0e206945f582e8f213005af94e8ba 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifndef _IIO_RING_SW_H_
 #define _IIO_RING_SW_H_
-#include "ring_generic.h"
+#include "buffer_generic.h"
 
 /**
  * ring_sw_access_funcs - access functions for a software ring buffer