All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/11] buffer.h cleanup and split
@ 2017-01-02 19:28 Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 01/11] iio:buffer: Stop exporting iio_update_demux Jonathan Cameron
                   ` (11 more replies)
  0 siblings, 12 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-02 19:28 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Jonathan Cameron

This series came out of the mess that became apparant when looking at the
autogenerated docs.  As we pull the kernel-doc from buffer.h in when
describing the API the drivers use to access it we were pulling in a lot
of documentation that was irrelevant to that use case.

Hence, this series does two things:
1) Splits the buffer.h header into two parts:
   * buffer.h which just contains the stuff that drivers using buffers need.
   * buffer_impl.h which just contains the stuff related to the implementation
   of buffers
   This makes struct iio_buffer opaque to the drivers (with a few extra
   access functions and a bit of code reorganization)
2) Takes the documentation of struct iio_buffer inline, allowing fairly
   sensible use of the private: label within docs rather than our local
   iio specific tagging of documentation.  There is an oddity here in that
   I have deliberately 'broken' the kernel-doc for elements that are private
   in order to avoid lots of warnings about excess documentation.

Along the way various drivers gained additional includes that should probably
have been there in the first place.  This was needed to cleanup the includes
within the includes.  Most drivers did it 'right' anyway so this wasn't too
bad.

I'll probably follow this up with similar cleanups elsewhere at some point.

This was against 4.10-rc1 as that's where I'm working on docs, but should
go in reasonably cleanly on iio/togreg or iio/testing.

Jonathan Cameron (11):
  iio:buffer: Stop exporting iio_update_demux
  iio:buffer.h Reformat structure comments to be inline.
  iio:buffer: Introduced a function to assign the buffer specific attrs.
  iio:buffer: Stop exporting iio_scan_mask_query
  iio:buffers: Push some docs down into the .c file.
  iio:buffer:iio_push_to_buffers_with_timestamp fix kernel-doc.
  iio:kfifo_buf header include push down.
  iio:buffer.h include pushdown into buffer implementations
  iio:buffer: Push implementation of iio_device_attach_buffer into .c
    file
  iio:dummy: Stop enabling timestamp by default.
  iio:buffer.h - split into buffer.h and buffer_impl.h

 drivers/iio/accel/bmc150-accel-core.c       |   3 +-
 drivers/iio/accel/ssp_accel_sensor.c        |   1 +
 drivers/iio/adc/ina2xx-adc.c                |   2 +
 drivers/iio/buffer/industrialio-buffer-cb.c |   3 +-
 drivers/iio/buffer/kfifo_buf.c              |   2 +
 drivers/iio/common/ssp_sensors/ssp_iio.c    |   1 +
 drivers/iio/dummy/iio_simple_dummy_buffer.c |   4 +-
 drivers/iio/gyro/ssp_gyro_sensor.c          |   1 +
 drivers/iio/industrialio-buffer.c           | 321 +++++++++++++++-------------
 drivers/iio/industrialio-core.c             |   1 +
 drivers/staging/iio/meter/ade7758_ring.c    |   1 +
 include/linux/iio/buffer.h                  | 160 +-------------
 include/linux/iio/buffer_impl.h             | 162 ++++++++++++++
 include/linux/iio/kfifo_buf.h               |   5 +-
 14 files changed, 360 insertions(+), 307 deletions(-)
 create mode 100644 include/linux/iio/buffer_impl.h

-- 
2.11.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/11] iio:buffer: Stop exporting iio_update_demux
  2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
@ 2017-01-02 19:28 ` Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 02/11] iio:buffer.h Reformat structure comments to be inline Jonathan Cameron
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-02 19:28 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Jonathan Cameron

Nothing outside of indiustrialio-buffer.c should be using this.
Requires a large amount of juggling of functions to avoid a
forward definition.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/industrialio-buffer.c | 260 +++++++++++++++++++-------------------
 include/linux/iio/buffer.h        |   2 -
 2 files changed, 129 insertions(+), 133 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index b12830b09c7d..9f496eb84e0b 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -751,6 +751,135 @@ static int iio_verify_update(struct iio_dev *indio_dev,
 	return 0;
 }
 
+/**
+ * struct iio_demux_table - table describing demux memcpy ops
+ * @from:	index to copy from
+ * @to:		index to copy to
+ * @length:	how many bytes to copy
+ * @l:		list head used for management
+ */
+struct iio_demux_table {
+	unsigned from;
+	unsigned to;
+	unsigned length;
+	struct list_head l;
+};
+
+static void iio_buffer_demux_free(struct iio_buffer *buffer)
+{
+	struct iio_demux_table *p, *q;
+	list_for_each_entry_safe(p, q, &buffer->demux_list, l) {
+		list_del(&p->l);
+		kfree(p);
+	}
+}
+
+static int iio_buffer_add_demux(struct iio_buffer *buffer,
+	struct iio_demux_table **p, unsigned int in_loc, unsigned int out_loc,
+	unsigned int length)
+{
+
+	if (*p && (*p)->from + (*p)->length == in_loc &&
+		(*p)->to + (*p)->length == out_loc) {
+		(*p)->length += length;
+	} else {
+		*p = kmalloc(sizeof(**p), GFP_KERNEL);
+		if (*p == NULL)
+			return -ENOMEM;
+		(*p)->from = in_loc;
+		(*p)->to = out_loc;
+		(*p)->length = length;
+		list_add_tail(&(*p)->l, &buffer->demux_list);
+	}
+
+	return 0;
+}
+
+static int iio_buffer_update_demux(struct iio_dev *indio_dev,
+				   struct iio_buffer *buffer)
+{
+	int ret, in_ind = -1, out_ind, length;
+	unsigned in_loc = 0, out_loc = 0;
+	struct iio_demux_table *p = NULL;
+
+	/* Clear out any old demux */
+	iio_buffer_demux_free(buffer);
+	kfree(buffer->demux_bounce);
+	buffer->demux_bounce = NULL;
+
+	/* First work out which scan mode we will actually have */
+	if (bitmap_equal(indio_dev->active_scan_mask,
+			 buffer->scan_mask,
+			 indio_dev->masklength))
+		return 0;
+
+	/* Now we have the two masks, work from least sig and build up sizes */
+	for_each_set_bit(out_ind,
+			 buffer->scan_mask,
+			 indio_dev->masklength) {
+		in_ind = find_next_bit(indio_dev->active_scan_mask,
+				       indio_dev->masklength,
+				       in_ind + 1);
+		while (in_ind != out_ind) {
+			in_ind = find_next_bit(indio_dev->active_scan_mask,
+					       indio_dev->masklength,
+					       in_ind + 1);
+			length = iio_storage_bytes_for_si(indio_dev, in_ind);
+			/* Make sure we are aligned */
+			in_loc = roundup(in_loc, length) + length;
+		}
+		length = iio_storage_bytes_for_si(indio_dev, in_ind);
+		out_loc = roundup(out_loc, length);
+		in_loc = roundup(in_loc, length);
+		ret = iio_buffer_add_demux(buffer, &p, in_loc, out_loc, length);
+		if (ret)
+			goto error_clear_mux_table;
+		out_loc += length;
+		in_loc += length;
+	}
+	/* Relies on scan_timestamp being last */
+	if (buffer->scan_timestamp) {
+		length = iio_storage_bytes_for_timestamp(indio_dev);
+		out_loc = roundup(out_loc, length);
+		in_loc = roundup(in_loc, length);
+		ret = iio_buffer_add_demux(buffer, &p, in_loc, out_loc, length);
+		if (ret)
+			goto error_clear_mux_table;
+		out_loc += length;
+		in_loc += length;
+	}
+	buffer->demux_bounce = kzalloc(out_loc, GFP_KERNEL);
+	if (buffer->demux_bounce == NULL) {
+		ret = -ENOMEM;
+		goto error_clear_mux_table;
+	}
+	return 0;
+
+error_clear_mux_table:
+	iio_buffer_demux_free(buffer);
+
+	return ret;
+}
+
+static int iio_update_demux(struct iio_dev *indio_dev)
+{
+	struct iio_buffer *buffer;
+	int ret;
+
+	list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list) {
+		ret = iio_buffer_update_demux(indio_dev, buffer);
+		if (ret < 0)
+			goto error_clear_mux_table;
+	}
+	return 0;
+
+error_clear_mux_table:
+	list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list)
+		iio_buffer_demux_free(buffer);
+
+	return ret;
+}
+
 static int iio_enable_buffers(struct iio_dev *indio_dev,
 	struct iio_device_config *config)
 {
@@ -1213,20 +1342,6 @@ int iio_scan_mask_query(struct iio_dev *indio_dev,
 };
 EXPORT_SYMBOL_GPL(iio_scan_mask_query);
 
-/**
- * struct iio_demux_table - table describing demux memcpy ops
- * @from:	index to copy from
- * @to:		index to copy to
- * @length:	how many bytes to copy
- * @l:		list head used for management
- */
-struct iio_demux_table {
-	unsigned from;
-	unsigned to;
-	unsigned length;
-	struct list_head l;
-};
-
 static const void *iio_demux(struct iio_buffer *buffer,
 				 const void *datain)
 {
@@ -1258,16 +1373,6 @@ static int iio_push_to_buffer(struct iio_buffer *buffer, const void *data)
 	return 0;
 }
 
-static void iio_buffer_demux_free(struct iio_buffer *buffer)
-{
-	struct iio_demux_table *p, *q;
-	list_for_each_entry_safe(p, q, &buffer->demux_list, l) {
-		list_del(&p->l);
-		kfree(p);
-	}
-}
-
-
 int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data)
 {
 	int ret;
@@ -1283,113 +1388,6 @@ int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data)
 }
 EXPORT_SYMBOL_GPL(iio_push_to_buffers);
 
