Commit 52dd1e04 authored by Ben Collins's avatar Ben Collins

IEEE1394(r1112): Adds a "ieee1394_guid" attribute to the scsi device for sbp2.

parent 27e0f0fe
...@@ -745,6 +745,7 @@ static struct sbp2scsi_host_info *sbp2_add_host(struct hpsb_host *host) ...@@ -745,6 +745,7 @@ static struct sbp2scsi_host_info *sbp2_add_host(struct hpsb_host *host)
SBP2_ERR("failed to add scsi host"); SBP2_ERR("failed to add scsi host");
scsi_host_put(hi->scsi_host); scsi_host_put(hi->scsi_host);
hpsb_destroy_hostinfo(&sbp2_highlevel, host); hpsb_destroy_hostinfo(&sbp2_highlevel, host);
return NULL;
} }
return hi; return hi;
...@@ -990,6 +991,9 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -990,6 +991,9 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
return PTR_ERR(sdev); return PTR_ERR(sdev);
} }
sdev->hostdata = scsi_id;
scsi_id->sdev = sdev;
return 0; return 0;
} }
...@@ -999,7 +1003,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) ...@@ -999,7 +1003,6 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id) static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
{ {
struct sbp2scsi_host_info *hi = scsi_id->hi; struct sbp2scsi_host_info *hi = scsi_id->hi;
struct scsi_device *sdev;
SBP2_DEBUG("sbp2_remove_device"); SBP2_DEBUG("sbp2_remove_device");
...@@ -1007,12 +1010,9 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id) ...@@ -1007,12 +1010,9 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT); sbp2scsi_complete_all_commands(scsi_id, DID_NO_CONNECT);
/* Remove it from the scsi layer now */ /* Remove it from the scsi layer now */
/* XXX(hch): why can't we simply cache the scsi_device if (scsi_id->sdev) {
in struct scsi_id_instance_data? */ scsi_remove_device(scsi_id->sdev);
sdev = scsi_device_lookup(hi->scsi_host, 0, scsi_id->id, 0); scsi_device_put(scsi_id->sdev);
if (sdev) {
scsi_remove_device(sdev);
scsi_device_put(sdev);
} }
sbp2util_remove_command_orb_pool(scsi_id); sbp2util_remove_command_orb_pool(scsi_id);
...@@ -2849,6 +2849,27 @@ static const char *sbp2scsi_info (struct Scsi_Host *host) ...@@ -2849,6 +2849,27 @@ static const char *sbp2scsi_info (struct Scsi_Host *host)
return "SCSI emulation for IEEE-1394 SBP-2 Devices"; return "SCSI emulation for IEEE-1394 SBP-2 Devices";
} }
static ssize_t sbp2_sysfs_ieee1394_guid_show(struct device *dev, char *buf)
{
struct scsi_device *sdev;
struct scsi_id_instance_data *scsi_id;
if (!(sdev = to_scsi_device(dev)))
return 0;
if (!(scsi_id = sdev->hostdata))
return 0;
return sprintf(buf, "%016Lx\n", (unsigned long long)scsi_id->ne->guid);
}
static DEVICE_ATTR(ieee1394_guid, S_IRUGO, sbp2_sysfs_ieee1394_guid_show, NULL);
static struct device_attribute *sbp2_sysfs_sdev_attrs[] = {
&dev_attr_ieee1394_guid,
NULL
};
MODULE_AUTHOR("Ben Collins <bcollins@debian.org>"); MODULE_AUTHOR("Ben Collins <bcollins@debian.org>");
MODULE_DESCRIPTION("IEEE-1394 SBP-2 protocol driver"); MODULE_DESCRIPTION("IEEE-1394 SBP-2 protocol driver");
MODULE_SUPPORTED_DEVICE(SBP2_DEVICE_NAME); MODULE_SUPPORTED_DEVICE(SBP2_DEVICE_NAME);
...@@ -2871,6 +2892,7 @@ static Scsi_Host_Template scsi_driver_template = { ...@@ -2871,6 +2892,7 @@ static Scsi_Host_Template scsi_driver_template = {
.cmd_per_lun = SBP2_MAX_CMDS_PER_LUN, .cmd_per_lun = SBP2_MAX_CMDS_PER_LUN,
.can_queue = SBP2_MAX_SCSI_QUEUE, .can_queue = SBP2_MAX_SCSI_QUEUE,
.emulated = 1, .emulated = 1,
.sdev_attrs = sbp2_sysfs_sdev_attrs,
}; };
static int sbp2_module_init(void) static int sbp2_module_init(void)
......
...@@ -410,6 +410,9 @@ struct scsi_id_instance_data { ...@@ -410,6 +410,9 @@ struct scsi_id_instance_data {
/* A backlink to our host_info */ /* A backlink to our host_info */
struct sbp2scsi_host_info *hi; struct sbp2scsi_host_info *hi;
/* The scsi_device associated with this scsi_id */
struct scsi_device *sdev;
/* Device specific workarounds/brokeness */ /* Device specific workarounds/brokeness */
u32 workarounds; u32 workarounds;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment