From: Lizhi Hou <lizhi.hou@xilinx.com>
To: Xu Yilun <yilun.xu@intel.com>, Lizhi Hou <lizhi.hou@xilinx.com>
Cc: <devicetree@vger.kernel.org>, <robh@kernel.org>,
<linux-kernel@vger.kernel.org>, <maxz@xilinx.com>,
<sonal.santan@xilinx.com>, <yliu@xilinx.com>,
<michal.simek@xilinx.com>, <stefanos@xilinx.com>,
<trix@redhat.com>, <mdf@kernel.org>, <dwmw2@infradead.org>,
Max Zhen <max.zhen@xilinx.com>
Subject: Re: [PATCH V1 Create empty OF root 1/1] of: create empty of root
Date: Fri, 11 Feb 2022 17:02:56 -0800 [thread overview]
Message-ID: <14bd131d-c978-e669-df55-45b58ff3bf6e@xilinx.com> (raw)
In-Reply-To: <20220211153801.GA1273192@yilunxu-OptiPlex-7050>
Hi Yilun,
Thanks a lot for your feedback. I will revise the comments and send
another patch.
In the meanwhile, based on our previous discussion,
https://lore.kernel.org/lkml/20220111070000.GC979169@yilunxu-OptiPlex-7050/
I will propose another patch to add an of_pci interface which can be
called by pci driver probe routine to create device node for it.
Thanks,
Lizhi
On 2/11/22 7:38 AM, Xu Yilun wrote:
> On Tue, Jan 25, 2022 at 09:48:07PM -0800, Lizhi Hou wrote:
>> Add OF_EMPTY_ROOT config. When it is selected and there is not a device
>> tree, create an empty device tree root node.
> Maybe add some description about why a empty device tree root node is
> needed. Note that the Patch #0 will not be present in the repo when the
> series will be merged, so add your description here please.
>
>> Signed-off-by: Sonal Santan <sonal.santan@xilinx.com>
>> Signed-off-by: Max Zhen <max.zhen@xilinx.com>
>> Signed-off-by: Lizhi Hou <lizhi.hou@xilinx.com>
>> ---
>> drivers/of/Kconfig | 3 +++
>> drivers/of/Makefile | 1 +
>> drivers/of/of_empty_root.c | 51 ++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 55 insertions(+)
>> create mode 100644 drivers/of/of_empty_root.c
>>
>> diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
>> index 80b5fd44ab1c..42afb126f91a 100644
>> --- a/drivers/of/Kconfig
>> +++ b/drivers/of/Kconfig
>> @@ -94,4 +94,7 @@ config OF_DMA_DEFAULT_COHERENT
>> # arches should select this if DMA is coherent by default for OF devices
>> bool
>>
>> +config OF_EMPTY_ROOT
>> + bool
> Also some descriptions for better understanding?
>
> Thanks,
> Yilun
>
>> +
>> endif # OF
>> diff --git a/drivers/of/Makefile b/drivers/of/Makefile
>> index e0360a44306e..c65364f32935 100644
>> --- a/drivers/of/Makefile
>> +++ b/drivers/of/Makefile
>> @@ -12,6 +12,7 @@ obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o
>> obj-$(CONFIG_OF_RESOLVE) += resolver.o
>> obj-$(CONFIG_OF_OVERLAY) += overlay.o
>> obj-$(CONFIG_OF_NUMA) += of_numa.o
>> +obj-$(CONFIG_OF_EMPTY_ROOT) += of_empty_root.o
>>
>> ifdef CONFIG_KEXEC_FILE
>> ifdef CONFIG_OF_FLATTREE
>> diff --git a/drivers/of/of_empty_root.c b/drivers/of/of_empty_root.c
>> new file mode 100644
>> index 000000000000..5c429c7a27bd
>> --- /dev/null
>> +++ b/drivers/of/of_empty_root.c
>> @@ -0,0 +1,51 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Copyright (C) 2022 Xilinx, Inc.
>> + */
>> +
>> +#include <linux/of.h>
>> +#include <linux/slab.h>
>> +
>> +#include "of_private.h"
>> +
>> +static int __init of_root_init(void)
>> +{
>> + struct property *prop = NULL;
>> + struct device_node *node;
>> + __be32 *val = NULL;
>> +
>> + if (of_root)
>> + return 0;
>> +
>> + pr_info("Create empty OF root node\n");
>> + node = kzalloc(sizeof(*node), GFP_KERNEL);
>> + if (!node)
>> + return -ENOMEM;
>> + of_node_init(node);
>> + node->full_name = "/";
>> +
>> + prop = kcalloc(2, sizeof(*prop), GFP_KERNEL);
>> + if (!prop)
>> + return -ENOMEM;
>> +
>> + val = kzalloc(sizeof(*val), GFP_KERNEL);
>> + if (!val)
>> + return -ENOMEM;
>> + *val = cpu_to_be32(sizeof(void *) / sizeof(u32));
>> +
>> + prop->name = "#address-cells";
>> + prop->value = val;
>> + prop->length = sizeof(u32);
>> + of_add_property(node, prop);
>> + prop++;
>> + prop->name = "#size-cells";
>> + prop->value = val;
>> + prop->length = sizeof(u32);
>> + of_add_property(node, prop);
>> + of_root = node;
>> + for_each_of_allnodes(node)
>> + __of_attach_node_sysfs(node);
>> +
>> + return 0;
>> +}
>> +pure_initcall(of_root_init);
>> --
>> 2.27.0
>
next prev parent reply other threads:[~2022-02-12 1:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-26 5:48 [PATCH V1 Create empty OF root 0/1] XRT Alveo driver infrastructure overview Lizhi Hou
2022-01-26 5:48 ` [PATCH V1 Create empty OF root 1/1] of: create empty of root Lizhi Hou
2022-02-11 15:38 ` Xu Yilun
2022-02-12 1:02 ` Lizhi Hou [this message]
2022-02-01 0:49 ` [PATCH V1 Create empty OF root 0/1] XRT Alveo driver infrastructure overview Lizhi Hou
2022-02-07 21:31 ` Sonal Santan
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=14bd131d-c978-e669-df55-45b58ff3bf6e@xilinx.com \
--to=lizhi.hou@xilinx.com \
--cc=devicetree@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=max.zhen@xilinx.com \
--cc=maxz@xilinx.com \
--cc=mdf@kernel.org \
--cc=michal.simek@xilinx.com \
--cc=robh@kernel.org \
--cc=sonal.santan@xilinx.com \
--cc=stefanos@xilinx.com \
--cc=trix@redhat.com \
--cc=yilun.xu@intel.com \
--cc=yliu@xilinx.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 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).