-static int iio_buffer_add_demux(struct iio_buffer *buffer,
-	struct iio_demux_table **p, unsigned int in_loc, unsigned int out_loc,
-	unsigned int length)
-{
-
-	if (*p && (*p)->from + (*p)->length == in_loc &&
-		(*p)->to + (*p)->length == out_loc) {
-		(*p)->length += length;
-	} else {
-		*p = kmalloc(sizeof(**p), GFP_KERNEL);
-		if (*p == NULL)
-			return -ENOMEM;
-		(*p)->from = in_loc;
-		(*p)->to = out_loc;
-		(*p)->length = length;
-		list_add_tail(&(*p)->l, &buffer->demux_list);
-	}
-
-	return 0;
-}
-
-static int iio_buffer_update_demux(struct iio_dev *indio_dev,
-				   struct iio_buffer *buffer)
-{
-	int ret, in_ind = -1, out_ind, length;
-	unsigned in_loc = 0, out_loc = 0;
-	struct iio_demux_table *p = NULL;
-
-	/* Clear out any old demux */
-	iio_buffer_demux_free(buffer);
-	kfree(buffer->demux_bounce);
-	buffer->demux_bounce = NULL;
-
-	/* First work out which scan mode we will actually have */
-	if (bitmap_equal(indio_dev->active_scan_mask,
-			 buffer->scan_mask,
-			 indio_dev->masklength))
-		return 0;
-
-	/* Now we have the two masks, work from least sig and build up sizes */
-	for_each_set_bit(out_ind,
-			 buffer->scan_mask,
-			 indio_dev->masklength) {
-		in_ind = find_next_bit(indio_dev->active_scan_mask,
-				       indio_dev->masklength,
-				       in_ind + 1);
-		while (in_ind != out_ind) {
-			in_ind = find_next_bit(indio_dev->active_scan_mask,
-					       indio_dev->masklength,
-					       in_ind + 1);
-			length = iio_storage_bytes_for_si(indio_dev, in_ind);
-			/* Make sure we are aligned */
-			in_loc = roundup(in_loc, length) + length;
-		}
-		length = iio_storage_bytes_for_si(indio_dev, in_ind);
-		out_loc = roundup(out_loc, length);
-		in_loc = roundup(in_loc, length);
-		ret = iio_buffer_add_demux(buffer, &p, in_loc, out_loc, length);
-		if (ret)
-			goto error_clear_mux_table;
-		out_loc += length;
-		in_loc += length;
-	}
-	/* Relies on scan_timestamp being last */
-	if (buffer->scan_timestamp) {
-		length = iio_storage_bytes_for_timestamp(indio_dev);
-		out_loc = roundup(out_loc, length);
-		in_loc = roundup(in_loc, length);
-		ret = iio_buffer_add_demux(buffer, &p, in_loc, out_loc, length);
-		if (ret)
-			goto error_clear_mux_table;
-		out_loc += length;
-		in_loc += length;
-	}
-	buffer->demux_bounce = kzalloc(out_loc, GFP_KERNEL);
-	if (buffer->demux_bounce == NULL) {
-		ret = -ENOMEM;
-		goto error_clear_mux_table;
-	}
-	return 0;
-
-error_clear_mux_table:
-	iio_buffer_demux_free(buffer);
-
-	return ret;
-}
-
-int iio_update_demux(struct iio_dev *indio_dev)
-{
-	struct iio_buffer *buffer;
-	int ret;
-
-	list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list) {
-		ret = iio_buffer_update_demux(indio_dev, buffer);
-		if (ret < 0)
-			goto error_clear_mux_table;
-	}
-	return 0;
-
-error_clear_mux_table:
-	list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list)
-		iio_buffer_demux_free(buffer);
-
-	return ret;
-}
-EXPORT_SYMBOL_GPL(iio_update_demux);
-
 /**
  * iio_buffer_release() - Free a buffer's resources
  * @ref: Pointer to the kref embedded in the iio_buffer struct
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 70a5164f4728..889d0f2f5d7b 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -168,8 +168,6 @@ static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,
 	return iio_push_to_buffers(indio_dev, data);
 }
 
-int iio_update_demux(struct iio_dev *indio_dev);
-
 bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev,
 	const unsigned long *mask);
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 02/11] iio:buffer.h Reformat structure comments to be inline.
  2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 01/11] iio:buffer: Stop exporting iio_update_demux Jonathan Cameron
@ 2017-01-02 19:28 ` Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 03/11] iio:buffer: Introduced a function to assign the buffer specific attrs Jonathan Cameron
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-02 19:28 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Jonathan Cameron

This should make it easier to see how the structure is split into
public and private parts - reflected in the generated documentation.

Deliberately use /* instead of /** for the private elements to avoid
warnings when kernel-doc script runs.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 include/linux/iio/buffer.h | 100 ++++++++++++++++++++++++++++-----------------
 1 file changed, 63 insertions(+), 37 deletions(-)

diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 889d0f2f5d7b..4a65a7bb40a4 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -74,45 +74,71 @@ struct iio_buffer_access_funcs {
 
 /**
  * struct iio_buffer - general buffer structure
- * @length:		[DEVICE] number of datums in buffer
- * @bytes_per_datum:	[DEVICE] size of individual datum including timestamp
- * @scan_el_attrs:	[DRIVER] control of scan elements if that scan mode
- *			control method is used
- * @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.
- * @scan_el_dev_attr_list:[INTERN] list of scan element related attributes.
- * @buffer_group:	[INTERN] attributes of the buffer group
- * @scan_el_group:	[DRIVER] attribute group for those attributes not
- *			created from the iio_chan_info array.
- * @pollq:		[INTERN] wait queue to allow for polling on the buffer.
- * @stufftoread:	[INTERN] flag to indicate new data.
- * @attrs:		[INTERN] standard attributes of the buffer
- * @demux_list:		[INTERN] list of operations required to demux the scan.
- * @demux_bounce:	[INTERN] buffer for doing gather from incoming scan.
- * @buffer_list:	[INTERN] entry in the devices list of current buffers.
- * @ref:		[INTERN] reference count of the buffer.
- * @watermark:		[INTERN] number of datums to wait for poll/read.
+ *
+ * Note that the internals of this structure should only be of interest to
+ * those writing new buffer implementations.
  */
 struct iio_buffer {
-	int					length;
-	int					bytes_per_datum;
-	struct attribute_group			*scan_el_attrs;
-	long					*scan_mask;
-	bool					scan_timestamp;
-	const struct iio_buffer_access_funcs	*access;
-	struct list_head			scan_el_dev_attr_list;
-	struct attribute_group			buffer_group;
-	struct attribute_group			scan_el_group;
-	wait_queue_head_t			pollq;
-	bool					stufftoread;
-	const struct attribute			**attrs;
-	struct list_head			demux_list;
-	void					*demux_bounce;
-	struct list_head			buffer_list;
-	struct kref				ref;
-	unsigned int				watermark;
+	/** @length: Number of datums in buffer. */
+	int length;
+
+	/**  @bytes_per_datum: Size of individual datum including timestamp. */
+	int bytes_per_datum;
+
+	/**
+	 * @access: Buffer access functions associated with the
+	 * implementation.
+	 */
+	const struct iio_buffer_access_funcs *access;
+
+	/** @scan_mask: Bitmask used in masking scan mode elements. */
+	long *scan_mask;
+
+	/** @demux_list: List of operations required to demux the scan. */
+	struct list_head demux_list;
+
+	/** @pollq: Wait queue to allow for polling on the buffer. */
+	wait_queue_head_t pollq;
+
+	/** @watermark: Number of datums to wait for poll/read. */
+	unsigned int watermark;
+
+	/* private: */
+	/*
+	 * @scan_el_attrs: Control of scan elements if that scan mode
+	 * control method is used.
+	 */
+	struct attribute_group *scan_el_attrs;
+
+	/* @scan_timestamp: Does the scan mode include a timestamp. */
+	bool scan_timestamp;
+
+	/* @scan_el_dev_attr_list: List of scan element related attributes. */
+	struct list_head scan_el_dev_attr_list;
+
+	/* @buffer_group: Attributes of the buffer group. */
+	struct attribute_group buffer_group;
+
+	/*
+	 * @scan_el_group: Attribute group for those attributes not
+	 * created from the iio_chan_info array.
+	 */
+	struct attribute_group scan_el_group;
+
+	/* @stufftoread: Flag to indicate new data. */
+	bool stufftoread;
+
+	/* @attrs: Standard attributes of the buffer. */
+	const struct attribute **attrs;
+
+	/* @demux_bounce: Buffer for doing gather from incoming scan. */
+	void *demux_bounce;
+
+	/* @buffer_list: Entry in the devices list of current buffers. */
+	struct list_head buffer_list;
+
+	/* @ref: Reference count of the buffer. */
+	struct kref ref;
 };
 
 /**
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 03/11] iio:buffer: Introduced a function to assign the buffer specific attrs.
  2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 01/11] iio:buffer: Stop exporting iio_update_demux Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 02/11] iio:buffer.h Reformat structure comments to be inline Jonathan Cameron
@ 2017-01-02 19:28 ` Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 04/11] iio:buffer: Stop exporting iio_scan_mask_query Jonathan Cameron
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-02 19:28 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Jonathan Cameron

This is a necessary step in taking the buffer implementation
opaque.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/accel/bmc150-accel-core.c |  3 ++-
 drivers/iio/industrialio-buffer.c     | 12 ++++++++++++
 include/linux/iio/buffer.h            |  2 ++
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c
index 59b380dbf27f..6b5d3be283c4 100644
--- a/drivers/iio/accel/bmc150-accel-core.c
+++ b/drivers/iio/accel/bmc150-accel-core.c
@@ -1638,7 +1638,8 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq,
 		if (block_supported) {
 			indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
 			indio_dev->info = &bmc150_accel_info_fifo;
-			indio_dev->buffer->attrs = bmc150_accel_fifo_attributes;
+			iio_buffer_set_attrs(indio_dev->buffer,
+					     bmc150_accel_fifo_attributes);
 		}
 	}
 
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 9f496eb84e0b..831537cc9500 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -209,6 +209,18 @@ void iio_buffer_init(struct iio_buffer *buffer)
 }
 EXPORT_SYMBOL(iio_buffer_init);
 
+/**
+ * iio_buffer_set_attrs - Set buffer specific attributes
+ * @buffer: The buffer for which we are setting attributes
+ * @attrs: Pointer to a null terminated list of pointers to attributes
+ */
+void iio_buffer_set_attrs(struct iio_buffer *buffer,
+			 const struct attribute **attrs)
+{
+	buffer->attrs = attrs;
+}
+EXPORT_SYMBOL_GPL(iio_buffer_set_attrs);
+
 static ssize_t iio_show_scan_index(struct device *dev,
 				   struct device_attribute *attr,
 				   char *buf)
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 4a65a7bb40a4..30ea9806db67 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -17,6 +17,8 @@
 
 struct iio_buffer;
 
