From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10E5EC3DA7A for ; Mon, 2 Jan 2023 13:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231787AbjABNsm (ORCPT ); Mon, 2 Jan 2023 08:48:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjABNsm (ORCPT ); Mon, 2 Jan 2023 08:48:42 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0102F22B; Mon, 2 Jan 2023 05:48:39 -0800 (PST) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id DA6DC1C0007; Mon, 2 Jan 2023 13:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1672667318; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YaEMzuEbjh8o3s0M+7BOHx2OufQjrgiQxu3MTpmKmQo=; b=RYs8skZNSlrU0FeRUO2gfvSNjHAP1FKd0rcS3xEMmUqbfhhmN4+dcGALJyr8W2YJ17fDH8 smWMRwKBoDZfIwRHZtZYQ6PzMd7w0tZx1I0xUQqYfAXBs8FK9oVVoErMierSJsTIYmCYAa 0l1ZI0N61K9/XlTVwJtFNpLHAN0WdsuqMHJ2+DS0TGE1ZFezoTyfsXUkJjIZo6uTqpFk9N Dz73esiK3SA2gz//uYqPqJ0b4/LPinDAzNRpvBjUbjU8wzIOaf5z9ZFzlPlo+SeRxhgMO8 vI+QpsMHUybHq2sQJr6VXvq/yyzvyoZ8WDTffmiK3bu9K7fy3rm+Hgu+/AA9dA== Date: Mon, 2 Jan 2023 14:50:46 +0100 From: =?UTF-8?B?Q2zDqW1lbnQgTMOpZ2Vy?= To: Lizhi Hou Cc: , , , , , , , , , , , , "Allan.Nielsen@microchip.com" , "Horatiu.Vultur@microchip.com" , "Steen.Hegelund@microchip.com" Subject: Re: [PATCH V5 1/3] of: dynamic: Add interfaces for creating device node dynamically Message-ID: <20230102145046.3e1d009e@fixe.home> In-Reply-To: <1671125446-57584-2-git-send-email-lizhi.hou@amd.com> References: <1671125446-57584-1-git-send-email-lizhi.hou@amd.com> <1671125446-57584-2-git-send-email-lizhi.hou@amd.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.35; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Le Thu, 15 Dec 2022 09:30:44 -0800, Lizhi Hou a =C3=A9crit : > 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. >=20 > 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. >=20 > 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() >=20 > Signed-off-by: Lizhi Hou > Signed-off-by: Sonal Santan > Signed-off-by: Max Zhen > Reviewed-by: Brian Xu > --- > drivers/of/dynamic.c | 197 +++++++++++++++++++++++++++++++++++++++++++ > include/linux/of.h | 24 ++++++ > 2 files changed, 221 insertions(+) >=20 > 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 devic= e_node *np, > return NULL; > } > =20 > +/** > + * 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 erro= r. > + */ > +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 =3D __of_node_dup(NULL, full_name); > + if (!np) > + return NULL; > + np->parent =3D parent; > + > + if (!cset) > + return np; > + > + ocs =3D 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. --=20 Cl=C3=A9ment L=C3=A9ger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com