[Skiboot] [PATCH V4 1/3] core/device: Add function to return child node using name at substring "@"
Reza Arbab
arbab at linux.ibm.com
Thu Mar 23 07:12:59 AEDT 2023
Hi Athira,
On Mon, Mar 06, 2023 at 09:09:11AM +0530, Athira Rajeev wrote:
>Add a function dt_find_by_name_substr() that returns the child node if
>it matches till first occurence at "@" of a given name, otherwise NULL.
Given this summary, I don't understand the following:
>+ assert(dt_find_by_name_substr(root, "node at 1") == addr1);
>+ assert(dt_find_by_name_substr(root, "node0_1 at 2") == addr2);
Is this behavior required? I don't think it makes sense to call this
function with a second argument containing '@', so I wouldn't expect it
to match anything in these cases. The function seems to specifically
enable it:
>+struct dt_node *dt_find_by_name_substr(struct dt_node *root, const char *name)
>+{
[snip]
>+ node = strdup(name);
>+ if (!node)
>+ return NULL;
>+ node = strtok(node, "@");
Seems like you could get rid of this and just use name as-is.
I was curious about something else; say we have 'node at 1' and 'node at 2'.
Is there an expectation of which it should match?
addr1 = dt_new_addr(root, "node", 0x1);
addr2 = dt_new_addr(root, "node", 0x2);
assert(dt_find_by_name_substr(root, "node") == ???????);
^^^^^^^
>+/* Find a child node by name and substring */
>+struct dt_node *dt_find_by_name_substr(struct dt_node *root, const char *name);
I think this name fit better in previous versions of the patch, but
since you're specifically looking for '@' now, maybe call it something
like dt_find_by_name_before_addr?
--
Reza Arbab
More information about the Linuxppc-dev
mailing list