From: "Nuno Sá" <noname.nuno@gmail.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá via B4 Relay" <devnull+nuno.sa.analog.com@kernel.org>
Cc: nuno.sa@analog.com, linux-iio@vger.kernel.org,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH 2/2] iio: dac: ltc2688: use the auto lock API
Date: Mon, 29 Sep 2025 06:41:33 +0100 [thread overview]
Message-ID: <7fe5c02a0594a8fee0a0008722a2ab3d943925de.camel@gmail.com> (raw)
In-Reply-To: <20250927185631.1051e315@jic23-huawei>
On Sat, 2025-09-27 at 18:56 +0100, Jonathan Cameron wrote:
> On Tue, 23 Sep 2025 09:41:48 +0100
> Nuno Sá via B4 Relay <devnull+nuno.sa.analog.com@kernel.org> wrote:
>
> > From: Nuno Sá <nuno.sa@analog.com>
> >
> > Make use of the cleanup API so that we can simplify some code paths.
> >
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> > drivers/iio/dac/ltc2688.c | 24 ++++++++++--------------
>
> This enables a few related simplifications that should be in this patch as well.
Yes, both make sense.
- Nuno Sá
>
> > static int ltc2688_dac_code_read(struct ltc2688_state *st, u32 chan, u32 input,
> > @@ -236,15 +234,15 @@ static int ltc2688_dac_code_read(struct ltc2688_state *st,
> > u32 chan, u32 input,
> > struct ltc2688_chan *c = &st->channels[chan];
> > int ret;
> >
> > - mutex_lock(&st->lock);
> > + guard(mutex)(&st->lock);
> > ret = regmap_update_bits(st->regmap, LTC2688_CMD_A_B_SELECT, BIT(chan),
> > input << chan);
> > if (ret)
> > - goto out_unlock;
> > + return ret;
> >
> > ret = regmap_read(st->regmap, LTC2688_CMD_CH_CODE(chan), code);
> > -out_unlock:
> > - mutex_unlock(&st->lock);
> > + if (ret)
> > + return ret;
> >
> > if (!c->toggle_chan && input == LTC2688_INPUT_B)
> > *code = FIELD_GET(LTC2688_DITHER_RAW_MASK, *code);
>
> There is a return ret later in this function that can be return 0;
>
> > @@ -359,15 +357,13 @@ static ssize_t ltc2688_dither_toggle_set(struct iio_dev
> > *indio_dev,
> > if (ret)
> > return ret;
> >
> > - mutex_lock(&st->lock);
> > + guard(mutex)(&st->lock);
> > ret = regmap_update_bits(st->regmap, LTC2688_CMD_TOGGLE_DITHER_EN,
> > BIT(chan->channel), en << chan->channel);
> > if (ret)
> > - goto out_unlock;
> > + return ret;
> >
> > c->mode = en ? LTC2688_MODE_DITHER_TOGGLE : LTC2688_MODE_DEFAULT;
> > -out_unlock:
> > - mutex_unlock(&st->lock);
> >
> > return ret ?: len;
> return len; as can't get here with non zero ret.
>
> > }
> >
>
prev parent reply other threads:[~2025-09-29 6:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 8:41 [PATCH 0/2] iio: dac: ltc2688: minor cleanups Nuno Sá via B4 Relay
2025-09-23 8:41 ` [PATCH 1/2] iio: dac: ltc2688: make use of devm_mutex_init() Nuno Sá via B4 Relay
2025-09-27 17:57 ` Jonathan Cameron
2025-09-23 8:41 ` [PATCH 2/2] iio: dac: ltc2688: use the auto lock API Nuno Sá via B4 Relay
2025-09-27 17:56 ` Jonathan Cameron
2025-09-29 5:41 ` Nuno Sá [this message]
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=7fe5c02a0594a8fee0a0008722a2ab3d943925de.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=andy@kernel.org \
--cc=devnull+nuno.sa.analog.com@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.com \
/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;
as well as URLs for NNTP newsgroup(s).