[PATCH v4 3/4] iio: adc: qcom-pm8xxx-xoadc: constify pointers in read operations

From: Antony Kurniawan Soemardi

Date: Sat Apr 25 2026 - 18:00:38 EST


These functions do not modify the indio_dev & adc structure, so they
should be marked const to allow the compiler to catch any accidental
modifications and to document the read only nature of these functions.

Signed-off-by: Antony Kurniawan Soemardi <linux@xxxxxxxxxxxxxx>
---
drivers/iio/adc/qcom-pm8xxx-xoadc.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
index 89858e81c859..2ee080b27d93 100644
--- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c
+++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
@@ -414,8 +414,8 @@ struct pm8xxx_xoadc {

static irqreturn_t pm8xxx_eoc_irq(int irq, void *d)
{
- struct iio_dev *indio_dev = d;
- struct pm8xxx_xoadc *adc = iio_priv(indio_dev);
+ const struct iio_dev *indio_dev = d;
+ const struct pm8xxx_xoadc *adc = iio_priv(indio_dev);

complete(&adc->complete);

@@ -423,7 +423,7 @@ static irqreturn_t pm8xxx_eoc_irq(int irq, void *d)
}

static struct pm8xxx_chan_info *
-pm8xxx_get_channel(struct pm8xxx_xoadc *adc, u8 chan)
+pm8xxx_get_channel(const struct pm8xxx_xoadc *adc, u8 chan)
{
int i;

@@ -435,7 +435,7 @@ pm8xxx_get_channel(struct pm8xxx_xoadc *adc, u8 chan)
return NULL;
}

-static int pm8xxx_read_channel_rsv(struct pm8xxx_xoadc *adc,
+static int pm8xxx_read_channel_rsv(const struct pm8xxx_xoadc *adc,
const struct pm8xxx_chan_info *ch,
u8 rsv, u16 *adc_code,
bool force_ratiometric)
@@ -564,7 +564,7 @@ static int pm8xxx_read_channel_rsv(struct pm8xxx_xoadc *adc,
return ret;
}

-static int pm8xxx_read_channel(struct pm8xxx_xoadc *adc,
+static int pm8xxx_read_channel(const struct pm8xxx_xoadc *adc,
const struct pm8xxx_chan_info *ch,
u16 *adc_code)
{
@@ -647,7 +647,7 @@ static int pm8xxx_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{
- struct pm8xxx_xoadc *adc = iio_priv(indio_dev);
+ const struct pm8xxx_xoadc *adc = iio_priv(indio_dev);
const struct pm8xxx_chan_info *ch;
u16 adc_code;
int ret;
@@ -948,8 +948,8 @@ static int pm8xxx_xoadc_probe(struct platform_device *pdev)

static void pm8xxx_xoadc_remove(struct platform_device *pdev)
{
- struct iio_dev *indio_dev = platform_get_drvdata(pdev);
- struct pm8xxx_xoadc *adc = iio_priv(indio_dev);
+ const struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ const struct pm8xxx_xoadc *adc = iio_priv(indio_dev);

iio_device_unregister(indio_dev);


--
2.34.1