[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7bd162bb-dce8-4aff-9f56-1ab73b091a28@baylibre.com>
Date: Thu, 5 Sep 2024 14:19:19 -0500
From: David Lechner <dlechner@...libre.com>
To: Angelo Dureghello <adureghello@...libre.com>,
Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>,
Nuno Sá <nuno.sa@...log.com>,
Jonathan Cameron <jic23@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley
<conor+dt@...nel.org>, Olivier Moysan <olivier.moysan@...s.st.com>
Cc: linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 4/9] iio: backend adi-axi-dac: add registering of child
fdt node
On 9/5/24 10:17 AM, Angelo Dureghello wrote:
> From: Angelo Dureghello <adureghello@...libre.com>
>
> Change to obtain the fdt use case as reported in the
> adi,ad3552r.yaml file in this patchset, with the DAC device that
> is actually using the backend set as a child node of the backend.
>
> To obtain this, registering all the child fdt nodes as platform
> devices.
>
> Signed-off-by: Angelo Dureghello <adureghello@...libre.com>
> Co-developed-by: David Lechner <dlechner@...libre.com>
> Co-developed-by: Nuno Sá <nuno.sa@...log.com>
> ---
> drivers/iio/dac/adi-axi-dac.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/drivers/iio/dac/adi-axi-dac.c b/drivers/iio/dac/adi-axi-dac.c
> index cc31e1dcd1df..e883cd557b6a 100644
> --- a/drivers/iio/dac/adi-axi-dac.c
> +++ b/drivers/iio/dac/adi-axi-dac.c
> @@ -783,6 +783,7 @@ static int axi_dac_probe(struct platform_device *pdev)
> {
> struct axi_dac_state *st;
> const struct axi_dac_info *info;
> + struct platform_device *child_pdev;
> void __iomem *base;
> unsigned int ver;
> struct clk *clk;
> @@ -862,6 +863,20 @@ 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) {
This should use fwnode_for_each_available_child_node() so that it skips
nodes with status != "okay".
Would be nice to introduce a scoped version of this function too.
Also, if we are allowing multiple devices on the bus, the DT bindings
need to have a reg property that is unique for each child.
> + struct platform_device_info pi;
> +
> + memset(&pi, 0, sizeof(pi));
struct platform_device_info pi = { };
avoids the need for memset().
> +
> + pi.name = fwnode_get_name(child);
> + pi.id = PLATFORM_DEVID_AUTO;
> + pi.fwnode = child;
Need to have pi.parent = &pdev->dev;
It could also make sense to have all of the primary bus functions
(reg read/write, ddr enable/disable, etc.) passed here as platform
data instead of having everything go through the IIO backend.
> +
> + child_pdev = platform_device_register_full(&pi);
> + if (IS_ERR(child_pdev))
> + return PTR_ERR(child_pdev);
These devices need to be unregistered on any error return and when
the parent device is removed.
> + }
> +
> dev_info(&pdev->dev, "AXI DAC IP core (%d.%.2d.%c) probed\n",
> ADI_AXI_PCORE_VER_MAJOR(ver),
> ADI_AXI_PCORE_VER_MINOR(ver),
>
Powered by blists - more mailing lists