Skip to contentSkip to conversation

mfd: dln2: replace usage of found with dedicated list iterator variable

PATCH New Jakob Koschel 1 participant 1 message Mar 24, 2022 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: dln2: replace usage of found with dedicated list iterator variable

To move the list iterator variable into the list_for_each_entry_*() macro in the future it should be avoided to use the list iterator variable after the loop body.

To *never* use the list iterator variable after the loop it was concluded to use a separate iterator variable instead of a found boolean [1].

This removes the need to use a found variable and simply checking if the variable was set, can determine if the break/goto was hit.

---
 drivers/mfd/dln2.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/mfd/dln2.c +6 -7
index 852129ea0766..741e8ae2d89d 100644
@@ -163,23 +163,22 @@ EXPORT_SYMBOL(dln2_register_event_cb);
 void dln2_unregister_event_cb(struct platform_device *pdev, u16 id)
 {
 	struct dln2_dev *dln2 = dev_get_drvdata(pdev->dev.parent);
-	struct dln2_event_cb_entry *i;
+	struct dln2_event_cb_entry *i = NULL, *iter;
 	unsigned long flags;
-	bool found = false;
 
 	spin_lock_irqsave(&dln2->event_cb_lock, flags);
 
-	list_for_each_entry(i, &dln2->event_cb_list, list) {
-		if (i->id == id) {
-			list_del_rcu(&i->list);
-			found = true;
+	list_for_each_entry(iter, &dln2->event_cb_list, list) {
+		if (iter->id == id) {
+			list_del_rcu(&iter->list);
+			i = iter;
 			break;
 		}
 	}
 
 	spin_unlock_irqrestore(&dln2->event_cb_lock, flags);
 
-	if (found) {
+	if (i) {
 		synchronize_rcu();
 		kfree(i);
 	}

base-commit: f443e374ae131c168a065ea1748feac6b2e76613

Signature · 1 line
2.25.1