Commit 62f4f36c authored by Jonathan Cameron's avatar Jonathan Cameron

iio: core: move @scan_index_timestamp to struct iio_dev_opaque

No reason for this cached value to be exposed to drivers so move it
to the opaque structure.
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: default avatarAlexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20210426174911.397061-6-jic23@kernel.org
parent 3028e0c2
...@@ -601,8 +601,10 @@ static unsigned int iio_storage_bytes_for_si(struct iio_dev *indio_dev, ...@@ -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) 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, 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, 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, ...@@ -1469,6 +1471,7 @@ static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
struct iio_dev *indio_dev, struct iio_dev *indio_dev,
int index) int index)
{ {
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
struct iio_dev_attr *p; struct iio_dev_attr *p;
struct attribute **attr; struct attribute **attr;
int ret, i, attrn, scan_el_attrcount, buffer_attrcount; 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, ...@@ -1495,7 +1498,7 @@ static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
goto error_cleanup_dynamic; goto error_cleanup_dynamic;
scan_el_attrcount += ret; scan_el_attrcount += ret;
if (channels[i].type == IIO_TIMESTAMP) if (channels[i].type == IIO_TIMESTAMP)
indio_dev->scan_index_timestamp = iio_dev_opaque->scan_index_timestamp =
channels[i].scan_index; channels[i].scan_index;
} }
if (indio_dev->masklength && buffer->scan_mask == NULL) { if (indio_dev->masklength && buffer->scan_mask == NULL) {
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
* @groupcounter: index of next attribute group * @groupcounter: index of next attribute group
* @legacy_scan_el_group: attribute group for legacy scan elements attribute group * @legacy_scan_el_group: attribute group for legacy scan elements attribute group
* @legacy_buffer_group: attribute group for legacy buffer attributes 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 * @debugfs_dentry: device specific debugfs dentry
* @cached_reg_addr: cached register address for debugfs reads * @cached_reg_addr: cached register address for debugfs reads
* @read_buf: read buffer to be used for the initial reg read * @read_buf: read buffer to be used for the initial reg read
...@@ -44,6 +45,9 @@ struct iio_dev_opaque { ...@@ -44,6 +45,9 @@ struct iio_dev_opaque {
int groupcounter; int groupcounter;
struct attribute_group legacy_scan_el_group; struct attribute_group legacy_scan_el_group;
struct attribute_group legacy_buffer_group; struct attribute_group legacy_buffer_group;
unsigned int scan_index_timestamp;
#if defined(CONFIG_DEBUG_FS) #if defined(CONFIG_DEBUG_FS)
struct dentry *debugfs_dentry; struct dentry *debugfs_dentry;
unsigned cached_reg_addr; unsigned cached_reg_addr;
......
...@@ -501,7 +501,6 @@ struct iio_buffer_setup_ops { ...@@ -501,7 +501,6 @@ struct iio_buffer_setup_ops {
* channels * channels
* @active_scan_mask: [INTERN] union of all scan masks requested by buffers * @active_scan_mask: [INTERN] union of all scan masks requested by buffers
* @scan_timestamp: [INTERN] set if any buffers have requested timestamp * @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) * @trig: [INTERN] current device trigger (buffer modes)
* @pollfunc: [DRIVER] function run on trigger being received * @pollfunc: [DRIVER] function run on trigger being received
* @pollfunc_event: [DRIVER] function run on events trigger being received * @pollfunc_event: [DRIVER] function run on events trigger being received
...@@ -532,7 +531,6 @@ struct iio_dev { ...@@ -532,7 +531,6 @@ struct iio_dev {
unsigned masklength; unsigned masklength;
const unsigned long *active_scan_mask; const unsigned long *active_scan_mask;
bool scan_timestamp; bool scan_timestamp;
unsigned scan_index_timestamp;
struct iio_trigger *trig; struct iio_trigger *trig;
struct iio_poll_func *pollfunc; struct iio_poll_func *pollfunc;
struct iio_poll_func *pollfunc_event; struct iio_poll_func *pollfunc_event;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment