Skip to contentSkip to conversation

scsi: qedf: Simplify mutex_unlock() usage

PATCH Applied Daniel Wagner 2 participants 2 messages Apr 3, 2020 – Apr 14, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 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 and drop the else body.

Cc Hannes Reinecke <[email protected]>
Cc Saurav Kashyap <[email protected]>

---

changes since v1:
- refactor the fcport->rdata assignemnt.

 drivers/scsi/qedf/qedf_els.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/scsi/qedf/qedf_els.c +3 -7
index 87e169dcebdb..542ba9454257 100644
@@ -388,14 +388,10 @@ 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);
-		if (rdata) {
-			mutex_unlock(&lport->disc.disc_mutex);
+		mutex_unlock(&lport->disc.disc_mutex);
+		if (rdata)
 			fc_rport_login(rdata);
-			fcport->rdata = rdata;
-		} else {
-			mutex_unlock(&lport->disc.disc_mutex);
-			fcport->rdata = NULL;
-		}
+		fcport->rdata = rdata;
 	}
 	clear_bit(QEDF_RPORT_IN_RESET, &fcport->flags);
 }
Signature · 1 line
2.26.0
#1 lore raw

Daniel,

Quoted 4 lines

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 and drop the else body.

Applied to 5.8/scsi-queue, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering