From: Jorge Marques <jorge.marques@analog.com>
To: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>
Cc: <linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Jorge Marques <jorge.marques@analog.com>
Subject: [PATCH] iio: Mark iio_dev as const in getter methods
Date: Mon, 3 Mar 2025 15:46:25 +0100 [thread overview]
Message-ID: <20250303-b4-iio-dev-const-v1-1-c2d9d5fe5ac1@analog.com> (raw)
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>
next reply other threads:[~2025-03-03 14:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-03 14:46 Jorge Marques [this message]
2025-03-05 12:56 ` [PATCH] iio: Mark iio_dev as const in getter methods 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=20250303-b4-iio-dev-const-v1-1-c2d9d5fe5ac1@analog.com \
--to=jorge.marques@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox