summaryrefslogtreecommitdiffstats
path: root/drivers/iio/industrialio-core.c
diff options
context:
space:
mode:
authorMiquel Raynal <miquel.raynal@bootlin.com>2022-02-07 15:38:38 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2022-04-10 16:23:01 +0100
commit51570c9d4b3a678f77a50ac139f67290e946ec86 (patch)
tree2c7bdbe7c725c6ef27de8b355b820c8ac27af316 /drivers/iio/industrialio-core.c
parent8c576f87ad7eb639b8bd4472a9bb830e0696dda5 (diff)
downloadlinux-51570c9d4b3a678f77a50ac139f67290e946ec86.tar.bz2
iio: core: Move the currentmode entry to the opaque structure
This entry should, under no situation, be modified by device drivers. Now that we have limited its read access to device drivers really needing it and did so through a dedicated helper, we can easily move this variable to the opaque structure in order to prevent any further modification from non-authorized code (out of the core, basically). Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/20220207143840.707510-12-miquel.raynal@bootlin.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/industrialio-core.c')
-rw-r--r--drivers/iio/industrialio-core.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index fa1e00bee787..a8c4e85c2bb5 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -190,7 +190,9 @@ EXPORT_SYMBOL_GPL(iio_device_id);
*/
bool iio_buffer_enabled(struct iio_dev *indio_dev)
{
- return indio_dev->currentmode
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+
+ return iio_dev_opaque->currentmode
& (INDIO_BUFFER_TRIGGERED | INDIO_BUFFER_HARDWARE |
INDIO_BUFFER_SOFTWARE);
}
@@ -2072,12 +2074,14 @@ EXPORT_SYMBOL_GPL(iio_device_release_direct_mode);
/**
* iio_device_get_current_mode() - helper function providing read-only access to
- * the @currentmode variable
+ * the opaque @currentmode variable
* @indio_dev: IIO device structure for device
*/
int iio_device_get_current_mode(struct iio_dev *indio_dev)
{
- return indio_dev->currentmode;
+ struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
+
+ return iio_dev_opaque->currentmode;
}
EXPORT_SYMBOL_GPL(iio_device_get_current_mode);