Skip to contentSkip to conversation

driver core: Add a comment to set_primary_fwnode() on nullifying

PATCH New Andy Shevchenko 1 participant 1 message Mar 23, 2023 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver core: Add a comment to set_primary_fwnode() on nullifying

Explain what parent && fn == parent->fwnode conditional does. With this refactor the code a bit.

---
 drivers/base/core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/base/core.c +6 -2
index f1889b9cab45..b59692a4d809 100644
@@ -4982,9 +4982,13 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
 	} else {
 		if (fwnode_is_primary(fn)) {
 			dev->fwnode = fn->secondary;
+
+			/* Skip nullifying fn->secondary if the primary is shared */
+			if (parent && fn == parent->fwnode)
+				return;
+
 			/* Set fn->secondary = NULL, so fn remains the primary fwnode */
-			if (!(parent && fn == parent->fwnode))
-				fn->secondary = NULL;
+			fn->secondary = NULL;
 		} else {
 			dev->fwnode = NULL;
 		}
Signature · 1 line
2.40.0.1.gaa8946217a0b