diff options
Diffstat (limited to 'drivers/firewire')
-rw-r--r-- | drivers/firewire/fw-device.h | 1 | ||||
-rw-r--r-- | drivers/firewire/fw-sbp2.c | 53 |
2 files changed, 54 insertions, 0 deletions
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h index 0ba9d64ccf4c..af1723eae4ba 100644 --- a/drivers/firewire/fw-device.h +++ b/drivers/firewire/fw-device.h | |||
@@ -99,6 +99,7 @@ fw_unit(struct device *dev) | |||
99 | #define CSR_DEPENDENT_INFO 0x14 | 99 | #define CSR_DEPENDENT_INFO 0x14 |
100 | #define CSR_MODEL 0x17 | 100 | #define CSR_MODEL 0x17 |
101 | #define CSR_INSTANCE 0x18 | 101 | #define CSR_INSTANCE 0x18 |
102 | #define CSR_DIRECTORY_ID 0x20 | ||
102 | 103 | ||
103 | #define SBP2_COMMAND_SET_SPECIFIER 0x38 | 104 | #define SBP2_COMMAND_SET_SPECIFIER 0x38 |
104 | #define SBP2_COMMAND_SET 0x39 | 105 | #define SBP2_COMMAND_SET 0x39 |
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c index 68300414e5f4..a98d3915e26f 100644 --- a/drivers/firewire/fw-sbp2.c +++ b/drivers/firewire/fw-sbp2.c | |||
@@ -1108,6 +1108,58 @@ static int sbp2_scsi_abort(struct scsi_cmnd *cmd) | |||
1108 | return SUCCESS; | 1108 | return SUCCESS; |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | /* | ||
1112 | * Format of /sys/bus/scsi/devices/.../ieee1394_id: | ||
1113 | * u64 EUI-64 : u24 directory_ID : u16 LUN (all printed in hexadecimal) | ||
1114 | * | ||
1115 | * This is the concatenation of target port identifier and logical unit | ||
1116 | * identifier as per SAM-2...SAM-4 annex A. | ||
1117 | */ | ||
1118 | static ssize_t | ||
1119 | sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr, | ||
1120 | char *buf) | ||
1121 | { | ||
1122 | struct scsi_device *sdev = to_scsi_device(dev); | ||
1123 | struct sbp2_device *sd; | ||
1124 | struct fw_unit *unit; | ||
1125 | struct fw_device *device; | ||
1126 | u32 directory_id; | ||
1127 | struct fw_csr_iterator ci; | ||
1128 | int key, value, lun; | ||
1129 | |||
1130 | if (!sdev) | ||
1131 | return 0; | ||
1132 | sd = (struct sbp2_device *)sdev->host->hostdata; | ||
1133 | unit = sd->unit; | ||
1134 | device = fw_device(unit->device.parent); | ||
1135 | |||
1136 | /* implicit directory ID */ | ||
1137 | directory_id = ((unit->directory - device->config_rom) * 4 | ||
1138 | + CSR_CONFIG_ROM) & 0xffffff; | ||
1139 | |||
1140 | /* explicit directory ID, overrides implicit ID if present */ | ||
1141 | fw_csr_iterator_init(&ci, unit->directory); | ||
1142 | while (fw_csr_iterator_next(&ci, &key, &value)) | ||
1143 | if (key == CSR_DIRECTORY_ID) { | ||
1144 | directory_id = value; | ||
1145 | break; | ||
1146 | } | ||
1147 | |||
1148 | /* FIXME: Make this work for multi-lun devices. */ | ||
1149 | lun = 0; | ||
1150 | |||
1151 | return sprintf(buf, "%08x%08x:%06x:%04x\n", | ||
1152 | device->config_rom[3], device->config_rom[4], | ||
1153 | directory_id, lun); | ||
1154 | } | ||
1155 | |||
1156 | static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL); | ||
1157 | |||
1158 | static struct device_attribute *sbp2_scsi_sysfs_attrs[] = { | ||
1159 | &dev_attr_ieee1394_id, | ||
1160 | NULL | ||
1161 | }; | ||
1162 | |||
1111 | static struct scsi_host_template scsi_driver_template = { | 1163 | static struct scsi_host_template scsi_driver_template = { |
1112 | .module = THIS_MODULE, | 1164 | .module = THIS_MODULE, |
1113 | .name = "SBP-2 IEEE-1394", | 1165 | .name = "SBP-2 IEEE-1394", |
@@ -1121,6 +1173,7 @@ static struct scsi_host_template scsi_driver_template = { | |||
1121 | .use_clustering = ENABLE_CLUSTERING, | 1173 | .use_clustering = ENABLE_CLUSTERING, |
1122 | .cmd_per_lun = 1, | 1174 | .cmd_per_lun = 1, |
1123 | .can_queue = 1, | 1175 | .can_queue = 1, |
1176 | .sdev_attrs = sbp2_scsi_sysfs_attrs, | ||
1124 | }; | 1177 | }; |
1125 | 1178 | ||
1126 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); | 1179 | MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); |