aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJames.Smart@Emulex.Com <James.Smart@Emulex.Com>2005-07-13 22:05:03 -0400
committerJames Bottomley <jejb@mulgrave.(none)>2005-07-14 11:21:27 -0400
commit2f4701d8274c8663f5c50323dc72fefa24b55091 (patch)
treedc578144cfcf1db0687c7c67f6f8b300577359b1 /drivers
parent77d74143612c1dab6c055dac21f965929ba0a7e6 (diff)
[SCSI] add int_to_scsilun() function
One of the issues we had was reverting the midlayers lun value into the 8byte lun value that we wanted to send to the device. Historically, there's been some combination of byte swapping, setting high/low, etc. There's also been no common thread between how our driver did it and others. I also got very confused as to why byteswap routines were being used. Anyway, this patch is a LLDD-callable function that reverts the midlayer's lun value, stored in an int, to the 8-byte quantity (note: this is not the real 8byte quantity, just the same amount that scsilun_to_int() was able to convert and store originally). This also solves the dilemma of the thread: http://marc.theaimsgroup.com/?l=linux-kernel&m=112116767118981&w=2 A patch for the lpfc driver to use this function will be along in a few days (batched with other patches). Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/scsi_scan.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 9fa209097e3b..ad3a5b142468 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1000,6 +1000,38 @@ static int scsilun_to_int(struct scsi_lun *scsilun)
1000} 1000}
1001 1001
1002/** 1002/**
1003 * int_to_scsilun: reverts an int into a scsi_lun
1004 * @int: integer to be reverted
1005 * @scsilun: struct scsi_lun to be set.
1006 *
1007 * Description:
1008 * Reverts the functionality of the scsilun_to_int, which packed
1009 * an 8-byte lun value into an int. This routine unpacks the int
1010 * back into the lun value.
1011 * Note: the scsilun_to_int() routine does not truly handle all
1012 * 8bytes of the lun value. This functions restores only as much
1013 * as was set by the routine.
1014 *
1015 * Notes:
1016 * Given an integer : 0x0b030a04, this function returns a
1017 * scsi_lun of : struct scsi_lun of: 0a 04 0b 03 00 00 00 00
1018 *
1019 **/
1020void int_to_scsilun(unsigned int lun, struct scsi_lun *scsilun)
1021{
1022 int i;
1023
1024 memset(scsilun->scsi_lun, 0, sizeof(scsilun->scsi_lun));
1025
1026 for (i = 0; i < sizeof(lun); i += 2) {
1027 scsilun->scsi_lun[i] = (lun >> 8) & 0xFF;
1028 scsilun->scsi_lun[i+1] = lun & 0xFF;
1029 lun = lun >> 16;
1030 }
1031}
1032EXPORT_SYMBOL(int_to_scsilun);
1033
1034/**
1003 * scsi_report_lun_scan - Scan using SCSI REPORT LUN results 1035 * scsi_report_lun_scan - Scan using SCSI REPORT LUN results
1004 * @sdevscan: scan the host, channel, and id of this Scsi_Device 1036 * @sdevscan: scan the host, channel, and id of this Scsi_Device
1005 * 1037 *