of: implement new of_device_ensure_probed_by_alias_stem
Subsystems (3)
PATCH v2 1/2 of: implement new of_device_ensure_probed_by_alias_stem
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.
User can specify one device_node which won't get probed. This is mainly for avoiding recursion if the function will be called from device probe function, or to specify the device which should get probed last. In the later case the user should probe the last device manually.
---
Changes in v2:
- add check for deep probe support,
- users can now specify one device node, which won't get probed. This ensures that one device can be probed last and we avoid recursion, if
this device happens to have alias,
- fix function name (ensured -> ensure).
--- drivers/of/base.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/of.h | 6 ++++++ 2 files changed, 46 insertions(+)
drivers/of/base.c +40 -0
@@ -274,6 +274,46 @@ 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 +* @np: Device node of a device that should be probed last, NULL if such +* device doesn't exist +* @stem: Alias stem of the given device_node +* +* The function ensures all devices with the given alias stem are probed before the +* target device. +* +* Returns 0 on success or error code. +*/ +int of_device_ensure_probed_by_alias_stem (struct device_node *np,const char *stem) +{ +struct alias_prop *app; +int id = -ENODEV ; +int ret; + +if (!deep_probe_is_supported ()) +return 0 ; + +list_for_each_entry (app, &aliases_lookup, link) { +if (of_node_cmp (app->stem, stem) !=0 ) +continue ; + +/* If device node is given skip the probing of that device so we +* avoid recursion. +*/ +if (np !=NULL && np == app->np) +continue ; + + ret =of_device_ensure_probed (app->np); +if (ret) +return ret; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (of_device_ensure_probed_by_alias_stem); +const char *of_alias_get (struct device_node *np) {struct alias_prop *app;
include/of.h +6 -0
@@ -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_ensure_probed_by_alias_stem (struct device_node *np,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_nreturn -ENOSYS ; } +static int of_device_ensure_probed_by_alias_stem (struct device_node *np,const char *stem) +{ +return -ENOSYS ; +} +static inline const char *of_alias_get (struct device_node *np) {return NULL ;
Signature · 7 lines
2.25.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 2/2 ARM: boards: phytec-som-imx6: probe all gpio devices before PMIC
GPIO lines in da9063 are assigned dynamically, while majority of SOC GPIO drivers assign their GPIOs in static manner (GPIO line numbers can be calculated).
This introduces regression if deep probe support is used. If da9063 GPIOs are registered before the SOCs GPIOs, there is a good chance that the SOCs statically computed GPIO line numbers will already be used by PMIC.
Ensure all SOCs GPIO drivers and GPIO lines get registered before the da9063 registers its own gpiochip.
---
Changes in v2:
- move function from da9062 probe to board file
--- arch/arm/boards/phytec-som-imx6/board.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/boards/phytec-som-imx6/board.c +4 -0
@@ -111,6 +111,10 @@ static int phycore_da9062_setup_buck_mode(void)if (!pmic_np)return -ENODEV ; + ret =of_device_ensure_probed_by_alias_stem (pmic_np,"gpio" ); +if (ret) +return ret; + ret =of_device_ensure_probed (pmic_np);if (ret)return ret;
Signature · 7 lines
2.25.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Andrej,
Quoted 9 lines · Andrej Picej
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.
User can specify one
device_nodewhich won't get probed. This is mainly for avoiding recursion if the function will be called from device probe function, or to specify the device which should get probed last. In the later case the user should probe the last device manually.
Quoted 8 lines
Signed-off-by Andrej Picej <[email protected]>---
Changes in v2:
- add check for deep probe support,
- users can now specify one device node, which won't get probed. This ensures that one device can be probed last and we avoid recursion, if
this device happens to have alias,
- fix function name (ensured -> ensure).
Your v2 came before I had a chance to react to your comments on v1, I was on vacation last week. I looked at the issue from another perspective and rather than ensuring a certain probe order I think we should decouple the GPIO numbers (at least the ones from the SoC internal controllers) from the probe order, see the patch I just sent.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi Sascha,
Quoted 21 lines · Sascha Hauer
Hi Andrej,
Quoted 9 lines · Andrej Picej
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.
User can specify one
device_nodewhich won't get probed. This is mainly for avoiding recursion if the function will be called from device probe function, or to specify the device which should get probed last. In the later case the user should probe the last device manually.Quoted 8 lines
Signed-off-by Andrej Picej <[email protected]>---
Changes in v2:
- add check for deep probe support,
- users can now specify one device node, which won't get probed. This ensures that one device can be probed last and we avoid recursion, if
this device happens to have alias,
- fix function name (ensured -> ensure).
Quoted 5 lines
Your v2 came before I had a chance to react to your comments on v1, I was on vacation last week. I looked at the issue from another perspective and rather than ensuring a certain probe order I think we should decouple the GPIO numbers (at least the ones from the SoC internal controllers) from the probe order, see the patch I just sent.
Sorry didn't mean to push you. Just figured out that it would be easier to talk about this topic when we have v2 version :).
OK, the patch looks good. As you said, solution from different perspective. Will test it out and get back to you with results.
Thanks for your help/work.
Andrej
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox