From: Jonathan Cameron <jic23@kernel.org>
To: Nuno Sa <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>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Conor Dooley <conor+dt@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Frank Rowand <frowand.list@gmail.com>,
Olivier Moysan <olivier.moysan@foss.st.com>
Subject: Re: [PATCH v4 7/8] iio: adc: ad9467: convert to backend framework
Date: Thu, 21 Dec 2023 17:52:09 +0000 [thread overview]
Message-ID: <20231221175209.457664b5@jic23-huawei> (raw)
In-Reply-To: <20231220-iio-backend-v4-7-998e9148b692@analog.com>
On Wed, 20 Dec 2023 16:34:10 +0100
Nuno Sa <nuno.sa@analog.com> wrote:
> Convert the driver to use the new IIO backend framework. The device
> functionality is expected to be the same (meaning no added or removed
> features).
>
> Also note this patch effectively breaks ABI and that's needed so we can
> properly support this device and add needed features making use of the
> new IIO framework.
>
> Signed-off-by: Nuno Sa <nuno.sa@analog.com>
A few minor comments. Looks good to me.
Jonathan
> +static int ad9467_update_scan_mode(struct iio_dev *indio_dev,
> + const unsigned long *scan_mask)
> +{
> + struct ad9467_state *st = iio_priv(indio_dev);
> + unsigned int c;
> + int ret;
> +
> + for (c = 0; c < st->info->num_channels; c++) {
> + if (test_bit(c, scan_mask))
> + ret = iio_backend_chan_enable(st->back, c);
> + else
> + ret = iio_backend_chan_disable(st->back, c);
> +
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
> static int ad9467_reset(struct device *dev)
> @@ -443,25 +475,63 @@ static int ad9467_reset(struct device *dev)
> return 0;
> }
>
> +static int ad9467_iio_backend_get(struct ad9467_state *st)
> +{
> + struct device *dev = &st->spi->dev;
> + struct device_node *__back;
> +
> + st->back = devm_iio_backend_get_optional(&st->spi->dev, NULL);
> + if (IS_ERR(st->back))
> + return PTR_ERR(st->back);
As per the comment on previous patch I'd just get it using the normal
function and handle PTR_ERR(-ENOENT) here as meaning we need to
try the old way.
> + if (st->back)
> + return 0;
> + /*
> + * if we don't get the backend using the normal API's, use the legacy
> + * 'adi,adc-dev' property. So we get all nodes with that property, and
> + * look for the one pointing at us. Then we directly lookup that fwnode
> + * on the backend list of registered devices. This is done so we don't
> + * make io-backends mandatory which would break DT ABI.
> + */
> + for_each_node_with_property(__back, "adi,adc-dev") {
> + struct device_node *__me;
> +
> + __me = of_parse_phandle(__back, "adi,adc-dev", 0);
> + if (!__me)
> + continue;
> +
> + if (!device_match_of_node(dev, __me)) {
> + of_node_put(__me);
> + continue;
> + }
> +
> + of_node_put(__me);
> + st->back = devm_iio_backend_get_from_fwnode_lookup(dev,
> + of_fwnode_handle(__back));
> + of_node_put(__back);
If it lands first the patch
RFC PATCH 1/4] of: Add cleanup.h based autorelease via __free(device_node) markings.
will get rid of this manual handling for you for both the continue and return.
This will make a very nice example for that :)
> + return PTR_ERR_OR_ZERO(st->back);
> + }
> +
> + return -ENODEV;
> +}
next prev parent reply other threads:[~2023-12-21 17:52 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-20 15:34 [PATCH v4 0/8] iio: add new backend framework Nuno Sa
2023-12-20 15:34 ` [PATCH v4 1/8] dt-bindings: adc: ad9467: add new io-backend property Nuno Sa
2023-12-20 16:56 ` Rob Herring
2023-12-21 17:21 ` Jonathan Cameron
2023-12-21 22:46 ` Rob Herring
2023-12-20 15:34 ` [PATCH v4 2/8] dt-bindings: adc: axi-adc: deprecate 'adi,adc-dev' Nuno Sa
2023-12-21 17:25 ` Jonathan Cameron
2023-12-22 9:07 ` Nuno Sá
2023-12-26 15:55 ` Jonathan Cameron
2023-12-20 15:34 ` [PATCH v4 3/8] driver: core: allow modifying device_links flags Nuno Sa
2023-12-20 15:34 ` [PATCH v4 4/8] of: property: add device link support for io-backends Nuno Sa
2023-12-21 22:47 ` Rob Herring
2024-01-03 21:39 ` David Lechner
2024-01-09 11:23 ` Nuno Sá
2023-12-20 15:34 ` [PATCH v4 5/8] iio: buffer-dmaengine: export buffer alloc and free functions Nuno Sa
2023-12-20 15:34 ` [PATCH v4 6/8] iio: add the IIO backend framework Nuno Sa
2023-12-21 17:44 ` Jonathan Cameron
2023-12-22 9:39 ` Nuno Sá
2023-12-26 15:59 ` Jonathan Cameron
2024-01-09 12:15 ` Nuno Sá
2024-01-10 9:16 ` Jonathan Cameron
2024-01-10 10:37 ` Nuno Sá
2024-01-11 15:07 ` Olivier MOYSAN
2023-12-20 15:34 ` [PATCH v4 7/8] iio: adc: ad9467: convert to " Nuno Sa
2023-12-21 17:52 ` Jonathan Cameron [this message]
2023-12-22 9:10 ` Nuno Sá
2023-12-20 15:34 ` [PATCH v4 8/8] iio: adc: adi-axi-adc: move " Nuno Sa
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=20231221175209.457664b5@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=gregkh@linuxfoundation.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=rafael@kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).