Re: [PATCH 4/4] ASoC: codecs: Add support for the generic IIO auxiliary devices

From: Jonathan Cameron
Date: Mon May 01 2023 - 11:09:34 EST



> >
> > > +static int simple_iio_aux_probe(struct platform_device *pdev)
> > > +{
> > > + struct device_node *np = pdev->dev.of_node;
> > > + struct simple_iio_aux_chan *iio_aux_chan;
> > > + struct simple_iio_aux *iio_aux;
> > > + int count;
> > > + u32 tmp;
> > > + int ret;
> > > + int i;
> > > +
> > > + iio_aux = devm_kzalloc(&pdev->dev, sizeof(*iio_aux), GFP_KERNEL);
> > > + if (!iio_aux)
> > > + return -ENOMEM;
> > > +
> > > + iio_aux->dev = &pdev->dev;
> > > +
> > > + count = of_property_count_strings(np, "io-channel-names");
> > > + if (count < 0) {
> > > + dev_err(iio_aux->dev, "%pOF: failed to read io-channel-names\n", np);
> > > + return count;
> > > + }
> > > +
> > > + iio_aux->chans = devm_kmalloc_array(&pdev->dev, count,
> > > + sizeof(*iio_aux->chans), GFP_KERNEL);
> > > + if (!iio_aux->chans)
> > > + return -ENOMEM;
> > > + iio_aux->num_chans = count;
> > > +
> > > + for (i = 0; i < iio_aux->num_chans; i++) {
> > > + iio_aux_chan = iio_aux->chans + i;
> > > +
> > > + ret = of_property_read_string_index(np, "io-channel-names", i,
> > > + &iio_aux_chan->name);
> >
> > Whilst today this will be tightly couple with of, if you can use generic firmware
> > handling where possible (from linux/property.h) it will reduce what needs
> > to be tidied up if anyone fills in the gaps for IIO consumer bindings in ACPI
> > and then someone uses PRP0001 based ACPI bindings.
>
> No device_property_read_*() function family are available to get a value
> from an array using an index.

That feels like it might be a feature gap in the generic property handling that
should be solved. Emtirely reasonable not to do it in this series however!



>
> I would prefer to keep the of_property_read_*() function family I use for this
> first IIO auxiliary device support.
>
> >
> > > + if (ret < 0) {
> > > + dev_err(iio_aux->dev, "%pOF: failed to read io-channel-names[%d]\n", np, i);
> >
> > dev_err_probe() would simplify these cases a little. Not sure on ASOC view on using
> > that for cases that won't defer. I tend to take the view it's nicer everywhere
> > for calls in probe() functions.
>
> I have the feeling that ASoC uses dev_err_probe() for cases that can defer.
> Mark, can you confirm ?
>

Left as needs an answer from Mark.

Jonathan