* [PATCH] iio: Mark iio_dev as const in getter methods
@ 2025-03-03 14:46 Jorge Marques
2025-03-05 12:56 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Jorge Marques @ 2025-03-03 14:46 UTC (permalink / raw)
To: Jonathan Cameron, Lars-Peter Clausen
Cc: linux-iio, linux-kernel, Jorge Marques
get_current_scan_type read-only method allows to support multiple
scan types per channel, which may also depend on a buffer enabled state.
Mark iio_dev as const in iio_device_id, iio_device_get_current_mode,
iio_buffer_enabled read-only methods so they can be used from other
read-only methods.
Signed-off-by: Jorge Marques <jorge.marques@analog.com>
---
drivers/iio/industrialio-core.c | 6 +++---
include/linux/iio/iio.h | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index a2117ad1337d55468c0f21c274fcbedd352c97ff..3b743cc1af6a15c5b9828e2c54d89ab8abb5524d 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -197,7 +197,7 @@ static const char * const iio_chan_info_postfix[] = {
*
* Returns: Unique ID for the device.
*/
-int iio_device_id(struct iio_dev *indio_dev)
+int iio_device_id(const struct iio_dev *indio_dev)
{
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
@@ -211,7 +211,7 @@ EXPORT_SYMBOL_GPL(iio_device_id);
*
* Returns: True, if the buffer is enabled.
*/
-bool iio_buffer_enabled(struct iio_dev *indio_dev)
+bool iio_buffer_enabled(const struct iio_dev *indio_dev)
{
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
@@ -2227,7 +2227,7 @@ EXPORT_SYMBOL_GPL(iio_device_release_buffer_mode);
* the opaque @currentmode variable
* @indio_dev: IIO device structure for device
*/
-int iio_device_get_current_mode(struct iio_dev *indio_dev)
+int iio_device_get_current_mode(const struct iio_dev *indio_dev)
{
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 56161e02f002cbe3a835cefce0e702c0f9776c81..b9ddfdeaef64dc5df687eac44d3f968bed2fde8e 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -627,9 +627,9 @@ struct iio_dev {
void *__private priv;
};
-int iio_device_id(struct iio_dev *indio_dev);
-int iio_device_get_current_mode(struct iio_dev *indio_dev);
-bool iio_buffer_enabled(struct iio_dev *indio_dev);
+int iio_device_id(const struct iio_dev *indio_dev);
+int iio_device_get_current_mode(const struct iio_dev *indio_dev);
+bool iio_buffer_enabled(const struct iio_dev *indio_dev);
const struct iio_chan_spec
*iio_find_channel_from_si(struct iio_dev *indio_dev, int si);
---
base-commit: 7eb172143d5508b4da468ed59ee857c6e5e01da6
change-id: 20250303-b4-iio-dev-const-cc26bac40292
Best regards,
--
Jorge Marques <jorge.marques@analog.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: Mark iio_dev as const in getter methods
2025-03-03 14:46 [PATCH] iio: Mark iio_dev as const in getter methods Jorge Marques
@ 2025-03-05 12:56 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2025-03-05 12:56 UTC (permalink / raw)
To: Jorge Marques; +Cc: Lars-Peter Clausen, linux-iio, linux-kernel
On Mon, 3 Mar 2025 15:46:25 +0100
Jorge Marques <jorge.marques@analog.com> wrote:
> get_current_scan_type read-only method allows to support multiple
> scan types per channel, which may also depend on a buffer enabled state.
> Mark iio_dev as const in iio_device_id, iio_device_get_current_mode,
> iio_buffer_enabled read-only methods so they can be used from other
> read-only methods.
>
> Signed-off-by: Jorge Marques <jorge.marques@analog.com>
Hi Jorge,
I'm not against this, but I would like to see this patch as part of
a series that uses it from a read-only method.
Until then this looks like noise unless there is other reasoning.
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-05 12:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-03 14:46 [PATCH] iio: Mark iio_dev as const in getter methods Jorge Marques
2025-03-05 12:56 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox