From: Jonathan Cameron <jic23@kernel.org>
To: "Tinaco, Mariel" <Mariel.Tinaco@analog.com>
Cc: "David Lechner" <dlechner@baylibre.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: Sat, 14 Sep 2024 12:45:27 +0100 [thread overview]
Message-ID: <20240914124527.1b89a660@jic23-huawei> (raw)
In-Reply-To: <DM8PR03MB6213FD30FCD465AA0262E4BB919A2@DM8PR03MB6213.namprd03.prod.outlook.com>
Hi Mariel,
You get to be the person I moan at today (though not the only person
doing it!).
Please crop to only the relevant information for continuing the
discussion. It is not necessarily easy to find where you reply if you
keep too much context.
...
> > > +static int ad8460_probe(struct spi_device *spi) {
> > > + struct ad8460_state *state;
> > > + struct iio_dev *indio_dev;
> > > + struct device *dev;
> > > + u32 tmp[2], temp;
> > > + int ret;
> > > +
> > > + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*state));
> > > + if (!indio_dev)
> > > + return -ENOMEM;
> > > +
> > > + state = iio_priv(indio_dev);
> > > + mutex_init(&state->lock);
> > > +
> > > + indio_dev->name = "ad8460";
> > > + indio_dev->info = &ad8460_info;
> > > +
> > > + state->spi = spi;
> > > + dev = &spi->dev;
> > > +
> > > + state->regmap = devm_regmap_init_spi(spi,
> > &ad8460_regmap_config);
> > > + if (IS_ERR(state->regmap))
> > > + return dev_err_probe(dev, PTR_ERR(state->regmap),
> > > + "Failed to initialize regmap");
> > > +
> > > + state->sync_clk = devm_clk_get_enabled(dev, NULL);
> > > + if (IS_ERR(state->sync_clk))
> > > + return dev_err_probe(dev, PTR_ERR(state->sync_clk),
> > > + "Failed to get sync clk\n");
> > > +
> > > + state->tmp_adc_channel = devm_iio_channel_get(dev, "ad8460-
> > tmp");
> >
> > Should we check for specific errors here? For example what if we get -
> > EPROBE_DEFER? Also, it doesn't like we could ever get NULL, so IS_ERR()
> > should be sufficient.
> >
>
> It says in the docs that, the intended channel might return -EPROBE_DEFER
> If the driver associated with that channel depends on resources that are not
> Yet available. For this specific case, should I create a loop that waits for
> That channel to be available before proceeding with the probe function?
Normally I'd say fail the probe with EPROBE_DEFER but in this case
it's awkward because this is far from a 'required' feature and whilst
DT providing the channel would indicate that the board supports using
it, that doesn't mean a given system has the driver for the ADC.
I don't want to suggest we make this a CONFIG_XXX option but I can't
immediately see an alternative that lets people intentionally not build
the driver support for the ADC.
>
> How would this be implemented?
>
> Originally, this channel was intended to be optional. If any error results from
> Obtaining it, it will not be included in the channels.
>
Given IIO drivers will probe in an unknown order this will fail perhaps half the
time. Normally deferral deals with that, because the consumer isn't useful
without the channel. Here it is...
I'm open to other suggestions on this but right now it looks like only way
to definitely handle it is a config option.
Maybe for now we don't provide one and see if anyone cares? That is
effectively make if required to provide an ADC driver if the DT describes
the channel we are getting. If that driver isn't loaded yet -EPROBE_DEFER and
wait for it to show up.
Jonathan
next prev parent reply other threads:[~2024-09-14 11:45 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
2024-09-10 1:44 ` Tinaco, Mariel
2024-09-14 11:45 ` Jonathan Cameron [this message]
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=20240914124527.1b89a660@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