[openib-general] SRP [PATCH] Cleaning in srp_remove_one

Ishai Rabinovitz ishai at mellanox.co.il
Wed May 17 09:21:41 PDT 2006


3 changes in the same place:

1) The if statement is redundant.
2) There is no need to save the flags - it is inside a mutex_lock.
3) We hold the mutex for the list and we are not deleting from the list so 
   there is no need for list_for_each_entry_safe.

Signed-off-by: Ishai Rabinovitz <ishai at mellanox.co.il>
Index: last_stable/drivers/infiniband/ulp/srp/ib_srp.c
===================================================================
--- last_stable.orig/drivers/infiniband/ulp/srp/ib_srp.c	2006-05-14 14:22:12.000000000 +0300
+++ last_stable/drivers/infiniband/ulp/srp/ib_srp.c	2006-05-14 14:26:54.000000000 +0300
@@ -1750,7 +1750,6 @@ static void srp_remove_one(struct ib_dev
 	struct srp_host *host, *tmp_host;
 	LIST_HEAD(target_list);
 	struct srp_target_port *target, *tmp_target;
-	unsigned long flags;
 
 	dev_list = ib_get_client_data(device, &srp_client);
 
@@ -1767,12 +1766,10 @@ static void srp_remove_one(struct ib_dev
 		 * commands and don't try to reconnect.
 		 */
 		mutex_lock(&host->target_mutex);
-		list_for_each_entry_safe(target, tmp_target,
-					 &host->target_list, list) {
-			spin_lock_irqsave(target->scsi_host->host_lock, flags);
-			if (target->state != SRP_TARGET_REMOVED)
-				target->state = SRP_TARGET_REMOVED;
-			spin_unlock_irqrestore(target->scsi_host->host_lock, flags);
+		list_for_each_entry(target, &host->target_list, list) {
+			spin_lock_irq(target->scsi_host->host_lock);
+			target->state = SRP_TARGET_REMOVED;
+			spin_unlock_irq(target->scsi_host->host_lock);
 		}
 		mutex_unlock(&host->target_mutex);
 
-- 
Ishai Rabinovitz



More information about the general mailing list