[PATCH 3/3] ASoC: atmel-ssc: replace usage of found with dedicated list iterator variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@xxxxxxxxxxxxxx/ [1]
Signed-off-by: Jakob Koschel <jakobkoschel@xxxxxxxxx>
---
 drivers/misc/atmel-ssc.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c
index d6cd5537126c..343e25555fbb 100644
--- a/drivers/misc/atmel-ssc.c
+++ b/drivers/misc/atmel-ssc.c
@@ -25,25 +25,24 @@ static LIST_HEAD(ssc_list);
 
 struct ssc_device *ssc_request(unsigned int ssc_num)
 {
-	int ssc_valid = 0;
-	struct ssc_device *ssc;
+	struct ssc_device *ssc = NULL, *iter;
 
 	mutex_lock(&user_lock);
-	list_for_each_entry(ssc, &ssc_list, list) {
-		if (ssc->pdev->dev.of_node) {
-			if (of_alias_get_id(ssc->pdev->dev.of_node, "ssc")
+	list_for_each_entry(iter, &ssc_list, list) {
+		if (iter->pdev->dev.of_node) {
+			if (of_alias_get_id(iter->pdev->dev.of_node, "ssc")
 				== ssc_num) {
-				ssc->pdev->id = ssc_num;
-				ssc_valid = 1;
+				iter->pdev->id = ssc_num;
+				ssc = iter;
 				break;
 			}
-		} else if (ssc->pdev->id == ssc_num) {
-			ssc_valid = 1;
+		} else if (iter->pdev->id == ssc_num) {
+			ssc = iter;
 			break;
 		}
 	}
 
-	if (!ssc_valid) {
+	if (!ssc) {
 		mutex_unlock(&user_lock);
 		pr_err("ssc: ssc%d platform device is missing\n", ssc_num);
 		return ERR_PTR(-ENODEV);
-- 
2.25.1




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux