public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>, nuno.sa@analog.com
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	 Jonathan Cameron <jic23@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Conor Dooley <conor+dt@kernel.org>,
	 Frank Rowand <frowand.list@gmail.com>,
	Olivier Moysan <olivier.moysan@foss.st.com>
Subject: Re: [PATCH v9 5/7] iio: add the IIO backend framework
Date: Wed, 07 Feb 2024 10:16:46 +0100	[thread overview]
Message-ID: <5c0985247622215c3eea548879afe68d0dce00ec.camel@gmail.com> (raw)
In-Reply-To: <CAHp75VdUjNeYsgJHcMC+z9m9j=z7Qzh0BFXR=Zi7jPs6rRVUKg@mail.gmail.com>

On Tue, 2024-02-06 at 16:27 +0200, Andy Shevchenko wrote:
> On Tue, Feb 6, 2024 at 12:08 PM Nuno Sa via B4 Relay
> <devnull+nuno.sa.analog.com@kernel.org> wrote:
> > 
> > From: Nuno Sa <nuno.sa@analog.com>
> > 
> > This is a Framework to handle complex IIO aggregate devices.
> > 
> > The typical architecture is to have one device as the frontend device which
> > can be "linked" against one or multiple backend devices. All the IIO and
> > userspace interface is expected to be registers/managed by the frontend
> > device which will callback into the backends when needed (to get/set
> > some configuration that it does not directly control).
> > 
> > The basic framework interface is pretty simple:
> >  - Backends should register themselves with @devm_iio_backend_register()
> >  - Frontend devices should get backends with @devm_iio_backend_get()
> 
> Not sure what the meaning of @ in the above lines.
> 

No special meaning...

> ...
> 
> > +/*
> > + * Framework to handle complex IIO aggregate devices.
> > + *
> > + * The typical architecture is to have one device as the frontend device
> > which
> > + * can be "linked" against one or multiple backend devices.
> 
> Can we have an ASCII art with an example?

I do have one in the cover and spoke on the possibility of having it here but no
one really expressed any interest on it. Personally, for now, I'm also not
seeing it as *that* important.

> 
> >  All the IIO and
> > + * userspace interface is expected to be registers/managed by the frontend
> > + * device which will callback into the backends when needed (to get/set
> > some
> > + * configuration that it does not directly control).
> > + *
> > + * The framework interface is pretty simple:
> > + *   - Backends should register themselves with
> > @devm_iio_backend_register()
> > + *   - Frontend devices should get backends with @devm_iio_backend_get()
> > + *
> > + * Also to note that the primary target for this framework are converters
> > like
> > + * ADC/DACs so @iio_backend_ops will have some operations typical of
> > converter
> > + * devices. On top of that, this is "generic" for all IIO which means any
> > kind
> > + * of device can make use of the framework. That said, If the
> > @iio_backend_ops
> > + * struct begins to grow out of control, we can always refactor things so
> > that
> > + * the industrialio-backend.c is only left with the really generic stuff.
> > Then,
> > + * we can build on top of it depending on the needs.
> > + *
> > + * Copyright (C) 2023-2024 Analog Devices Inc.
> > + */
> 
> ...
> 
> > +/*
> > + * Helper macros to call backend ops. Makes sure the option is supported
> 
> Missing period.
> 
> > + */
> 
> ...
> 
> > +/**
> > + * iio_backend_chan_enable - Enable a backend channel
> > + * @back:      Backend device
> > + * @chan:      Channel number
> > + *
> > + * RETURNS:
> 
> Not sure if this is the style used in other IIO core files...
> 
> > + * 0 on success, negative error number on failure.
> > + */
> 
> ...
> 
> > +       if (!try_module_get(back->owner)) {
> > +               dev_err(dev, "Cannot get module reference\n");
> > +               return -ENODEV;
> 
> devm_*() are supposed to be used only at ->probe() stage, hence
> dev_err_probe() is fine (and eventually would be nice to have for the
> sake of making messaging uniform).
> 
> > +       }
> 
> ...
> 
> > +       link = device_link_add(dev, back->dev, DL_FLAG_AUTOREMOVE_CONSUMER);
> > +       if (!link) {
> > +               dev_err(dev, "Could not link to supplier(%s)\n",
> > +                       dev_name(back->dev));
> > +               return -EINVAL;
> 
> Ditto.
> 
> > +       }
> 
> ...
> 
> > +       if (name) {
> > +               ret = device_property_match_string(dev, "io-backend-names",
> > +                                                  name);
> 
> One line?

Would pass the 80 limit column. I would not mind at all to have the one liner
but I'm playing by Jonathan's rules. Stick with that limit unless it hurts
readability.

> 
> > +               if (ret < 0)
> > +                       return ERR_PTR(ret);
> > +               index = ret;
> > +       } else {
> > +               index = 0;
> > +       }
> 
> ...
> 
> > +       fwnode = fwnode_find_reference(dev_fwnode(dev), "io-backends",
> > index);
> > +       if (IS_ERR(fwnode)) {
> > +               dev_err(dev, "Cannot get Firmware reference\n");
> > +               return ERR_CAST(fwnode);
> 
> dev_err_probe() ?
> 
> > +       }
> 
> ...
> 
> > +       if (!ops) {
> > +               dev_err(dev, "No backend ops given\n");
> > +               return -EINVAL;
> 
> dev_err_probe() ?

Yeah, I can switch to that as on top of being devm APIs, these APIs are really
intended to be called during probe().

- Nuno Sá

  reply	other threads:[~2024-02-07  9:13 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-06 10:08 [PATCH v9 0/7] iio: add new backend framework Nuno Sa via B4 Relay
2024-02-06 10:08 ` [PATCH v9 1/7] dt-bindings: adc: ad9467: add new io-backend property Nuno Sa via B4 Relay
2024-02-06 10:08 ` [PATCH v9 2/7] dt-bindings: adc: axi-adc: update bindings for backend framework Nuno Sa via B4 Relay
2024-02-06 10:08 ` [PATCH v9 3/7] of: property: add device link support for io-backends Nuno Sa via B4 Relay
2024-02-06 10:08 ` [PATCH v9 4/7] iio: buffer-dmaengine: export buffer alloc and free functions Nuno Sa via B4 Relay
2024-02-06 10:08 ` [PATCH v9 5/7] iio: add the IIO backend framework Nuno Sa via B4 Relay
2024-02-06 14:27   ` Andy Shevchenko
2024-02-07  9:16     ` Nuno Sá [this message]
2024-02-06 10:08 ` [PATCH v9 6/7] iio: adc: ad9467: convert to " Nuno Sa via B4 Relay
2024-02-06 14:20   ` Andy Shevchenko
2024-02-06 14:20     ` Andy Shevchenko
2024-02-06 16:52       ` Nuno Sá
2024-02-06 17:50         ` Andy Shevchenko
2024-02-07 12:08           ` Nuno Sá
2024-02-06 16:51     ` Nuno Sá
2024-02-06 17:51       ` Andy Shevchenko
2024-02-07  9:23         ` Nuno Sá
2024-02-10 16:31           ` Jonathan Cameron
2024-02-06 10:08 ` [PATCH v9 7/7] iio: adc: adi-axi-adc: move " Nuno Sa via B4 Relay

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=5c0985247622215c3eea548879afe68d0dce00ec.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=jic23@kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=olivier.moysan@foss.st.com \
    --cc=robh+dt@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