All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: linux-iio@vger.kernel.org
Cc: Alexandru Ardelean <ardeleanalex@gmail.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: [PATCH 5/9] iio: core: move @scan_index_timestamp to struct iio_dev_opaque
Date: Mon, 26 Apr 2021 18:49:07 +0100	[thread overview]
Message-ID: <20210426174911.397061-6-jic23@kernel.org> (raw)
In-Reply-To: <20210426174911.397061-1-jic23@kernel.org>

From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

No reason for this cached value to be exposed to drivers so move it
to the opaque structure.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
 drivers/iio/industrialio-buffer.c | 7 +++++--
 include/linux/iio/iio-opaque.h    | 4 ++++
 include/linux/iio/iio.h           | 2 --
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 9a8e16c7e9af..9ecb3c58d94c 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -601,8 +601,10 @@ static unsigned int iio_storage_bytes_for_si(struct iio_dev *indio_dev,
 
 static unsigned int iio_storage_bytes_for_timestamp(struct iio_dev *indio_dev)
 {
+	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+
 	return iio_storage_bytes_for_si(indio_dev,
-					indio_dev->scan_index_timestamp);
+					iio_dev_opaque->scan_index_timestamp);
 }
 
 static int iio_compute_scan_bytes(struct iio_dev *indio_dev,
@@ -1469,6 +1471,7 @@ static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
 					     struct iio_dev *indio_dev,
 					     int index)
 {
+	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
 	struct iio_dev_attr *p;
 	struct attribute **attr;
 	int ret, i, attrn, scan_el_attrcount, buffer_attrcount;
@@ -1495,7 +1498,7 @@ static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
 				goto error_cleanup_dynamic;
 			scan_el_attrcount += ret;
 			if (channels[i].type == IIO_TIMESTAMP)
-				indio_dev->scan_index_timestamp =
+				iio_dev_opaque->scan_index_timestamp =
 					channels[i].scan_index;
 		}
 		if (indio_dev->masklength && buffer->scan_mask == NULL) {
diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h
index 10aa97239117..02038fb2d291 100644
--- a/include/linux/iio/iio-opaque.h
+++ b/include/linux/iio/iio-opaque.h
@@ -22,6 +22,7 @@
  * @groupcounter:		index of next attribute group
  * @legacy_scan_el_group:	attribute group for legacy scan elements attribute group
  * @legacy_buffer_group:	attribute group for legacy buffer attributes group
+ * @scan_index_timestamp:	cache of the index to the timestamp
  * @debugfs_dentry:		device specific debugfs dentry
  * @cached_reg_addr:		cached register address for debugfs reads
  * @read_buf:			read buffer to be used for the initial reg read
@@ -44,6 +45,9 @@ struct iio_dev_opaque {
 	int				groupcounter;
 	struct attribute_group		legacy_scan_el_group;
 	struct attribute_group		legacy_buffer_group;
+
+	unsigned int			scan_index_timestamp;
+
 #if defined(CONFIG_DEBUG_FS)
 	struct dentry			*debugfs_dentry;
 	unsigned			cached_reg_addr;
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 672f141f74c5..cbc9e9ece0a6 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -501,7 +501,6 @@ struct iio_buffer_setup_ops {
  *			channels
  * @active_scan_mask:	[INTERN] union of all scan masks requested by buffers
  * @scan_timestamp:	[INTERN] set if any buffers have requested timestamp
- * @scan_index_timestamp:[INTERN] cache of the index to the timestamp
  * @trig:		[INTERN] current device trigger (buffer modes)
  * @pollfunc:		[DRIVER] function run on trigger being received
  * @pollfunc_event:	[DRIVER] function run on events trigger being received
@@ -532,7 +531,6 @@ struct iio_dev {
 	unsigned			masklength;
 	const unsigned long		*active_scan_mask;
 	bool				scan_timestamp;
-	unsigned			scan_index_timestamp;
 	struct iio_trigger		*trig;
 	struct iio_poll_func		*pollfunc;
 	struct iio_poll_func		*pollfunc_event;
-- 
2.31.1


  parent reply	other threads:[~2021-04-26 17:50 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26 17:49 [PATCH 0/9] iio: Move more things from iio_dev to iio_dev_opaque Jonathan Cameron
2021-04-26 17:49 ` [PATCH 1/9] iio: core: move @id from struct iio_dev to struct iio_dev_opaque Jonathan Cameron
2021-04-27  7:44   ` Alexandru Ardelean
2021-04-27 17:16     ` Jonathan Cameron
2021-05-03 11:42   ` Jonathan Cameron
2021-04-26 17:49 ` [PATCH 2/9] iio: avoid shadowing of variable name in to_iio_dev_opaque() Jonathan Cameron
2021-04-27  7:45   ` Alexandru Ardelean
2021-04-26 17:49 ` [PATCH 3/9] iio: core: move @driver_module from struct iio_dev to struct iio_dev_opaque Jonathan Cameron
2021-04-28  6:55   ` Alexandru Ardelean
2021-04-26 17:49 ` [PATCH 4/9] iio: core: move @trig_readonly " Jonathan Cameron
2021-04-27  8:03   ` Alexandru Ardelean
2021-04-26 17:49 ` Jonathan Cameron [this message]
2021-04-27  8:03   ` [PATCH 5/9] iio: core: move @scan_index_timestamp " Alexandru Ardelean
2021-04-26 17:49 ` [PATCH 6/9] iio: core: move @info_exist_lock " Jonathan Cameron
2021-04-27  8:04   ` Alexandru Ardelean
2021-04-26 17:49 ` [PATCH 7/9] iio: core: move @chrdev from struct iio_dev " Jonathan Cameron
2021-04-27  8:06   ` Alexandru Ardelean
2021-04-27 17:17     ` Jonathan Cameron
2021-04-26 17:49 ` [PATCH 8/9] iio: core: move @flags " Jonathan Cameron
2021-04-27  8:07   ` Alexandru Ardelean
2021-04-26 17:49 ` [PATCH 9/9] iio: core: move @clock_id " Jonathan Cameron
2021-04-27  8:02   ` Alexandru Ardelean
2021-04-27 17:19     ` Jonathan Cameron
2021-04-27  8:08 ` [PATCH 0/9] iio: Move more things from iio_dev to iio_dev_opaque Alexandru Ardelean
2021-04-27 17:12   ` Jonathan Cameron
2021-04-28  6:55     ` Alexandru Ardelean
2021-05-03 11:53       ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210426174911.397061-6-jic23@kernel.org \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=ardeleanalex@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.