diff mbox series

scsi: scsi_devinfo: remove redundant 'found'

Message ID 20250531054638.46256-1-mrigendra.chaubey@gmail.com
State New
Headers show
Series scsi: scsi_devinfo: remove redundant 'found' | expand

Commit Message

mrigendrachaubey May 31, 2025, 5:46 a.m. UTC
Remove the unnecessary 'found' flag in scsi_devinfo_lookup_by_key().
The loop can return the matching entry directly when found, and fall
through to return ERR_PTR(-EINVAL) otherwise.

Signed-off-by: mrigendrachaubey <mrigendra.chaubey@gmail.com>
---
 drivers/scsi/scsi_devinfo.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index a348df895dca..53cc60ab6dab 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -269,17 +269,13 @@  static struct {
 static struct scsi_dev_info_list_table *scsi_devinfo_lookup_by_key(int key)
 {
 	struct scsi_dev_info_list_table *devinfo_table;
-	int found = 0;
 
-	list_for_each_entry(devinfo_table, &scsi_dev_info_list, node)
-		if (devinfo_table->key == key) {
-			found = 1;
-			break;
-		}
-	if (!found)
-		return ERR_PTR(-EINVAL);
+	list_for_each_entry(devinfo_table, &scsi_dev_info_list, node) {
+		if (devinfo_table->key == key)
+			return devinfo_table;
+	}
 
-	return devinfo_table;
+	return ERR_PTR(-EINVAL);
 }
 
 /*