Skip to contentSkip to conversation

devres: Improve grp->id setting logics in devres_open_group()

PATCH New Liu Ying 1 participant 1 message Oct 30, 2014 Driver core

lore
Share & tools
lore

Liu Ying

author
#0 lore raw

PATCH v2 1/1 devres: Improve grp->id setting logics in devres_open_group()

Instead of setting grp->id directly with a temporary value and then changing it if a certain condition meets, we may check the condition first and then decide which value should be set to grp->id. This may save two lines of code and potentially reduces a writing operation.

---
v1->v2:
* Fix a typo in the commit head line.

 drivers/base/devres.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/base/devres.c +1 -3
index c8a53d1..39e1856 100644
@@ -544,9 +544,7 @@ void * devres_open_group(struct device *dev, void *id, gfp_t gfp)
 	INIT_LIST_HEAD(&grp->node[1].entry);
 	set_node_dbginfo(&grp->node[0], "grp<", 0);
 	set_node_dbginfo(&grp->node[1], "grp>", 0);
-	grp->id = grp;
-	if (id)
-		grp->id = id;
+	grp->id = id ? id : grp;
 
 	spin_lock_irqsave(&dev->devres_lock, flags);
 	add_dr(dev, &grp->node[0]);
Signature · 1 line
2.1.0