driver core: Keep the supplier fwnode consistent with the device
Subsystems (2)
PATCH 1/1 driver core: Keep the supplier fwnode consistent with the device
The commit 3a2dbc510c43 ("driver core: fw_devlink: Don't purge child fwnode's consumer links") introduces the possibility to use the supplier's parent device instead of the supplier itself. In that case the supplier fwnode used is not updated and is no more consistent with the supplier device used.
Update the fwnode used to be consistent with the supplier device used.
--- drivers/base/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/base/core.c +12 -0
@@ -2076,6 +2076,18 @@ static int fw_devlink_create_devlink(struct device *con, sup_dev =get_dev_from_fwnode (sup_handle);if (sup_dev) { +/* +* The supplier device may have changed and so, the supplier +* fwnode maybe inconsistent. +* Update the supplier fwnode +*/ + sup_handle = sup_dev->fwnode; +if (!sup_handle) { +dev_dbg (con,"Not linking %s - fwnode NULL\n" , +dev_name (sup_dev)); + goto out; + } +/* * If it's one of those drivers that don't actually bind to * their device using driver core, then don't wait on this
Signature · 1 line
2.41.0
Quoted 26 lines · Herve Codina
The commit
3a2dbc510c43("driver core:fw_devlink: Don't purge child fwnode's consumer links") introduces the possibility to use the supplier's parent device instead of the supplier itself. In that case the supplier fwnode used is not updated and is no more consistent with the supplier device used.Update the fwnode used to be consistent with the supplier device used.
Fixes 3a2dbc510c43 ("driver core: fw_devlink: Don't purge child fwnode's consumer links")Signed-off-by Herve Codina <[email protected]>--- drivers/base/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/base/core.c +2
-0@@ -2076,6 +2076,18 @@ static int fw_devlink_create_devlink(struct device *con, sup_dev =get_dev_from_fwnode (sup_handle);if (sup_dev) { +/* +* The supplier device may have changed and so, the supplier
drivers/base/core.c static int fw_devlink_create_devlink(struct device *con, · line 2090
Quoted 10 lines
drivers/base/core.c +10
-0+* fwnode maybe inconsistent. +* Update the supplier fwnode +*/ + sup_handle = sup_dev->fwnode; +if (!sup_handle) { +dev_dbg (con,"Not linking %s - fwnode NULL\n" , +dev_name (sup_dev)); + goto out; + } +
Nack. It's easier to debug when you know what supplier you were pointing to in DT that triggered the creation of the device link. The parent could be several levels up and multiple supplier links might be skipped for various reasons. If they all printed the parent's fwnode, it'll be confusing to debug.
-Saravana
Quoted 6 lines
drivers/base/core.c +0
-1/* * If it's one of those drivers that don't actually bind to * their device using driver core, then don't wait on this -- 2.41.0
Hi Saravana,
Quoted 35 lines · On Fri, 10 Nov 2023 17:50:07 -0800 Saravana Kannan <[email protected]> wrote:
Quoted 34 lines · Herve Codina
The commit
3a2dbc510c43("driver core:fw_devlink: Don't purge child fwnode's consumer links") introduces the possibility to use the supplier's parent device instead of the supplier itself. In that case the supplier fwnode used is not updated and is no more consistent with the supplier device used.Update the fwnode used to be consistent with the supplier device used.
Fixes 3a2dbc510c43 ("driver core: fw_devlink: Don't purge child fwnode's consumer links")Signed-off-by Herve Codina <[email protected]>--- drivers/base/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)drivers/base/core.c +10
-0@@ -2076,6 +2076,18 @@ static int fw_devlink_create_devlink(struct device *con, sup_dev =get_dev_from_fwnode (sup_handle);if (sup_dev) { +/* +* The supplier device may have changed and so, the supplier +* fwnode maybe inconsistent. +* Update the supplier fwnode +*/ + sup_handle = sup_dev->fwnode; +if (!sup_handle) { +dev_dbg (con,"Not linking %s - fwnode NULL\n" , +dev_name (sup_dev)); + goto out;
Quoted 8 lines
drivers/base/core.c static int fw_devlink_create_devlink(struct device *con, · line 2090
Quoted 2 lines
drivers/base/core.c +2
-0+ } +Nack. It's easier to debug when you know what supplier you were pointing to in DT that triggered the creation of the device link. The parent could be several levels up and multiple supplier links might be skipped for various reasons. If they all printed the parent's fwnode, it'll be confusing to debug.
In fact, I will remove the check if(!sup_handle) in the next iteration.
Indeed, sup_handle cannot be NULL.sup_dev is retrieved from fwnode_get_next_parent_dev() or get_dev_from_fwnode(). In both cases, if sup_dev is valid, sup_dev->fwnode is valid too. So, the check and the dev_dbg() call make no sense.
Best regards,
Hervé