public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikhil Gautam <nikhilgtr@gmail.com>
To: linux-iio@vger.kernel.org
Cc: jic23@kernel.org, dlechner@baylibre.com,
	Nikhil Gautam <nikhilgtr@gmail.com>
Subject: [PATCH v5 2/3] iio: dac: mcp4821: move state initialization outside switch
Date: Tue, 14 Apr 2026 14:52:52 +0530	[thread overview]
Message-ID: <20260414092254.34883-3-nikhilgtr@gmail.com> (raw)
In-Reply-To: <20260414092254.34883-1-nikhilgtr@gmail.com>

Move the iio_priv() call outside the switch statement in
mcp4821_read_raw() to avoid repeating it in multiple cases.

This is a cleanup change with no functional impact.

Signed-off-by: Nikhil Gautam <nikhilgtr@gmail.com>
---
 drivers/iio/dac/mcp4821.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iio/dac/mcp4821.c b/drivers/iio/dac/mcp4821.c
index 29187f2a9d3c..102ae3718514 100644
--- a/drivers/iio/dac/mcp4821.c
+++ b/drivers/iio/dac/mcp4821.c
@@ -115,11 +115,10 @@ static int mcp4821_read_raw(struct iio_dev *indio_dev,
 			    struct iio_chan_spec const *chan, int *val,
 			    int *val2, long mask)
 {
-	struct mcp4821_state *state;
+	struct mcp4821_state *state = iio_priv(indio_dev);
 
 	switch (mask) {
 	case IIO_CHAN_INFO_RAW:
-		state = iio_priv(indio_dev);
 		*val = state->dac_value[chan->channel];
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
-- 
2.43.0


  parent reply	other threads:[~2026-04-14  9:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14  9:22 [PATCH v5 0/3] iio: dac: mcp4821: add configurable gain support Nikhil Gautam
2026-04-14  9:22 ` [PATCH v5 1/3] iio: dac: mcp4821: fix spelling mistake in enum name Nikhil Gautam
2026-04-14  9:22 ` Nikhil Gautam [this message]
2026-04-14 13:33   ` [PATCH v5 2/3] iio: dac: mcp4821: move state initialization outside switch David Lechner
2026-04-14  9:22 ` [PATCH v5 3/3] iio: dac: mcp4821: add configurable gain support Nikhil Gautam
2026-04-14 13:57   ` David Lechner
2026-04-14 16:44     ` Nikhil Gautam

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=20260414092254.34883-3-nikhilgtr@gmail.com \
    --to=nikhilgtr@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@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