+void iio_buffer_set_attrs(struct iio_buffer *buffer,
+			 const struct attribute **attrs);
 /**
  * INDIO_BUFFER_FLAG_FIXED_WATERMARK - Watermark level of the buffer can not be
  *   configured. It has a fixed value which will be buffer specific.
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 04/11] iio:buffer: Stop exporting iio_scan_mask_query
  2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
                   ` (2 preceding siblings ...)
  2017-01-02 19:28 ` [PATCH 03/11] iio:buffer: Introduced a function to assign the buffer specific attrs Jonathan Cameron
@ 2017-01-02 19:28 ` Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 05/11] iio:buffers: Push some docs down into the .c file Jonathan Cameron
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-02 19:28 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Jonathan Cameron

Nothing uses it outside of core code.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/industrialio-buffer.c | 27 +++++++++++++--------------
 include/linux/iio/buffer.h        |  3 ---
 2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 831537cc9500..5eb991b24dff 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -358,6 +358,19 @@ static int iio_scan_mask_clear(struct iio_buffer *buffer, int bit)
 	return 0;
 }
 
+static int iio_scan_mask_query(struct iio_dev *indio_dev,
+			       struct iio_buffer *buffer, int bit)
+{
+	if (bit > indio_dev->masklength)
+		return -EINVAL;
+
+	if (!buffer->scan_mask)
+		return 0;
+
+	/* Ensure return value is 0 or 1. */
+	return !!test_bit(bit, buffer->scan_mask);
+};
+
 static ssize_t iio_scan_el_store(struct device *dev,
 				 struct device_attribute *attr,
 				 const char *buf,
@@ -1340,20 +1353,6 @@ bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev,
 }
 EXPORT_SYMBOL_GPL(iio_validate_scan_mask_onehot);
 
-int iio_scan_mask_query(struct iio_dev *indio_dev,
-			struct iio_buffer *buffer, int bit)
-{
-	if (bit > indio_dev->masklength)
-		return -EINVAL;
-
-	if (!buffer->scan_mask)
-		return 0;
-
-	/* Ensure return value is 0 or 1. */
-	return !!test_bit(bit, buffer->scan_mask);
-};
-EXPORT_SYMBOL_GPL(iio_scan_mask_query);
-
 static const void *iio_demux(struct iio_buffer *buffer,
 				 const void *datain)
 {
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 30ea9806db67..635aa87eb5e9 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -161,9 +161,6 @@ int iio_update_buffers(struct iio_dev *indio_dev,
  **/
 void iio_buffer_init(struct iio_buffer *buffer);
 
-int iio_scan_mask_query(struct iio_dev *indio_dev,
-			struct iio_buffer *buffer, int bit);
-
 /**
  * iio_push_to_buffers() - push to a registered buffer.
  * @indio_dev:		iio_dev structure for device.
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 05/11] iio:buffers: Push some docs down into the .c file.
  2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
                   ` (3 preceding siblings ...)
  2017-01-02 19:28 ` [PATCH 04/11] iio:buffer: Stop exporting iio_scan_mask_query Jonathan Cameron
@ 2017-01-02 19:28 ` Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 06/11] iio:buffer:iio_push_to_buffers_with_timestamp fix kernel-doc Jonathan Cameron
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-02 19:28 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Jonathan Cameron

Ancient legacy of me doing it wrong which it is nice to clear
up whilst we are here.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/industrialio-buffer.c | 5 +++++
 include/linux/iio/buffer.h        | 5 -----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 5eb991b24dff..0067e184c9ae 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -1384,6 +1384,11 @@ static int iio_push_to_buffer(struct iio_buffer *buffer, const void *data)
 	return 0;
 }
 
+/**
+ * iio_push_to_buffers() - push to a registered buffer.
+ * @indio_dev:		iio_dev structure for device.
+ * @data:		Full scan.
+ */
 int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data)
 {
 	int ret;
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 635aa87eb5e9..cd77ed14eb7f 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -161,11 +161,6 @@ int iio_update_buffers(struct iio_dev *indio_dev,
  **/
 void iio_buffer_init(struct iio_buffer *buffer);
 
-/**
- * iio_push_to_buffers() - push to a registered buffer.
- * @indio_dev:		iio_dev structure for device.
- * @data:		Full scan.
- */
 int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data);
 
 /*
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 06/11] iio:buffer:iio_push_to_buffers_with_timestamp fix kernel-doc.
  2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
                   ` (4 preceding siblings ...)
  2017-01-02 19:28 ` [PATCH 05/11] iio:buffers: Push some docs down into the .c file Jonathan Cameron
@ 2017-01-02 19:28 ` Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 07/11] iio:kfifo_buf header include push down Jonathan Cameron
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-02 19:28 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Jonathan Cameron

Wrong start of kernel doc comment /* -> /**

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 include/linux/iio/buffer.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index cd77ed14eb7f..8c915c2c18f1 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -163,7 +163,7 @@ void iio_buffer_init(struct iio_buffer *buffer);
 
 int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data);
 
-/*
+/**
  * iio_push_to_buffers_with_timestamp() - push data and timestamp to buffers
  * @indio_dev:		iio_dev structure for device.
  * @data:		sample data
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 07/11] iio:kfifo_buf header include push down.
  2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
                   ` (5 preceding siblings ...)
  2017-01-02 19:28 ` [PATCH 06/11] iio:buffer:iio_push_to_buffers_with_timestamp fix kernel-doc Jonathan Cameron
@ 2017-01-02 19:28 ` Jonathan Cameron
  2017-01-07 21:52   ` Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 08/11] iio:buffer.h include pushdown into buffer implementations Jonathan Cameron
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-02 19:28 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Jonathan Cameron

As a precursor to splitting buffer.h, lets make sure all drivers
include the relevant headers rather than relying on picking them
up from kfifo_buf.h.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/accel/ssp_accel_sensor.c        | 1 +
 drivers/iio/adc/ina2xx-adc.c                | 2 ++
 drivers/iio/common/ssp_sensors/ssp_iio.c    | 1 +
 drivers/iio/dummy/iio_simple_dummy_buffer.c | 1 +
 drivers/iio/gyro/ssp_gyro_sensor.c          | 1 +
 drivers/staging/iio/meter/ade7758_ring.c    | 1 +
 include/linux/iio/kfifo_buf.h               | 5 ++---
 7 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/accel/ssp_accel_sensor.c b/drivers/iio/accel/ssp_accel_sensor.c
index 31db00970fa0..6b54008e29c7 100644
--- a/drivers/iio/accel/ssp_accel_sensor.c
+++ b/drivers/iio/accel/ssp_accel_sensor.c
@@ -15,6 +15,7 @@
 
 #include <linux/iio/common/ssp_sensors.h>
 #include <linux/iio/iio.h>
+#include <linux/iio/buffer.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
index 59b7d76e1ad2..3263231276ca 100644
--- a/drivers/iio/adc/ina2xx-adc.c
+++ b/drivers/iio/adc/ina2xx-adc.c
@@ -22,6 +22,8 @@
 
 #include <linux/delay.h>
 #include <linux/i2c.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/buffer.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/iio/sysfs.h>
 #include <linux/kthread.h>
diff --git a/drivers/iio/common/ssp_sensors/ssp_iio.c b/drivers/iio/common/ssp_sensors/ssp_iio.c
index a3ae165f8d9f..645f2e3975db 100644
--- a/drivers/iio/common/ssp_sensors/ssp_iio.c
+++ b/drivers/iio/common/ssp_sensors/ssp_iio.c
@@ -14,6 +14,7 @@
  */
 
 #include <linux/iio/common/ssp_sensors.h>
+#include <linux/iio/buffer.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/module.h>
 #include <linux/slab.h>
diff --git a/drivers/iio/dummy/iio_simple_dummy_buffer.c b/drivers/iio/dummy/iio_simple_dummy_buffer.c
index b383892a5193..26bddb2464b7 100644
--- a/drivers/iio/dummy/iio_simple_dummy_buffer.c
+++ b/drivers/iio/dummy/iio_simple_dummy_buffer.c
@@ -20,6 +20,7 @@
 
 #include <linux/iio/iio.h>
 #include <linux/iio/trigger_consumer.h>
+#include <linux/iio/buffer.h>
 #include <linux/iio/kfifo_buf.h>
 
 #include "iio_simple_dummy.h"
diff --git a/drivers/iio/gyro/ssp_gyro_sensor.c b/drivers/iio/gyro/ssp_gyro_sensor.c
index 1f25f406c545..33a7f0a94ce5 100644
--- a/drivers/iio/gyro/ssp_gyro_sensor.c
+++ b/drivers/iio/gyro/ssp_gyro_sensor.c
@@ -15,6 +15,7 @@
 
 #include <linux/iio/common/ssp_sensors.h>
 #include <linux/iio/iio.h>
+#include <linux/iio/buffer.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c
index 57c213dfadcc..6d7444d6e880 100644
--- a/drivers/staging/iio/meter/ade7758_ring.c
+++ b/drivers/staging/iio/meter/ade7758_ring.c
@@ -13,6 +13,7 @@
 #include <asm/unaligned.h>
 
 #include <linux/iio/iio.h>
+#include <linux/iio/buffer.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/iio/trigger_consumer.h>
 #include "ade7758.h"
diff --git a/include/linux/iio/kfifo_buf.h b/include/linux/iio/kfifo_buf.h
index 1683bc710d14..027cfa9c3703 100644
--- a/include/linux/iio/kfifo_buf.h
+++ b/include/linux/iio/kfifo_buf.h
@@ -1,9 +1,8 @@
 #ifndef __LINUX_IIO_KFIFO_BUF_H__
 #define __LINUX_IIO_KFIFO_BUF_H__
 
-#include <linux/kfifo.h>
-#include <linux/iio/iio.h>
-#include <linux/iio/buffer.h>
+struct iio_buffer;
+struct device;
 
 struct iio_buffer *iio_kfifo_allocate(void);
 void iio_kfifo_free(struct iio_buffer *r);
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 08/11] iio:buffer.h include pushdown into buffer implementations
  2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
                   ` (6 preceding siblings ...)
  2017-01-02 19:28 ` [PATCH 07/11] iio:kfifo_buf header include push down Jonathan Cameron
@ 2017-01-02 19:28 ` Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 09/11] iio:buffer: Push implementation of iio_device_attach_buffer into .c file Jonathan Cameron
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-02 19:28 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Jonathan Cameron

These were only getting access to the internals of struct iio_dev via
the include of iio.h within buffer.h.  This should always have been
explicitly included by the buffer implementations themselves.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/buffer/industrialio-buffer-cb.c | 1 +
 drivers/iio/buffer/kfifo_buf.c              | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buffer/industrialio-buffer-cb.c
index b8f550e47d3d..79fb2f9de759 100644
--- a/drivers/iio/buffer/industrialio-buffer-cb.c
+++ b/drivers/iio/buffer/industrialio-buffer-cb.c
@@ -10,6 +10,7 @@
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/export.h>
+#include <linux/iio/iio.h>
 #include <linux/iio/buffer.h>
 #include <linux/iio/consumer.h>
 
diff --git a/drivers/iio/buffer/kfifo_buf.c b/drivers/iio/buffer/kfifo_buf.c
index c5b999f0c519..2267ce190335 100644
--- a/drivers/iio/buffer/kfifo_buf.c
+++ b/drivers/iio/buffer/kfifo_buf.c
@@ -5,6 +5,7 @@
 #include <linux/workqueue.h>
 #include <linux/kfifo.h>
 #include <linux/mutex.h>
+#include <linux/iio/iio.h>
 #include <linux/iio/kfifo_buf.h>
 #include <linux/sched.h>
 #include <linux/poll.h>
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 09/11] iio:buffer: Push implementation of iio_device_attach_buffer into .c file
  2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
                   ` (7 preceding siblings ...)
  2017-01-02 19:28 ` [PATCH 08/11] iio:buffer.h include pushdown into buffer implementations Jonathan Cameron
@ 2017-01-02 19:28 ` Jonathan Cameron
  2017-01-07 22:00   ` Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 10/11] iio:dummy: Stop enabling timestamp by default Jonathan Cameron
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-02 19:28 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Jonathan Cameron

This is a precursor to the splitting of buffer.h into parts relevant
to buffer implementation vs those for devices using buffers.
struct buffer is about to become opaque as far as the header is
concerned.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/industrialio-buffer.c | 16 ++++++++++++++++
 include/linux/iio/buffer.h        | 17 ++---------------
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 0067e184c9ae..a04498231f94 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -1445,3 +1445,19 @@ void iio_buffer_put(struct iio_buffer *buffer)
 		kref_put(&buffer->ref, iio_buffer_release);
 }
 EXPORT_SYMBOL_GPL(iio_buffer_put);
+
+/**
+ * iio_device_attach_buffer - Attach a buffer to a IIO device
+ * @indio_dev: The device the buffer should be attached to
+ * @buffer: The buffer to attach to the device
+ *
+ * This function attaches a buffer to a IIO device. The buffer stays attached to
+ * the device until the device is freed. The function should only be called at
+ * most once per device.
+ */
+void iio_device_attach_buffer(struct iio_dev *indio_dev,
+			      struct iio_buffer *buffer)
+{
+	indio_dev->buffer = iio_buffer_get(buffer);
+}
+EXPORT_SYMBOL_GPL(iio_device_attach_buffer);
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 8c915c2c18f1..45a8d59e39cd 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -194,26 +194,13 @@ bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev,
 struct iio_buffer *iio_buffer_get(struct iio_buffer *buffer);
 void iio_buffer_put(struct iio_buffer *buffer);
 
-/**
- * iio_device_attach_buffer - Attach a buffer to a IIO device
- * @indio_dev: The device the buffer should be attached to
- * @buffer: The buffer to attach to the device
- *
- * This function attaches a buffer to a IIO device. The buffer stays attached to
- * the device until the device is freed. The function should only be called at
- * most once per device.
- */
-static inline void iio_device_attach_buffer(struct iio_dev *indio_dev,
-	struct iio_buffer *buffer)
-{
-	indio_dev->buffer = iio_buffer_get(buffer);
-}
-
 #else /* CONFIG_IIO_BUFFER */
 
 static inline void iio_buffer_get(struct iio_buffer *buffer) {}
 static inline void iio_buffer_put(struct iio_buffer *buffer) {}
 
+void iio_device_attach_buffer(struct iio_dev *indio_dev,
+			      struct iio_buffer *buffer);
 #endif /* CONFIG_IIO_BUFFER */
 
 #endif /* _IIO_BUFFER_GENERIC_H_ */
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 10/11] iio:dummy: Stop enabling timestamp by default.
  2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
                   ` (8 preceding siblings ...)
  2017-01-02 19:28 ` [PATCH 09/11] iio:buffer: Push implementation of iio_device_attach_buffer into .c file Jonathan Cameron
@ 2017-01-02 19:28 ` Jonathan Cameron
  2017-01-02 19:28 ` [PATCH 11/11] iio:buffer.h - split into buffer.h and buffer_impl.h Jonathan Cameron
  2017-01-04 18:41 ` [PATCH 00/11] buffer.h cleanup and split Lars-Peter Clausen
  11 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-02 19:28 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Jonathan Cameron

It's bad practice and only done in this fake driver + it breaks my
attempt to take struct buffer opaque. Not worth an access function
as it shouldn't be done anyway.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/dummy/iio_simple_dummy_buffer.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/iio/dummy/iio_simple_dummy_buffer.c b/drivers/iio/dummy/iio_simple_dummy_buffer.c
index 26bddb2464b7..744ca92c3c99 100644
--- a/drivers/iio/dummy/iio_simple_dummy_buffer.c
+++ b/drivers/iio/dummy/iio_simple_dummy_buffer.c
@@ -132,9 +132,6 @@ int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev)
 
 	iio_device_attach_buffer(indio_dev, buffer);
 
