From: Andrej Picej <andrej.picej@norik.com>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] of: implement new of_device_ensured_probed_by_alias_stem
Date: Wed, 16 Mar 2022 11:01:17 +0100 [thread overview]
Message-ID: <1aaf583d-4bba-3391-7091-795b598a167f@norik.com> (raw)
In-Reply-To: <3219049b-d6eb-68a3-20c6-c62d735bcda9@pengutronix.de>
On 15. 03. 22 15:29, Ahmad Fatoum wrote:
> On 15.03.22 15:16, Ahmad Fatoum wrote:
>> Hello Andrej,
>>
>> On 15.03.22 14:39, Andrej Picej wrote:
>>> Function first goes through all the aliases which have the given stem.
>>> It then ensures that all the devices hiding under these aliases are
>>> probed.
>>>
>>> Signed-off-by: Andrej Picej <andrej.picej@norik.com>
>>> ---
>>> drivers/of/base.c | 28 ++++++++++++++++++++++++++++
>>> include/of.h | 6 ++++++
>>> 2 files changed, 34 insertions(+)
>>>
>>> diff --git a/drivers/of/base.c b/drivers/of/base.c
>>> index 80465d6d50..055dba97ab 100644
>>> --- a/drivers/of/base.c
>>> +++ b/drivers/of/base.c
>>> @@ -274,6 +274,34 @@ int of_alias_get_id_from(struct device_node *root, struct device_node *np,
>>> }
>>> EXPORT_SYMBOL_GPL(of_alias_get_id_from);
>>>
>>> +/**
>>> + * of_device_ensured_probed_by_alias_stem - Ensure all devices with alias base name
>>> + * are probed
>>> + * @stem: Alias stem of the given device_node
>>> + *
>>> + * The function ensures all devices with the given alias stem are probed.
>>> + *
>>> + * Returns 0 on success or error code.
>>> + */
>>> +int of_device_ensured_probed_by_alias_stem(const char *stem)
>>> +{
>>> + struct alias_prop *app;
>>> + int id = -ENODEV;
>>> + int ret;
>>
>> Can you early exit here if (!deep_probe_is_supported())?
>>
>> This saves non-deep probe users the hassle of needless iteration
>> and string comparisons.
>>
>>> +
>>> + list_for_each_entry(app, &aliases_lookup, link) {
>
> Corner case: aliases in DT are not sorted, so
>
> &{/aliases} { gpio1 = &pmic_gpio; gpio0 = &gpio1; };
>
> may result in pmic_gpio being probed first..
True
>
> Could be resolved by sorting aliases on insertion though. hmm..
Ok I will check things up and send a v2.
Thanks for review.
>
>>> + if (of_node_cmp(app->stem, stem) != 0)
>>> + continue;
>>> +
>>> + ret = of_device_ensure_probed(app->np);
>>> + if (ret)
>>> + return ret;
>>> + }
>>> +
>>> + return 0;
>>> +}
>>> +EXPORT_SYMBOL_GPL(of_device_ensured_probed_by_alias_stem);
>>> +
>>> const char *of_alias_get(struct device_node *np)
>>> {
>>> struct alias_prop *app;
>>> diff --git a/include/of.h b/include/of.h
>>> index 216d0ee763..95817c58a4 100644
>>> --- a/include/of.h
>>> +++ b/include/of.h
>>> @@ -261,6 +261,7 @@ extern void of_alias_scan(void);
>>> extern int of_alias_get_id(struct device_node *np, const char *stem);
>>> extern int of_alias_get_id_from(struct device_node *root, struct device_node *np,
>>> const char *stem);
>>> +extern int of_device_ensured_probed_by_alias_stem(const char *stem);
>>> extern const char *of_alias_get(struct device_node *np);
>>> extern int of_modalias_node(struct device_node *node, char *modalias, int len);
>>>
>>> @@ -750,6 +751,11 @@ static inline int of_alias_get_id_from(struct device_node *root, struct device_n
>>> return -ENOSYS;
>>> }
>>>
>>> +static int of_device_ensured_probed_by_aliases(const char *stem)
>>> +{
>>> + return -ENOSYS;
>>> +}
>>> +
>>> static inline const char *of_alias_get(struct device_node *np)
>>> {
>>> return NULL;
>>
>>
>
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2022-03-16 10:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-15 13:39 Andrej Picej
2022-03-15 13:39 ` [PATCH 2/2] mfd: da9063: ensure all gpio devices are probed before Andrej Picej
2022-03-15 14:24 ` Ahmad Fatoum
2022-03-16 10:44 ` Sascha Hauer
2022-03-21 9:46 ` Andrej Picej
2022-03-15 14:16 ` [PATCH 1/2] of: implement new of_device_ensured_probed_by_alias_stem Ahmad Fatoum
2022-03-15 14:29 ` Ahmad Fatoum
2022-03-16 10:01 ` Andrej Picej [this message]
2022-03-16 7:29 ` Andrej Picej
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=1aaf583d-4bba-3391-7091-795b598a167f@norik.com \
--to=andrej.picej@norik.com \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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