From: "Nuno Sá" <noname.nuno@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Alexis Czezar Torreno" <alexisczezar.torreno@analog.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Uwe Kleine-König" <ukleinek@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org
Subject: Re: [PATCH 2/3] iio: dac: ad5706r: Add support for AD5706R DAC
Date: Fri, 20 Feb 2026 15:02:37 +0000 [thread overview]
Message-ID: <a6a2fc3ebb45fa4d7b379d552196d56eb13fa8d3.camel@gmail.com> (raw)
In-Reply-To: <aZg-vtenBU2rKKX_@smile.fi.intel.com>
On Fri, 2026-02-20 at 13:00 +0200, Andy Shevchenko wrote:
> On Fri, Feb 20, 2026 at 10:48:59AM +0000, Nuno Sá wrote:
> > On Fri, 2026-02-20 at 16:02 +0800, Alexis Czezar Torreno wrote:
>
> ...
>
> > > +static void ad5706r_debugs_init(struct iio_dev *indio_dev)
> > > +{
> > > + struct dentry *d = iio_get_debugfs_dentry(indio_dev);
> >
> > It should have:
> >
> > if (!IS_ENABLED(CONFIG_DEBUGFS))
> > return
>
> But why? The debugfs is a stub when disabled, nobody should do that
> in the cases when the main purpose is not the debugfs code.
Because the compiler can then optimize away all of the above code...
- Nuno Sá
>
> > > + debugfs_create_file_unsafe("streaming_addr", 0600, d,
> > > + indio_dev, &ad5706r_streaming_addr_fops);
> > > + debugfs_create_file_unsafe("streaming_len", 0600, d,
> > > + indio_dev, &ad5706r_streaming_len_fops);
> > > + debugfs_create_file_unsafe("streaming_data", 0600, d,
> > > + indio_dev, &ad5706r_streaming_data_fops);
> > > + debugfs_create_file_unsafe("streaming_reg_access", 0600, d,
> > > + indio_dev, &ad5706r_streaming_reg_access_fops);
> > > + debugfs_create_file_unsafe("spi_speed_hz_write", 0600, d,
> > > + indio_dev, &ad5706r_spi_speed_write_fops);
> > > + debugfs_create_file_unsafe("spi_speed_hz_read", 0600, d,
> > > + indio_dev, &ad5706r_spi_speed_read_fops);
> > > +}
>
> ...
>
> > > + /* Find which index has this register value */
> > > + for (i = 0; i < ARRAY_SIZE(mux_out_sel_reg_values); i++) {
>
> for (size_t i...)
>
> > > + if (mux_out_sel_reg_values[i] == reg_byte) {
> > > + st->mux_out_sel = i;
> > > + return i; /* Return index, not register value */
> > > + }
> > > + }
>
> ...
>
> > > + return ret ? ret : len;
>
> Use Elvis operator
>
> return ret ?: len;
>
> ...
>
>
> > > + {},
>
> IIO has a style for terminator entry, along with confusing trailing comma.
> If it's a sentinel, it must be one even at a compile time.
>
> > > +};
>
> ...
>
> > > + st->debug_spi_speed_hz_write = 10000000;
> > > + st->debug_spi_speed_hz_read = 10000000;
>
> units.h and other headers for your help
>
> 10 * HZ_PER_MHZ
>
> ...
>
> > > + st->sampling_frequency = 1000000;
>
> In the similar way.
>
> ...
>
> > > + st->reference_volts = 2500;
>
> 2.5kV?! I think you mistakenly put volts where should be _mV
>
> ...
>
> > > + for (i = 0; i < 4; i++) {
>
> Magic 4.
>
> > > + st->hw_active_edge[i] = HW_ACTIVE_EDGE_RISING_EDGE;
> > > + st->range_sel[i] = RANGE_SEL_50;
> > > + st->output_state[i] = OUTPUT_STATE_NORMAL_SW;
> > > + st->ldac_trigger_chn[i] = LDAC_TRIGGER_CHN_HW_TRIGGER;
> > > + st->toggle_trigger_chn[i] = TOGGLE_TRIGGER_CHN_HW_TRIGGER;
> > > + st->dither_trigger_chn[i] = DITHER_TRIGGER_CHN_HW_TRIGGER;
> > > + st->multi_dac_sel_ch[i] = MULTI_DAC_SEL_CH_EXCLUDE;
>
> Hmm... Perhaps memsetXX()? But original loop with the defined iterator will be
> okay:
>
> for (unsigned int i = 0; i < $MAGIC_CONST; i++) {
>
> > > + }
>
> ...
>
> > > + st->resetb_gpio = devm_gpiod_get_optional(dev, "dac-resetb", GPIOD_OUT_LOW);
> > > + if (IS_ERR(st->resetb_gpio)) {
> > > + return dev_err_probe(dev, PTR_ERR(st->resetb_gpio),
> > > + "Failed to get RESET_B GPIO\n");
> > > + }
>
> > > + st->shdn_gpio = devm_gpiod_get_optional(dev, "dac-shdn", GPIOD_OUT_HIGH);
> > > + if (IS_ERR(st->shdn_gpio)) {
> > > + return dev_err_probe(dev, PTR_ERR(st->shdn_gpio),
> > > + "Failed to get SHDN GPIO\n");
> > > + }
>
> The {} are not needed when the body is a single call.
>
> ...
>
> > > +static const struct of_device_id ad5706r_of_match[] = {
> > > + { .compatible = "adi,ad5706r" },
> > > + { },
>
> See above about terminator entry style.
>
> > > +};
next prev parent reply other threads:[~2026-02-20 15:01 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-20 8:02 [PATCH 0/3] Add support for AD5706R DAC Alexis Czezar Torreno
2026-02-20 8:02 ` [PATCH 1/3] dt-bindings: iio: dac: Add binding for AD5706R Alexis Czezar Torreno
2026-02-21 10:45 ` Krzysztof Kozlowski
2026-02-21 16:05 ` David Lechner
2026-02-20 8:02 ` [PATCH 2/3] iio: dac: ad5706r: Add support for AD5706R DAC Alexis Czezar Torreno
2026-02-20 10:48 ` Nuno Sá
2026-02-20 11:00 ` Andy Shevchenko
2026-02-20 15:02 ` Nuno Sá [this message]
2026-02-20 16:56 ` Andy Shevchenko
2026-02-23 10:10 ` Nuno Sá
2026-02-20 10:51 ` Uwe Kleine-König
2026-02-21 16:19 ` David Lechner
2026-02-22 18:57 ` Jonathan Cameron
2026-02-23 4:49 ` Torreno, Alexis Czezar
2026-02-23 8:47 ` Andy Shevchenko
2026-02-20 8:02 ` [PATCH 3/3] MAINTAINERS: Add entry for AD5706R DAC driver Alexis Czezar Torreno
2026-02-20 10:18 ` Nuno Sá
2026-02-20 10:31 ` [PATCH 0/3] Add support for AD5706R DAC Andy Shevchenko
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=a6a2fc3ebb45fa4d7b379d552196d56eb13fa8d3.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=alexisczezar.torreno@analog.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
--cc=ukleinek@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