[SCSI] srp_transport: convert to use supported_mode attribute
authorFUJITA Tomonori <tomof@acm.org>
Fri, 31 Aug 2007 17:03:39 +0000 (02:03 +0900)
committerJames Bottomley <jejb@mulgrave.localdomain>
Fri, 12 Oct 2007 18:47:02 +0000 (14:47 -0400)
srp transport works for target drivers without supported_mode
attribute but it would be better to use it explicitly.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/ibmvscsi/ibmvstgt.c
drivers/scsi/scsi_transport_srp.c

index 3db03dd6b56ee29c6be8d602386236bd942cb3f4..82bcab688b44895fa0a17389100c65af7d95cf1c 100644 (file)
@@ -820,6 +820,7 @@ static struct scsi_host_template ibmvstgt_sht = {
        .eh_abort_handler       = ibmvstgt_eh_abort_handler,
        .shost_attrs            = ibmvstgt_attrs,
        .proc_name              = TGT_NAME,
+       .supported_mode         = MODE_TARGET,
 };
 
 static int ibmvstgt_probe(struct vio_dev *dev, const struct vio_device_id *id)
index 430501ef9f02fed890705ec698f6a9915fcf4715..44a340bd937b9fb43752ccceb1427c25341f92bc 100644 (file)
@@ -222,7 +222,8 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
                return ERR_PTR(ret);
        }
 
-       if (ids->roles == SRP_RPORT_ROLE_INITIATOR) {
+       if (shost->active_mode & MODE_TARGET &&
+           ids->roles == SRP_RPORT_ROLE_INITIATOR) {
                ret = srp_tgt_it_nexus_create(shost, (unsigned long)rport,
                                              rport->port_id);
                if (ret) {
@@ -249,10 +250,11 @@ EXPORT_SYMBOL_GPL(srp_rport_add);
 void srp_rport_del(struct srp_rport *rport)
 {
        struct device *dev = &rport->dev;
+       struct Scsi_Host *shost = dev_to_shost(dev->parent);
 
-       if (rport->roles == SRP_RPORT_ROLE_INITIATOR)
-               srp_tgt_it_nexus_destroy(dev_to_shost(dev->parent),
-                                        (unsigned long)rport);
+       if (shost->active_mode & MODE_TARGET &&
+           rport->roles == SRP_RPORT_ROLE_INITIATOR)
+               srp_tgt_it_nexus_destroy(shost, (unsigned long)rport);
 
        transport_remove_device(dev);
        device_del(dev);