-	/* Enable timestamps by default */
-	buffer->scan_timestamp = true;
-
 	/*
 	 * Tell the core what device type specific functions should
 	 * be run on either side of buffer capture enable / disable.
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 11/11] iio:buffer.h - split into buffer.h and buffer_impl.h
  2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
                   ` (9 preceding siblings ...)
  2017-01-02 19:28 ` [PATCH 10/11] iio:dummy: Stop enabling timestamp by default Jonathan Cameron
@ 2017-01-02 19:28 ` Jonathan Cameron
  2017-01-04 18:41 ` [PATCH 00/11] buffer.h cleanup and split Lars-Peter Clausen
  11 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-02 19:28 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, Jonathan Cameron

buffer.h supplies everything needed for devices using buffers.
buffer_impl.h supplies access to the internals as needed to write
a buffer implementation.

This was really motivated by the mess that turned up in the
kernel-doc documentation pulled in by the new sphinx docs.
It made it clear that our logical separations in headers were
generally terrible.  The buffer case was easy to sort out without
greatly effecting drivers so here it is.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
---
 drivers/iio/buffer/industrialio-buffer-cb.c |   2 +-
 drivers/iio/buffer/kfifo_buf.c              |   1 +
 drivers/iio/industrialio-buffer.c           |   1 +
 drivers/iio/industrialio-core.c             |   1 +
 include/linux/iio/buffer.h                  | 155 +-------------------------
 include/linux/iio/buffer_impl.h             | 162 ++++++++++++++++++++++++++++
 6 files changed, 167 insertions(+), 155 deletions(-)

diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buffer/industrialio-buffer-cb.c
index 79fb2f9de759..4847534700e7 100644
--- a/drivers/iio/buffer/industrialio-buffer-cb.c
+++ b/drivers/iio/buffer/industrialio-buffer-cb.c
@@ -11,7 +11,7 @@
 #include <linux/err.h>
 #include <linux/export.h>
 #include <linux/iio/iio.h>
-#include <linux/iio/buffer.h>
+#include <linux/iio/buffer_impl.h>
 #include <linux/iio/consumer.h>
 
 struct iio_cb_buffer {
diff --git a/drivers/iio/buffer/kfifo_buf.c b/drivers/iio/buffer/kfifo_buf.c
index 2267ce190335..f584742f191e 100644
--- a/drivers/iio/buffer/kfifo_buf.c
+++ b/drivers/iio/buffer/kfifo_buf.c
@@ -7,6 +7,7 @@
 #include <linux/mutex.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/kfifo_buf.h>
+#include <linux/iio/buffer_impl.h>
 #include <linux/sched.h>
 #include <linux/poll.h>
 
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index a04498231f94..4972986f6455 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -26,6 +26,7 @@
 #include "iio_core.h"
 #include <linux/iio/sysfs.h>
 #include <linux/iio/buffer.h>
+#include <linux/iio/buffer_impl.h>
 
 static const char * const iio_endian_prefix[] = {
 	[IIO_BE] = "be",
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index aaca42862389..d507c0f5cd2c 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -32,6 +32,7 @@
 #include <linux/iio/sysfs.h>
 #include <linux/iio/events.h>
 #include <linux/iio/buffer.h>
+#include <linux/iio/buffer_impl.h>
 
 /* IDA to assign each registered device a unique id */
 static DEFINE_IDA(iio_ida);
diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
index 45a8d59e39cd..48767c776119 100644
--- a/include/linux/iio/buffer.h
+++ b/include/linux/iio/buffer.h
@@ -11,155 +11,11 @@
 #define _IIO_BUFFER_GENERIC_H_
 #include <linux/sysfs.h>
 #include <linux/iio/iio.h>
-#include <linux/kref.h>
-
-#ifdef CONFIG_IIO_BUFFER
 
 struct iio_buffer;
 
 void iio_buffer_set_attrs(struct iio_buffer *buffer,
 			 const struct attribute **attrs);
-/**
- * INDIO_BUFFER_FLAG_FIXED_WATERMARK - Watermark level of the buffer can not be
- *   configured. It has a fixed value which will be buffer specific.
- */
-#define INDIO_BUFFER_FLAG_FIXED_WATERMARK BIT(0)
-
-/**
- * struct iio_buffer_access_funcs - access functions for buffers.
- * @store_to:		actually store stuff to the buffer
- * @read_first_n:	try to get a specified number of bytes (must exist)
- * @data_available:	indicates how much data is available for reading from
- *			the buffer.
- * @request_update:	if a parameter change has been marked, update underlying
- *			storage.
- * @set_bytes_per_datum:set number of bytes per datum
- * @set_length:		set number of datums in buffer
- * @enable:             called if the buffer is attached to a device and the
- *                      device starts sampling. Calls are balanced with
- *                      @disable.
- * @disable:            called if the buffer is attached to a device and the
- *                      device stops sampling. Calles are balanced with @enable.
- * @release:		called when the last reference to the buffer is dropped,
- *			should free all resources allocated by the buffer.
- * @modes:		Supported operating modes by this buffer type
- * @flags:		A bitmask combination of INDIO_BUFFER_FLAG_*
- *
- * 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 {
-	int (*store_to)(struct iio_buffer *buffer, const void *data);
-	int (*read_first_n)(struct iio_buffer *buffer,
-			    size_t n,
-			    char __user *buf);
-	size_t (*data_available)(struct iio_buffer *buffer);
-
-	int (*request_update)(struct iio_buffer *buffer);
-
-	int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
-	int (*set_length)(struct iio_buffer *buffer, int length);
-
-	int (*enable)(struct iio_buffer *buffer, struct iio_dev *indio_dev);
-	int (*disable)(struct iio_buffer *buffer, struct iio_dev *indio_dev);
-
-	void (*release)(struct iio_buffer *buffer);
-
-	unsigned int modes;
-	unsigned int flags;
-};
-
-/**
- * struct iio_buffer - general buffer structure
- *
- * Note that the internals of this structure should only be of interest to
- * those writing new buffer implementations.
- */
-struct iio_buffer {
-	/** @length: Number of datums in buffer. */
-	int length;
-
-	/**  @bytes_per_datum: Size of individual datum including timestamp. */
-	int bytes_per_datum;
-
-	/**
-	 * @access: Buffer access functions associated with the
-	 * implementation.
-	 */
-	const struct iio_buffer_access_funcs *access;
-
-	/** @scan_mask: Bitmask used in masking scan mode elements. */
-	long *scan_mask;
-
-	/** @demux_list: List of operations required to demux the scan. */
-	struct list_head demux_list;
-
-	/** @pollq: Wait queue to allow for polling on the buffer. */
-	wait_queue_head_t pollq;
-
-	/** @watermark: Number of datums to wait for poll/read. */
-	unsigned int watermark;
-
-	/* private: */
-	/*
-	 * @scan_el_attrs: Control of scan elements if that scan mode
-	 * control method is used.
-	 */
-	struct attribute_group *scan_el_attrs;
-
-	/* @scan_timestamp: Does the scan mode include a timestamp. */
-	bool scan_timestamp;
-
-	/* @scan_el_dev_attr_list: List of scan element related attributes. */
-	struct list_head scan_el_dev_attr_list;
-
-	/* @buffer_group: Attributes of the buffer group. */
-	struct attribute_group buffer_group;
-
-	/*
-	 * @scan_el_group: Attribute group for those attributes not
-	 * created from the iio_chan_info array.
-	 */
-	struct attribute_group scan_el_group;
-
-	/* @stufftoread: Flag to indicate new data. */
-	bool stufftoread;
-
-	/* @attrs: Standard attributes of the buffer. */
-	const struct attribute **attrs;
-
-	/* @demux_bounce: Buffer for doing gather from incoming scan. */
-	void *demux_bounce;
-
-	/* @buffer_list: Entry in the devices list of current buffers. */
-	struct list_head buffer_list;
-
-	/* @ref: Reference count of the buffer. */
-	struct kref ref;
-};
-
-/**
- * iio_update_buffers() - add or remove buffer from active list
- * @indio_dev:		device to add buffer to
- * @insert_buffer:	buffer to insert
- * @remove_buffer:	buffer_to_remove
- *
- * Note this will tear down the all buffering and build it up again
- */
-int iio_update_buffers(struct iio_dev *indio_dev,
-		       struct iio_buffer *insert_buffer,
-		       struct iio_buffer *remove_buffer);
-
-/**
- * iio_buffer_init() - Initialize the buffer structure
- * @buffer:		buffer to be initialized
- **/
-void iio_buffer_init(struct iio_buffer *buffer);
 
 int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data);
 
@@ -189,18 +45,9 @@ static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,
 }
 
 bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev,
-	const unsigned long *mask);
-
-struct iio_buffer *iio_buffer_get(struct iio_buffer *buffer);
-void iio_buffer_put(struct iio_buffer *buffer);
-
-#else /* CONFIG_IIO_BUFFER */
-
-static inline void iio_buffer_get(struct iio_buffer *buffer) {}
-static inline void iio_buffer_put(struct iio_buffer *buffer) {}
+				   const unsigned long *mask);
 
 void iio_device_attach_buffer(struct iio_dev *indio_dev,
 			      struct iio_buffer *buffer);
-#endif /* CONFIG_IIO_BUFFER */
 
 #endif /* _IIO_BUFFER_GENERIC_H_ */
diff --git a/include/linux/iio/buffer_impl.h b/include/linux/iio/buffer_impl.h
new file mode 100644
index 000000000000..8daba198fafa
--- /dev/null
+++ b/include/linux/iio/buffer_impl.h
@@ -0,0 +1,162 @@
+#ifndef _IIO_BUFFER_GENERIC_IMPL_H_
+#define _IIO_BUFFER_GENERIC_IMPL_H_
+#include <linux/sysfs.h>
+#include <linux/kref.h>
+
+#ifdef CONFIG_IIO_BUFFER
+
+struct iio_dev;
+struct iio_buffer;
+
+/**
+ * INDIO_BUFFER_FLAG_FIXED_WATERMARK - Watermark level of the buffer can not be
+ *   configured. It has a fixed value which will be buffer specific.
+ */
+#define INDIO_BUFFER_FLAG_FIXED_WATERMARK BIT(0)
+
+/**
+ * struct iio_buffer_access_funcs - access functions for buffers.
+ * @store_to:		actually store stuff to the buffer
+ * @read_first_n:	try to get a specified number of bytes (must exist)
+ * @data_available:	indicates how much data is available for reading from
+ *			the buffer.
+ * @request_update:	if a parameter change has been marked, update underlying
+ *			storage.
+ * @set_bytes_per_datum:set number of bytes per datum
+ * @set_length:		set number of datums in buffer
+ * @enable:             called if the buffer is attached to a device and the
+ *                      device starts sampling. Calls are balanced with
+ *                      @disable.
+ * @disable:            called if the buffer is attached to a device and the
+ *                      device stops sampling. Calles are balanced with @enable.
+ * @release:		called when the last reference to the buffer is dropped,
+ *			should free all resources allocated by the buffer.
+ * @modes:		Supported operating modes by this buffer type
+ * @flags:		A bitmask combination of INDIO_BUFFER_FLAG_*
+ *
+ * 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 {
+	int (*store_to)(struct iio_buffer *buffer, const void *data);
+	int (*read_first_n)(struct iio_buffer *buffer,
+			    size_t n,
+			    char __user *buf);
+	size_t (*data_available)(struct iio_buffer *buffer);
+
+	int (*request_update)(struct iio_buffer *buffer);
+
+	int (*set_bytes_per_datum)(struct iio_buffer *buffer, size_t bpd);
+	int (*set_length)(struct iio_buffer *buffer, int length);
+
+	int (*enable)(struct iio_buffer *buffer, struct iio_dev *indio_dev);
+	int (*disable)(struct iio_buffer *buffer, struct iio_dev *indio_dev);
+
+	void (*release)(struct iio_buffer *buffer);
+
+	unsigned int modes;
+	unsigned int flags;
+};
+
+/**
+ * struct iio_buffer - general buffer structure
+ *
+ * Note that the internals of this structure should only be of interest to
+ * those writing new buffer implementations.
+ */
+struct iio_buffer {
+	/** @length: Number of datums in buffer. */
+	int length;
+
+	/**  @bytes_per_datum: Size of individual datum including timestamp. */
+	int bytes_per_datum;
+
+	/**
+	 * @access: Buffer access functions associated with the
+	 * implementation.
+	 */
+	const struct iio_buffer_access_funcs *access;
+
+	/** @scan_mask: Bitmask used in masking scan mode elements. */
+	long *scan_mask;
+
+	/** @demux_list: List of operations required to demux the scan. */
+	struct list_head demux_list;
+
+	/** @pollq: Wait queue to allow for polling on the buffer. */
+	wait_queue_head_t pollq;
+
+	/** @watermark: Number of datums to wait for poll/read. */
+	unsigned int watermark;
+
+	/* private: */
+	/*
+	 * @scan_el_attrs: Control of scan elements if that scan mode
+	 * control method is used.
+	 */
+	struct attribute_group *scan_el_attrs;
+
+	/* @scan_timestamp: Does the scan mode include a timestamp. */
+	bool scan_timestamp;
+
+	/* @scan_el_dev_attr_list: List of scan element related attributes. */
+	struct list_head scan_el_dev_attr_list;
+
+	/* @buffer_group: Attributes of the buffer group. */
+	struct attribute_group buffer_group;
+
+	/*
+	 * @scan_el_group: Attribute group for those attributes not
+	 * created from the iio_chan_info array.
+	 */
+	struct attribute_group scan_el_group;
+
+	/* @stufftoread: Flag to indicate new data. */
+	bool stufftoread;
+
+	/* @attrs: Standard attributes of the buffer. */
+	const struct attribute **attrs;
+
+	/* @demux_bounce: Buffer for doing gather from incoming scan. */
+	void *demux_bounce;
+
+	/* @buffer_list: Entry in the devices list of current buffers. */
+	struct list_head buffer_list;
+
+	/* @ref: Reference count of the buffer. */
+	struct kref ref;
+};
+
+/**
+ * iio_update_buffers() - add or remove buffer from active list
+ * @indio_dev:		device to add buffer to
+ * @insert_buffer:	buffer to insert
+ * @remove_buffer:	buffer_to_remove
+ *
+ * Note this will tear down the all buffering and build it up again
+ */
+int iio_update_buffers(struct iio_dev *indio_dev,
+		       struct iio_buffer *insert_buffer,
+		       struct iio_buffer *remove_buffer);
+
+/**
+ * iio_buffer_init() - Initialize the buffer structure
+ * @buffer:		buffer to be initialized
+ **/
+void iio_buffer_init(struct iio_buffer *buffer);
+
+struct iio_buffer *iio_buffer_get(struct iio_buffer *buffer);
+void iio_buffer_put(struct iio_buffer *buffer);
+
+#else /* CONFIG_IIO_BUFFER */
+
+static inline void iio_buffer_get(struct iio_buffer *buffer) {}
+static inline void iio_buffer_put(struct iio_buffer *buffer) {}
+
+#endif /* CONFIG_IIO_BUFFER */
+#endif /* _IIO_BUFFER_GENERIC_IMPL_H_ */
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 00/11] buffer.h cleanup and split
  2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
                   ` (10 preceding siblings ...)
  2017-01-02 19:28 ` [PATCH 11/11] iio:buffer.h - split into buffer.h and buffer_impl.h Jonathan Cameron
