From: "Clément Léger" <clement.leger@bootlin.com>
To: Lizhi Hou <lizhi.hou@amd.com>
Cc: <linux-pci@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <robh@kernel.org>,
<frowand.list@gmail.com>, <helgaas@kernel.org>,
<max.zhen@amd.com>, <sonal.santan@amd.com>, <larry.liu@amd.com>,
<brian.xu@amd.com>, <stefano.stabellini@xilinx.com>,
<trix@redhat.com>,
"Allan.Nielsen@microchip.com" <Allan.Nielsen@microchip.com>,
"Horatiu.Vultur@microchip.com" <Horatiu.Vultur@microchip.com>,
"Steen.Hegelund@microchip.com" <Steen.Hegelund@microchip.com>
Subject: Re: [PATCH V5 1/3] of: dynamic: Add interfaces for creating device node dynamically
Date: Mon, 2 Jan 2023 14:50:46 +0100 [thread overview]
Message-ID: <20230102145046.3e1d009e@fixe.home> (raw)
In-Reply-To: <1671125446-57584-2-git-send-email-lizhi.hou@amd.com>
Le Thu, 15 Dec 2022 09:30:44 -0800,
Lizhi Hou <lizhi.hou@amd.com> a écrit :
> of_create_node() creates device node dynamically. The parent device node
> and full name are required for creating the node. It optionally creates
> an OF changeset and attaches the newly created node to the changeset. The
> device node pointer and the changeset pointer can be used to add
> properties to the device node and apply the node to the base tree.
>
> of_destroy_node() frees the device node created by of_create_node(). If
> an OF changeset was also created for this node, it will destroy the
> changeset before freeing the device node.
>
> Expand of_changeset APIs to handle specific types of properties.
> of_changeset_add_prop_string()
> of_changeset_add_prop_string_array()
> of_changeset_add_prop_u32_array()
>
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
> Signed-off-by: Sonal Santan <sonal.santan@amd.com>
> Signed-off-by: Max Zhen <max.zhen@amd.com>
> Reviewed-by: Brian Xu <brian.xu@amd.com>
> ---
> drivers/of/dynamic.c | 197 +++++++++++++++++++++++++++++++++++++++++++
> include/linux/of.h | 24 ++++++
> 2 files changed, 221 insertions(+)
>
> diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
> index cd3821a6444f..067d996a9f79 100644
> --- a/drivers/of/dynamic.c
> +++ b/drivers/of/dynamic.c
> @@ -461,6 +461,71 @@ struct device_node *__of_node_dup(const struct device_node *np,
> return NULL;
> }
>
> +/**
> + * of_create_node - Dynamically create a device node
> + *
> + * @parent: Pointer to parent device node
> + * @full_name: Node full name
> + * @cset: Pointer to returning changeset
> + *
> + * Return: Pointer to the created device node or NULL in case of an error.
> + */
> +struct device_node *of_create_node(struct device_node *parent,
> + const char *full_name,
> + struct of_changeset **cset)
> +{
> + struct of_changeset *ocs;
> + struct device_node *np;
> + int ret;
> +
> + np = __of_node_dup(NULL, full_name);
> + if (!np)
> + return NULL;
> + np->parent = parent;
> +
> + if (!cset)
> + return np;
> +
> + ocs = kmalloc(sizeof(*cset), GFP_KERNEL);
I started to test this series and this sizeof(*cset) is probably wrong,
it should be sizeof(*ocs) or it will yield the size of a struct
of_changeset pointer and not the struct of_changeset itself.
--
Clément Léger,
Embedded Linux and Kernel engineer at Bootlin
https://bootlin.com
next prev parent reply other threads:[~2023-01-02 13:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-15 17:30 [PATCH V5 0/3] Generate device tree node for pci devices Lizhi Hou
2022-12-15 17:30 ` [PATCH V5 1/3] of: dynamic: Add interfaces for creating device node dynamically Lizhi Hou
2023-01-02 13:50 ` Clément Léger [this message]
2023-01-03 18:34 ` Lizhi Hou
2022-12-15 17:30 ` [PATCH V5 2/3] PCI: Create device tree node for selected devices Lizhi Hou
2023-01-02 13:56 ` Clément Léger
2023-01-03 18:44 ` Lizhi Hou
2023-01-03 19:34 ` clement.leger
2023-01-02 17:16 ` Clément Léger
2023-01-03 19:45 ` Lizhi Hou
2023-01-04 0:29 ` Lizhi Hou
2023-01-03 14:48 ` Clément Léger
2023-01-04 0:31 ` Lizhi Hou
2023-01-04 5:57 ` clement.leger
2023-01-03 15:38 ` Clément Léger
2022-12-15 17:30 ` [PATCH V5 3/3] PCI: Add PCI quirks to generate device tree node for Xilinx Alveo U50 Lizhi Hou
-- strict thread matches above, loose matches on Subject: below --
2022-12-09 19:38 [PATCH V5 0/3] Generate device tree node for pci devices Lizhi Hou
2022-12-09 19:38 ` [PATCH V5 1/3] of: dynamic: Add interfaces for creating device node dynamically Lizhi Hou
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=20230102145046.3e1d009e@fixe.home \
--to=clement.leger@bootlin.com \
--cc=Allan.Nielsen@microchip.com \
--cc=Horatiu.Vultur@microchip.com \
--cc=Steen.Hegelund@microchip.com \
--cc=brian.xu@amd.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=helgaas@kernel.org \
--cc=larry.liu@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lizhi.hou@amd.com \
--cc=max.zhen@amd.com \
--cc=robh@kernel.org \
--cc=sonal.santan@amd.com \
--cc=stefano.stabellini@xilinx.com \
--cc=trix@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.