aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-sbp2.c
diff options
context:
space:
mode:
authorStefan Richter <stefanr@s5r6.in-berlin.de>2007-05-27 07:18:27 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2007-05-31 15:40:13 -0400
commit14e2198646d92ef52a69d20269580a3fbe7c996b (patch)
treeff9522f74da61ade0ab3739a35ea90b85fd91fea /drivers/firewire/fw-sbp2.c
parentd7794c86686a05276de42f145e485099426aca68 (diff)
firewire: fw-sbp2: implement sysfs ieee1394_id
The attribute /sys/bus/scsi/devices/*:*:*:*/ieee1394_id, as generated by the old sbp2 driver, is typically used to create persistently named links in /dev/disk/by-id. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Diffstat (limited to 'drivers/firewire/fw-sbp2.c')
-rw-r--r--drivers/firewire/fw-sbp2.c53
1 files changed, 53 insertions, 0 deletions
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 */
1118static ssize_t
1119sbp2_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
1156static DEVICE_ATTR(ieee1394_id, S_IRUGO, sbp2_sysfs_ieee1394_id_show, NULL);
1157
1158static struct device_attribute *sbp2_scsi_sysfs_attrs[] = {
1159 &dev_attr_ieee1394_id,
1160 NULL
1161};
1162
1111static struct scsi_host_template scsi_driver_template = { 1163static 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
1126MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>"); 1179MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");