From 1a411b8b4b277dcb8756b1c13ee400300c31154c Mon Sep 17 00:00:00 2001 From: "James.Smart@Emulex.Com" Date: Wed, 13 Jul 2005 22:05:03 -0400 Subject: [PATCH] --- yaml --- r: 5023 b: refs/heads/master c: 2f4701d8274c8663f5c50323dc72fefa24b55091 h: refs/heads/master i: 5021: 92d3d63b523bbefeae0181665e5734301b0d49ac 5019: c19b55aed72aa91556e7f508f365842151107759 5015: b32f5b3d92bcc6b40a766719673835733aac5f58 5007: c473208569c2e80df455f5e6c35df329a2d1f090 4991: 2971e938b85345e49c44c594a12fae48d1850d81 v: v3 --- [refs] | 2 +- trunk/drivers/scsi/scsi_scan.c | 32 ++++++++++++++++++++++++++++++++ trunk/include/scsi/scsi_device.h | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index a2207d04ab20..09e5f3bb75bd 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 77d74143612c1dab6c055dac21f965929ba0a7e6 +refs/heads/master: 2f4701d8274c8663f5c50323dc72fefa24b55091 diff --git a/trunk/drivers/scsi/scsi_scan.c b/trunk/drivers/scsi/scsi_scan.c index 9fa209097e3b..ad3a5b142468 100644 --- a/trunk/drivers/scsi/scsi_scan.c +++ b/trunk/drivers/scsi/scsi_scan.c @@ -999,6 +999,38 @@ static int scsilun_to_int(struct scsi_lun *scsilun) return lun; } +/** + * int_to_scsilun: reverts an int into a scsi_lun + * @int: integer to be reverted + * @scsilun: struct scsi_lun to be set. + * + * Description: + * Reverts the functionality of the scsilun_to_int, which packed + * an 8-byte lun value into an int. This routine unpacks the int + * back into the lun value. + * Note: the scsilun_to_int() routine does not truly handle all + * 8bytes of the lun value. This functions restores only as much + * as was set by the routine. + * + * Notes: + * Given an integer : 0x0b030a04, this function returns a + * scsi_lun of : struct scsi_lun of: 0a 04 0b 03 00 00 00 00 + * + **/ +void int_to_scsilun(unsigned int lun, struct scsi_lun *scsilun) +{ + int i; + + memset(scsilun->scsi_lun, 0, sizeof(scsilun->scsi_lun)); + + for (i = 0; i < sizeof(lun); i += 2) { + scsilun->scsi_lun[i] = (lun >> 8) & 0xFF; + scsilun->scsi_lun[i+1] = lun & 0xFF; + lun = lun >> 16; + } +} +EXPORT_SYMBOL(int_to_scsilun); + /** * scsi_report_lun_scan - Scan using SCSI REPORT LUN results * @sdevscan: scan the host, channel, and id of this Scsi_Device diff --git a/trunk/include/scsi/scsi_device.h b/trunk/include/scsi/scsi_device.h index 63c91dd85ca1..223f92f4d2cb 100644 --- a/trunk/include/scsi/scsi_device.h +++ b/trunk/include/scsi/scsi_device.h @@ -243,6 +243,7 @@ extern void scsi_target_reap(struct scsi_target *); extern void scsi_target_block(struct device *); extern void scsi_target_unblock(struct device *); extern void scsi_remove_target(struct device *); +extern void int_to_scsilun(unsigned int, struct scsi_lun *); extern const char *scsi_device_state_name(enum scsi_device_state); extern int scsi_is_sdev_device(const struct device *); extern int scsi_is_target_device(const struct device *);