From: "Nuno Sá" <noname.nuno@gmail.com>
To: "David Lechner" <dlechner@baylibre.com>,
"Angelo Dureghello" <adureghello@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Olivier Moysan" <olivier.moysan@foss.st.com>
Cc: linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH v6 8/8] iio: dac: adi-axi-dac: add registering of child fdt node
Date: Tue, 15 Oct 2024 08:11:46 +0200 [thread overview]
Message-ID: <df1cdac2c954d9a95b9026a400e68697e177787f.camel@gmail.com> (raw)
In-Reply-To: <022be235-f028-4b6e-9589-b0066df5d459@baylibre.com>
On Mon, 2024-10-14 at 16:16 -0500, David Lechner wrote:
> On 10/14/24 5:08 AM, Angelo Dureghello wrote:
> > From: Angelo Dureghello <adureghello@baylibre.com>
> >
> > Change to obtain the fdt use case as reported in the
> > adi,ad3552r.yaml file in this patchset.
> >
> > The DAC device is defined as a child node of the backend.
> > Registering the child fdt node as a platform devices.
> >
> > Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
> > ---
> > drivers/iio/dac/adi-axi-dac.c | 53 +++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 53 insertions(+)
> >
> > diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c
> > index b887c6343f96..f85e3138d428 100644
> > --- a/drivers/iio/dac/adi-axi-dac.c
> > +++ b/drivers/iio/dac/adi-axi-dac.c
> > @@ -29,6 +29,8 @@
> > #include <linux/iio/buffer.h>
> > #include <linux/iio/iio.h>
> >
> > +#include "ad3552r-hs.h"
> > +
> > /*
> > * Register definitions:
> > * https://wiki.analog.com/resources/fpga/docs/axi_dac_ip#register_map
> > @@ -738,6 +740,39 @@ static int axi_dac_bus_reg_read(struct iio_backend *back,
> > u32 reg, u32 *val,
> > return regmap_read(st->regmap, AXI_DAC_CUSTOM_RD_REG, val);
> > }
> >
> > +static void axi_dac_child_remove(void *data)
> > +{
> > + struct platform_device *pdev = data;
> > +
> > + platform_device_unregister(pdev);
Just do platform_device_unregister(data)... Or call the argument pdev for better
readability...
> > +}
> > +
> > +static int axi_dac_create_platform_device(struct axi_dac_state *st,
> > + struct fwnode_handle *child)
> > +{
> > + struct ad3552r_hs_platform_data pdata = {
> > + .bus_reg_read = axi_dac_bus_reg_read,
> > + .bus_reg_write = axi_dac_bus_reg_write,
> > + };
> > + struct platform_device_info pi = {
> > + .parent = st->dev,
> > + .name = fwnode_get_name(child),
> > + .id = PLATFORM_DEVID_AUTO,
> > + .fwnode = child,
> > + .data = &pdata,
> > + .size_data = sizeof(pdata),
> > + };
> > + struct platform_device *pdev;
> > +
> > + pdev = platform_device_register_full(&pi);
> > + if (IS_ERR(pdev))
> > + return PTR_ERR(pdev);
> > +
> > + device_set_node(&pdev->dev, child);
>
> Not sure why Nuno suggested adding device_set_node(). It is
> redundant since platform_device_register_full() already does
> the same thing.
>
Indeed... I realized that yesterday when (actually) looking at
platform_device_register_full(). You just beat me in replying to the email. Sorry for
the noise...
> (And setting it after platform_device_register_full() would
> be too late anyway since drivers may have already probed.)
> > +
> > + return devm_add_action_or_reset(st->dev, axi_dac_child_remove, pdev);
> > +}
> > +
> > static const struct iio_backend_ops axi_dac_generic_ops = {
> > .enable = axi_dac_enable,
> > .disable = axi_dac_disable,
> > @@ -874,6 +909,24 @@ static int axi_dac_probe(struct platform_device *pdev)
> > return dev_err_probe(&pdev->dev, ret,
> > "failed to register iio backend\n");
> >
> > + device_for_each_child_node_scoped(&pdev->dev, child) {
> > + int val;
> > +
I'm starting to come around again if some sort of flag (bus_controller or an explicit
has_child) wouldn't make sense (since you may need to re-spin another version). So we
could error out in case someone comes up with child nodes on a device that does not
support them.
Anyways, I'll leave this up to you and maybe others can also argue about this...
> > + /* Processing only reg 0 node */
> > + ret = fwnode_property_read_u32(child, "reg", &val);
> > + if (ret)
> > + return dev_err_probe(&pdev->dev, ret,
> > + "child node missing.");
>
> Shouldn't the error message say that there is a problem with the reg
> property? We already have a handle to the child node, so the child node
> isn't missing.
Makes sense... like "reg property missing" - something on those lines.
- Nuno Sá
next prev parent reply other threads:[~2024-10-15 6:11 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-14 10:08 [PATCH v6 0/8] iio: add support for the ad3552r AXI DAC IP Angelo Dureghello
2024-10-14 10:08 ` [PATCH v6 1/8] dt-bindings: iio: dac: ad3552r: add iio backend support Angelo Dureghello
2024-10-14 10:08 ` [PATCH v6 2/8] dt-bindings: iio: dac: adi-axi-dac: add ad3552r axi variant Angelo Dureghello
2024-10-14 11:21 ` Rob Herring (Arm)
2024-10-14 13:38 ` Rob Herring
2024-10-14 14:04 ` Angelo Dureghello
2024-10-14 19:20 ` Jonathan Cameron
2024-10-14 19:24 ` Angelo Dureghello
2024-10-14 21:13 ` David Lechner
2024-10-15 7:44 ` Angelo Dureghello
2024-10-15 14:40 ` David Lechner
2024-10-15 14:51 ` Nuno Sá
2024-10-15 18:19 ` Angelo Dureghello
2024-10-14 10:08 ` [PATCH v6 3/8] iio: backend: extend features Angelo Dureghello
2024-10-14 10:08 ` [PATCH v6 4/8] iio: dac: adi-axi-dac: " Angelo Dureghello
2024-10-14 21:14 ` David Lechner
2024-10-15 6:30 ` Nuno Sá
2024-10-15 8:57 ` Angelo Dureghello
2024-10-15 11:10 ` Nuno Sá
2024-10-19 15:08 ` Jonathan Cameron
2024-10-14 10:08 ` [PATCH v6 5/8] iio: dac: ad3552r: changes to use FIELD_PREP Angelo Dureghello
2024-10-14 21:14 ` David Lechner
2024-10-15 6:17 ` Nuno Sá
2024-10-15 10:19 ` Angelo Dureghello
2024-10-14 10:08 ` [PATCH v6 6/8] iio: dac: ad3552r: extract common code (no changes in behavior intended) Angelo Dureghello
2024-10-19 15:15 ` Jonathan Cameron
2024-10-14 10:08 ` [PATCH v6 7/8] iio: dac: ad3552r: add high-speed platform driver Angelo Dureghello
2024-10-14 21:15 ` David Lechner
2024-10-15 6:37 ` Nuno Sá
2024-10-15 14:38 ` David Lechner
2024-10-15 15:00 ` Nuno Sá
2024-10-15 15:23 ` David Lechner
2024-10-16 7:50 ` Nuno Sá
2024-10-19 15:18 ` Jonathan Cameron
2024-10-16 8:35 ` Angelo Dureghello
2024-10-15 7:15 ` Nuno Sá
2024-10-15 14:48 ` David Lechner
2024-10-16 11:54 ` Nuno Sá
2024-10-17 7:27 ` Angelo Dureghello
2024-10-19 15:24 ` Jonathan Cameron
2024-10-14 10:08 ` [PATCH v6 8/8] iio: dac: adi-axi-dac: add registering of child fdt node Angelo Dureghello
2024-10-14 21:16 ` David Lechner
2024-10-15 6:11 ` Nuno Sá [this message]
2024-10-17 8:32 ` Angelo Dureghello
2024-10-17 15:13 ` Nuno Sá
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=df1cdac2c954d9a95b9026a400e68697e177787f.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=adureghello@baylibre.com \
--cc=broonie@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=nuno.sa@analog.com \
--cc=olivier.moysan@foss.st.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;
as well as URLs for NNTP newsgroup(s).