Commit 7880c57b authored by Mika Westerberg's avatar Mika Westerberg Committed by Tim Gardner

driver core: Do not overwrite secondary fwnode with NULL if it is set

BugLink: http://bugs.launchpad.net/bugs/1533035

If multiple devices share single firmware node like it is case with MFD
devices, the same firmware node (ACPI) is assigned to all of them. The
function also modifies the shared firmware node in order to preserve
secondary firmware node of the device in question.

If the new device which is sharing the firmware node does not have
secondary node it will be NULL which will be assigned to the secondary node
of the shared firmware node losing all built-in properties.

Prevent this by setting the secondary firmware node only if the replacement
is non-NULL.

Print also warning if someone tries to overwrite secondary node that has
already been assigned.
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
(cherry picked from commit 55f89a8a)
Signed-off-by: default avatarTim Gardner <tim.gardner@canonical.com>
parent 010fdc76
...@@ -2261,7 +2261,10 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode) ...@@ -2261,7 +2261,10 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
if (fwnode_is_primary(fn)) if (fwnode_is_primary(fn))
fn = fn->secondary; fn = fn->secondary;
fwnode->secondary = fn; if (fn) {
WARN_ON(fwnode->secondary);
fwnode->secondary = fn;
}
dev->fwnode = fwnode; dev->fwnode = fwnode;
} else { } else {
dev->fwnode = fwnode_is_primary(dev->fwnode) ? dev->fwnode = fwnode_is_primary(dev->fwnode) ?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment