Skip to contentSkip to conversation

- export scsilun_to_int

PATCH Eric Moore 2 participants 2 messages Feb 1, 2007

Subsystems (2)
lore
Share & tools
lore

Eric Moore

author
#0 lore raw
Quoted 10 lines · James Bottomley

what's wrong with

memcmp(lun1->scsi_lun, lun2->scsi_lun, 8)

rather than introducing a wrapper? The compiler can even optimise memcmp for a fixed size nicely.

James

Changed to using memcmp. This replaces the prevous patch.

drivers/message/fusion/mptscsih.c +6 -5
diff -uarpN b/drivers/message/fusion/mptscsih.c a/drivers/message/fusion/mptscsih.c
@@ -1016,7 +1016,7 @@ mptscsih_search_running_cmds(MPT_SCSI_HO
 	int		 ii;
 	int		 max = hd->ioc->req_depth;
 	struct scsi_cmnd *sc;
-	int		 lun;
+	struct scsi_lun  lun;
 
 	dsprintk((KERN_INFO MYNAM ": search_running channel %d id %d lun %d max %d\n",
 	    vdevice->vtarget->channel, vdevice->vtarget->id, vdevice->lun, max));
@@ -1027,13 +1027,14 @@ mptscsih_search_running_cmds(MPT_SCSI_HO
 			mf = (SCSIIORequest_t *)MPT_INDEX_2_MFPTR(hd->ioc, ii);
 			if (mf == NULL)
 				continue;
-			lun = scsilun_to_int((struct scsi_lun *)mf->LUN);
-			dsprintk(( "search_running: found (sc=%p, mf = %p) chanel %d id %d, lun %d \n",
-			    hd->ScsiLookup[ii], mf, mf->Bus, mf->TargetID, lun));
+			int_to_scsilun(vdevice->lun, &lun);
 			if ((mf->Bus != vdevice->vtarget->channel) ||
 			    (mf->TargetID != vdevice->vtarget->id) ||
-			    (lun != vdevice->lun))
+			    memcmp(lun.scsi_lun, mf->LUN, 8))
 				continue;
+			dsprintk(( "search_running: found (sc=%p, mf = %p) "
+			    "channel %d id %d, lun %d \n", hd->ScsiLookup[ii],
+			    mf, mf->Bus, mf->TargetID, vdevice->lun));
 
 			/* Cleanup
 			 */
#1 lore raw
Quoted 8 lines · Eric Moore
Quoted 7 lines · James Bottomley

what's wrong with

memcmp(lun1->scsi_lun, lun2->scsi_lun, 8)

rather than introducing a wrapper? The compiler can even optimise memcmp for a fixed size nicely.

Quoted 8 lines
Quoted 2 lines

James

Changed to using memcmp. This replaces the prevous patch.

IMO a wrapper is better.

memcmp() is not type-safe nor type-aware, and we have already created a type for SCSI LUNs.

Jeff