Merge tag 'devprop-5.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 8 Jan 2021 23:45:47 +0000 (15:45 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 8 Jan 2021 23:45:47 +0000 (15:45 -0800)
Pull device properties framework fixes from Rafael Wysocki:
 "Revert a problematic commit that went in during the 5.10 cycle and
  improve the kerneldoc description of the function affected by it (both
  changes from Bard Liao)"

* tag 'devprop-5.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  device property: add description of fwnode cases
  Revert "device property: Keep secondary firmware node secondary by type"

drivers/base/core.c

index 25e08e5..14f1658 100644 (file)
@@ -4414,6 +4414,12 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
  *
  * Set the device's firmware node pointer to @fwnode, but if a secondary
  * firmware node of the device is present, preserve it.
+ *
+ * Valid fwnode cases are:
+ *  - primary --> secondary --> -ENODEV
+ *  - primary --> NULL
+ *  - secondary --> -ENODEV
+ *  - NULL
  */
 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
 {
@@ -4432,8 +4438,9 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
        } else {
                if (fwnode_is_primary(fn)) {
                        dev->fwnode = fn->secondary;
+                       /* Set fn->secondary = NULL, so fn remains the primary fwnode */
                        if (!(parent && fn == parent->fwnode))
-                               fn->secondary = ERR_PTR(-ENODEV);
+                               fn->secondary = NULL;
                } else {
                        dev->fwnode = NULL;
                }