Skip to contentSkip to conversation

scsi: qedf: Simplify mutex_unlock() usage

PATCH Superseded Daniel Wagner 1 participant 2 messages Apr 1, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: qedf: Simplify mutex_unlock() usage

The commit 6d1368e8f987 ("scsi: qedf: fixup locking in qedf_restart_rport()") introduced the lock. Though the lock protects only the fc_rport_create() call. Thus, we can move the mutex unlock up before the if statement.

Cc Hannes Reinecke <[email protected]>
Cc Saurav Kashyap <[email protected]>
---
 drivers/scsi/qedf/qedf_els.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/qedf/qedf_els.c +1 -2
index 87e169dcebdb..c60eede92145 100644
@@ -388,12 +388,11 @@ void qedf_restart_rport(struct qedf_rport *fcport)
 		mutex_lock(&lport->disc.disc_mutex);
 		/* Recreate the rport and log back in */
 		rdata = fc_rport_create(lport, port_id);
+		mutex_unlock(&lport->disc.disc_mutex);
 		if (rdata) {
-			mutex_unlock(&lport->disc.disc_mutex);
 			fc_rport_login(rdata);
 			fcport->rdata = rdata;
 		} else {
-			mutex_unlock(&lport->disc.disc_mutex);
 			fcport->rdata = NULL;
 		}
 	}
Signature · 1 line
2.26.0
#1 lore raw
Quoted 6 lines · Daniel Wagner
drivers/scsi/qedf/qedf_els.c +0 -0
@@ -388,12 +388,11 @@ void qedf_restart_rport(struct qedf_rport *fcport)
 		mutex_lock(&lport->disc.disc_mutex);
 		/* Recreate the rport and log back in */
 		rdata = fc_rport_create(lport, port_id);

drivers/scsi/qedf/qedf_els.c void qedf_restart_rport(struct qedf_rport *fcport) · line 398

Quoted 10 lines
drivers/scsi/qedf/qedf_els.c +1 -2
+		mutex_unlock(&lport->disc.disc_mutex);
 		if (rdata) {
-			mutex_unlock(&lport->disc.disc_mutex);
 			fc_rport_login(rdata);
 			fcport->rdata = rdata;
 		} else {
-			mutex_unlock(&lport->disc.disc_mutex);
 			fcport->rdata = NULL;
 		}
 	}

Looking at it again, I think we could even do

	mutex_unlock(&lport->disc.disc_mutex);
	if (rdata)
		fc_rport_login(rdata);
	fcport->rdata = rdata;