@ 2017-01-04 18:41 ` Lars-Peter Clausen
  2017-01-07 19:45   ` Jonathan Cameron
  11 siblings, 1 reply; 16+ messages in thread
From: Lars-Peter Clausen @ 2017-01-04 18:41 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Peter Meerwald-Stadler

On 01/02/2017 08:28 PM, Jonathan Cameron wrote:
> This series came out of the mess that became apparant when looking at the
> autogenerated docs.  As we pull the kernel-doc from buffer.h in when
> describing the API the drivers use to access it we were pulling in a lot
> of documentation that was irrelevant to that use case.
> 
> Hence, this series does two things:
> 1) Splits the buffer.h header into two parts:
>    * buffer.h which just contains the stuff that drivers using buffers need.
>    * buffer_impl.h which just contains the stuff related to the implementation
>    of buffers
>    This makes struct iio_buffer opaque to the drivers (with a few extra
>    access functions and a bit of code reorganization)
> 2) Takes the documentation of struct iio_buffer inline, allowing fairly
>    sensible use of the private: label within docs rather than our local
>    iio specific tagging of documentation.  There is an oddity here in that
>    I have deliberately 'broken' the kernel-doc for elements that are private
>    in order to avoid lots of warnings about excess documentation.
> 
> Along the way various drivers gained additional includes that should probably
> have been there in the first place.  This was needed to cleanup the includes
> within the includes.  Most drivers did it 'right' anyway so this wasn't too
> bad.
> 
> I'll probably follow this up with similar cleanups elsewhere at some point.
> 
> This was against 4.10-rc1 as that's where I'm working on docs, but should
> go in reasonably cleanly on iio/togreg or iio/testing.

Looks good. I'm not convinced the split is necessary, but it doesn't hurt
either. Full series:

Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 00/11] buffer.h cleanup and split
  2017-01-04 18:41 ` [PATCH 00/11] buffer.h cleanup and split Lars-Peter Clausen
@ 2017-01-07 19:45   ` Jonathan Cameron
  0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-07 19:45 UTC (permalink / raw)
  To: Lars-Peter Clausen, linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Peter Meerwald-Stadler

On 04/01/17 13:41, Lars-Peter Clausen wrote:
> On 01/02/2017 08:28 PM, Jonathan Cameron wrote:
>> This series came out of the mess that became apparant when looking at the
>> autogenerated docs.  As we pull the kernel-doc from buffer.h in when
>> describing the API the drivers use to access it we were pulling in a lot
>> of documentation that was irrelevant to that use case.
>>
>> Hence, this series does two things:
>> 1) Splits the buffer.h header into two parts:
>>    * buffer.h which just contains the stuff that drivers using buffers need.
>>    * buffer_impl.h which just contains the stuff related to the implementation
>>    of buffers
>>    This makes struct iio_buffer opaque to the drivers (with a few extra
>>    access functions and a bit of code reorganization)
>> 2) Takes the documentation of struct iio_buffer inline, allowing fairly
>>    sensible use of the private: label within docs rather than our local
>>    iio specific tagging of documentation.  There is an oddity here in that
>>    I have deliberately 'broken' the kernel-doc for elements that are private
>>    in order to avoid lots of warnings about excess documentation.
>>
>> Along the way various drivers gained additional includes that should probably
>> have been there in the first place.  This was needed to cleanup the includes
>> within the includes.  Most drivers did it 'right' anyway so this wasn't too
>> bad.
>>
>> I'll probably follow this up with similar cleanups elsewhere at some point.
>>
>> This was against 4.10-rc1 as that's where I'm working on docs, but should
>> go in reasonably cleanly on iio/togreg or iio/testing.
> 
> Looks good. I'm not convinced the split is necessary, but it doesn't hurt
> either. Full series:
Yeah, bit marginal on necessity but will make the docs rather nice when I
(or someone else) gets around to documenting how to write a buffer driver.
In the meantime means a lot of irrelevant stuff goes from the driver api
docs on using a buffer.
> 
> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
> 
Thanks,

Series applied to the togreg branch of iio.git which will get pushed out as
testing at somepoint soonish.

Jonathan

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 07/11] iio:kfifo_buf header include push down.
  2017-01-02 19:28 ` [PATCH 07/11] iio:kfifo_buf header include push down Jonathan Cameron
@ 2017-01-07 21:52   ` Jonathan Cameron
  0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-07 21:52 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler

On 02/01/17 14:28, Jonathan Cameron wrote:
> As a precursor to splitting buffer.h, lets make sure all drivers
> include the relevant headers rather than relying on picking them
> up from kfifo_buf.h.
> 
> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
slight mess up in this one. Kfifo_buf.c needs to include buffer.h for now
or it won't build.

Fixed up during applying.
> ---
>  drivers/iio/accel/ssp_accel_sensor.c        | 1 +
>  drivers/iio/adc/ina2xx-adc.c                | 2 ++
>  drivers/iio/common/ssp_sensors/ssp_iio.c    | 1 +
>  drivers/iio/dummy/iio_simple_dummy_buffer.c | 1 +
>  drivers/iio/gyro/ssp_gyro_sensor.c          | 1 +
>  drivers/staging/iio/meter/ade7758_ring.c    | 1 +
>  include/linux/iio/kfifo_buf.h               | 5 ++---
>  7 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/accel/ssp_accel_sensor.c b/drivers/iio/accel/ssp_accel_sensor.c
> index 31db00970fa0..6b54008e29c7 100644
> --- a/drivers/iio/accel/ssp_accel_sensor.c
> +++ b/drivers/iio/accel/ssp_accel_sensor.c
> @@ -15,6 +15,7 @@
>  
>  #include <linux/iio/common/ssp_sensors.h>
>  #include <linux/iio/iio.h>
> +#include <linux/iio/buffer.h>
>  #include <linux/iio/kfifo_buf.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
> index 59b7d76e1ad2..3263231276ca 100644
> --- a/drivers/iio/adc/ina2xx-adc.c
> +++ b/drivers/iio/adc/ina2xx-adc.c
> @@ -22,6 +22,8 @@
>  
>  #include <linux/delay.h>
>  #include <linux/i2c.h>
> +#include <linux/iio/iio.h>
> +#include <linux/iio/buffer.h>
>  #include <linux/iio/kfifo_buf.h>
>  #include <linux/iio/sysfs.h>
>  #include <linux/kthread.h>
> diff --git a/drivers/iio/common/ssp_sensors/ssp_iio.c b/drivers/iio/common/ssp_sensors/ssp_iio.c
> index a3ae165f8d9f..645f2e3975db 100644
> --- a/drivers/iio/common/ssp_sensors/ssp_iio.c
> +++ b/drivers/iio/common/ssp_sensors/ssp_iio.c
> @@ -14,6 +14,7 @@
>   */
>  
>  #include <linux/iio/common/ssp_sensors.h>
> +#include <linux/iio/buffer.h>
>  #include <linux/iio/kfifo_buf.h>
>  #include <linux/module.h>
>  #include <linux/slab.h>
> diff --git a/drivers/iio/dummy/iio_simple_dummy_buffer.c b/drivers/iio/dummy/iio_simple_dummy_buffer.c
> index b383892a5193..26bddb2464b7 100644
> --- a/drivers/iio/dummy/iio_simple_dummy_buffer.c
> +++ b/drivers/iio/dummy/iio_simple_dummy_buffer.c
> @@ -20,6 +20,7 @@
>  
>  #include <linux/iio/iio.h>
>  #include <linux/iio/trigger_consumer.h>
> +#include <linux/iio/buffer.h>
>  #include <linux/iio/kfifo_buf.h>
>  
>  #include "iio_simple_dummy.h"
> diff --git a/drivers/iio/gyro/ssp_gyro_sensor.c b/drivers/iio/gyro/ssp_gyro_sensor.c
> index 1f25f406c545..33a7f0a94ce5 100644
> --- a/drivers/iio/gyro/ssp_gyro_sensor.c
> +++ b/drivers/iio/gyro/ssp_gyro_sensor.c
> @@ -15,6 +15,7 @@
>  
>  #include <linux/iio/common/ssp_sensors.h>
>  #include <linux/iio/iio.h>
> +#include <linux/iio/buffer.h>
>  #include <linux/iio/kfifo_buf.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> diff --git a/drivers/staging/iio/meter/ade7758_ring.c b/drivers/staging/iio/meter/ade7758_ring.c
> index 57c213dfadcc..6d7444d6e880 100644
> --- a/drivers/staging/iio/meter/ade7758_ring.c
> +++ b/drivers/staging/iio/meter/ade7758_ring.c
> @@ -13,6 +13,7 @@
>  #include <asm/unaligned.h>
>  
>  #include <linux/iio/iio.h>
> +#include <linux/iio/buffer.h>
>  #include <linux/iio/kfifo_buf.h>
>  #include <linux/iio/trigger_consumer.h>
>  #include "ade7758.h"
> diff --git a/include/linux/iio/kfifo_buf.h b/include/linux/iio/kfifo_buf.h
> index 1683bc710d14..027cfa9c3703 100644
> --- a/include/linux/iio/kfifo_buf.h
> +++ b/include/linux/iio/kfifo_buf.h
> @@ -1,9 +1,8 @@
>  #ifndef __LINUX_IIO_KFIFO_BUF_H__
>  #define __LINUX_IIO_KFIFO_BUF_H__
>  
> -#include <linux/kfifo.h>
> -#include <linux/iio/iio.h>
> -#include <linux/iio/buffer.h>
> +struct iio_buffer;
> +struct device;
>  
>  struct iio_buffer *iio_kfifo_allocate(void);
>  void iio_kfifo_free(struct iio_buffer *r);
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 09/11] iio:buffer: Push implementation of iio_device_attach_buffer into .c file
  2017-01-02 19:28 ` [PATCH 09/11] iio:buffer: Push implementation of iio_device_attach_buffer into .c file Jonathan Cameron
@ 2017-01-07 22:00   ` Jonathan Cameron
  0 siblings, 0 replies; 16+ messages in thread
From: Jonathan Cameron @ 2017-01-07 22:00 UTC (permalink / raw)
  To: linux-iio
  Cc: Daniel Baluta, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler

On 02/01/17 19:28, Jonathan Cameron wrote:
> This is a precursor to the splitting of buffer.h into parts relevant
> to buffer implementation vs those for devices using buffers.
> struct buffer is about to become opaque as far as the header is
> concerned.
> 
> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
> ---
>  drivers/iio/industrialio-buffer.c | 16 ++++++++++++++++
>  include/linux/iio/buffer.h        | 17 ++---------------
>  2 files changed, 18 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 0067e184c9ae..a04498231f94 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -1445,3 +1445,19 @@ void iio_buffer_put(struct iio_buffer *buffer)
>  		kref_put(&buffer->ref, iio_buffer_release);
>  }
>  EXPORT_SYMBOL_GPL(iio_buffer_put);
> +
> +/**
> + * iio_device_attach_buffer - Attach a buffer to a IIO device
> + * @indio_dev: The device the buffer should be attached to
> + * @buffer: The buffer to attach to the device
> + *
> + * This function attaches a buffer to a IIO device. The buffer stays attached to
> + * the device until the device is freed. The function should only be called at
> + * most once per device.
> + */
> +void iio_device_attach_buffer(struct iio_dev *indio_dev,
> +			      struct iio_buffer *buffer)
> +{
> +	indio_dev->buffer = iio_buffer_get(buffer);
> +}
> +EXPORT_SYMBOL_GPL(iio_device_attach_buffer);
> diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h
> index 8c915c2c18f1..45a8d59e39cd 100644
> --- a/include/linux/iio/buffer.h
> +++ b/include/linux/iio/buffer.h
> @@ -194,26 +194,13 @@ bool iio_validate_scan_mask_onehot(struct iio_dev *indio_dev,
>  struct iio_buffer *iio_buffer_get(struct iio_buffer *buffer);
>  void iio_buffer_put(struct iio_buffer *buffer);
>  
> -/**
> - * iio_device_attach_buffer - Attach a buffer to a IIO device
> - * @indio_dev: The device the buffer should be attached to
> - * @buffer: The buffer to attach to the device
> - *
> - * This function attaches a buffer to a IIO device. The buffer stays attached to
> - * the device until the device is freed. The function should only be called at
> - * most once per device.
> - */
> -static inline void iio_device_attach_buffer(struct iio_dev *indio_dev,
> -	struct iio_buffer *buffer)
> -{
> -	indio_dev->buffer = iio_buffer_get(buffer);
> -}
> -
>  #else /* CONFIG_IIO_BUFFER */
>  
>  static inline void iio_buffer_get(struct iio_buffer *buffer) {}
>  static inline void iio_buffer_put(struct iio_buffer *buffer) {}
>  
> +void iio_device_attach_buffer(struct iio_dev *indio_dev,
> +			      struct iio_buffer *buffer);
Hmm. I made a mess of splitting up these changes into patches.
This should be in the other branch of the ifdef.
Fixed up.
>  #endif /* CONFIG_IIO_BUFFER */
>  
>  #endif /* _IIO_BUFFER_GENERIC_H_ */
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2017-01-08  9:48 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-02 19:28 [PATCH 00/11] buffer.h cleanup and split Jonathan Cameron
2017-01-02 19:28 ` [PATCH 01/11] iio:buffer: Stop exporting iio_update_demux Jonathan Cameron
2017-01-02 19:28 ` [PATCH 02/11] iio:buffer.h Reformat structure comments to be inline Jonathan Cameron
2017-01-02 19:28 ` [PATCH 03/11] iio:buffer: Introduced a function to assign the buffer specific attrs Jonathan Cameron
2017-01-02 19:28 ` [PATCH 04/11] iio:buffer: Stop exporting iio_scan_mask_query Jonathan Cameron
2017-01-02 19:28 ` [PATCH 05/11] iio:buffers: Push some docs down into the .c file Jonathan Cameron
2017-01-02 19:28 ` [PATCH 06/11] iio:buffer:iio_push_to_buffers_with_timestamp fix kernel-doc Jonathan Cameron
2017-01-02 19:28 ` [PATCH 07/11] iio:kfifo_buf header include push down Jonathan Cameron
2017-01-07 21:52   ` Jonathan Cameron
2017-01-02 19:28 ` [PATCH 08/11] iio:buffer.h include pushdown into buffer implementations Jonathan Cameron
2017-01-02 19:28 ` [PATCH 09/11] iio:buffer: Push implementation of iio_device_attach_buffer into .c file Jonathan Cameron
2017-01-07 22:00   ` Jonathan Cameron
2017-01-02 19:28 ` [PATCH 10/11] iio:dummy: Stop enabling timestamp by default Jonathan Cameron
2017-01-02 19:28 ` [PATCH 11/11] iio:buffer.h - split into buffer.h and buffer_impl.h Jonathan Cameron
2017-01-04 18:41 ` [PATCH 00/11] buffer.h cleanup and split Lars-Peter Clausen
2017-01-07 19:45   ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.