From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: "Tinaco, Mariel" <Mariel.Tinaco@analog.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Hennerich, Michael" <Michael.Hennerich@analog.com>,
"Conor Dooley" <conor+dt@kernel.org>,
"Marcelo Schmitt" <marcelo.schmitt1@gmail.com>,
"Dimitri Fedrau" <dima.fedrau@gmail.com>,
"Nuno Sá" <noname.nuno@gmail.com>
Subject: Re: [PATCH v3 2/2] iio: dac: support the ad8460 Waveform DAC
Date: Mon, 9 Sep 2024 20:09:36 +0100 [thread overview]
Message-ID: <20240909200936.68c23866@jic23-huawei> (raw)
In-Reply-To: <b1584871-9a9d-4042-98c3-00581bdb5499@baylibre.com>
On Mon, 9 Sep 2024 09:51:35 -0500
David Lechner <dlechner@baylibre.com> wrote:
> On 9/9/24 4:47 AM, Tinaco, Mariel wrote:
> >
> >
>
> ...
>
> >>> + *val = get_unaligned_le16(state->spi_tx_buf);
> >>
> >> With spi_tx_buf changed to __le16, this can use le16_to_cpu() instead of
> >> get_unaligned_le16().
> >>
> >
> > I suppose we use the cpu_to_le16 for the set_hvdac_word function?
> >
> > static int ad8460_set_hvdac_word(struct ad8460_state *state, int index, int val)
> > {
> > state->spi_tx_buf = cpu_to_le16(FIELD_PREP(AD8460_DATA_BYTE_FULL_MSK, val));
> >
> > return regmap_bulk_write(state->regmap, AD8460_HVDAC_DATA_WORD(index),
> > &state->spi_tx_buf, AD8460_DATA_BYTE_WORD_LENGTH);
> > }
> >
>
> Yes, that looks correct.
>
>
> >>> +static ssize_t ad8460_write_toggle_en(struct iio_dev *indio_dev, uintptr_t
> >> private,
> >>> + const struct iio_chan_spec *chan,
> >>> + const char *buf, size_t len) {
> >>> + struct ad8460_state *state = iio_priv(indio_dev);
> >>> + bool toggle_en;
> >>> + int ret;
> >>> +
> >>> + ret = kstrtobool(buf, &toggle_en);
> >>> + if (ret)
> >>> + return ret;
> >>> +
> >>> + iio_device_claim_direct_scoped(return -EBUSY, indio_dev)
> >>> + return ad8460_enable_apg_mode(state, toggle_en);
> >>> + unreachable();
> >>> +}
> >>
> >> Hmm... do we need to make an unscoped version of
> >> iio_device_claim_direct_scoped()?
> >>
> >
> > So iio_device_claim_direct_scoped is used here because the buffer enable/disable
> > accesses this enable_apg_mode function. Is it also a standard practice to put the
> > kstrobool() util inside the scope?
> >
>
> Since this is at the end of a function with nothing after it, it
> would be nice if we could avoid the indent and unreachable();
>
> The idea would be to write the last 3 lines like this instead:
>
> guard_cond(iio_device_claim_direct, return -EBUSY, indio_dev);
>
> But I didn't see a `guard_cond()` analog of `guard()` in
> linux/cleanup.h. So this is probably fine for now and adding
> `guard_cond()` (if it is actually a good idea in the first
> place) can be a job for another time.
That's a fun topic if you check the archives. Linus really
didn't like the proposal
https://lore.kernel.org/all/170905253339.2268463.9376907713092612237.stgit@dwillia2-xfh.jf.intel.com/
Mind you I don't think he much likes scoped_cond_guard() either!
Jonathan
next prev parent reply other threads:[~2024-09-09 19:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 2:30 [PATCH v3 0/2] Add support to AD8460 Waveform Generator DAC Mariel Tinaco
2024-09-04 2:30 ` [PATCH v3 1/2] dt-bindings: iio: dac: add docs for ad8460 Mariel Tinaco
2024-09-04 6:20 ` Krzysztof Kozlowski
2024-09-07 17:01 ` Jonathan Cameron
2024-09-09 6:22 ` Tinaco, Mariel
2024-09-09 6:41 ` Krzysztof Kozlowski
2024-09-04 2:30 ` [PATCH v3 2/2] iio: dac: support the ad8460 Waveform DAC Mariel Tinaco
2024-09-04 15:50 ` kernel test robot
2024-09-04 17:23 ` kernel test robot
2024-09-06 0:50 ` David Lechner
2024-09-09 9:47 ` Tinaco, Mariel
2024-09-09 14:51 ` David Lechner
2024-09-09 19:09 ` Jonathan Cameron [this message]
2024-09-10 1:44 ` Tinaco, Mariel
2024-09-14 11:45 ` Jonathan Cameron
2024-09-07 17:14 ` Jonathan Cameron
2024-09-09 8:22 ` Tinaco, Mariel
2024-09-09 14:41 ` David Lechner
2024-09-04 6:16 ` [PATCH v3 0/2] Add support to AD8460 Waveform Generator DAC Krzysztof Kozlowski
2024-09-05 1:10 ` Tinaco, Mariel
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=20240909200936.68c23866@jic23-huawei \
--to=jic23@kernel.org \
--cc=Mariel.Tinaco@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dima.fedrau@gmail.com \
--cc=dlechner@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo.schmitt1@gmail.com \
--cc=noname.nuno@gmail.com \
--cc=robh@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;
as well as URLs for NNTP newsgroup(s).