Skip to contentSkip to conversation

aic94xx: fix cascaded expander properties

PATCH New James Bottomley 1 participant 1 message Jul 8, 2006 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aic94xx: fix cascaded expander properties

The sas_device properties for a cascaded expander are always empty. Fix this by filling them in at the correct point (also refactor the code since we do this in several places).

James

drivers/scsi/sas/sas_expander.c +3 -6
Index: BUILD-2.6/drivers/scsi/sas/sas_expander.c
===================================================================
@@ -611,11 +611,7 @@
 		sas_init_dev(child);
 
 		child->rphy = rphy;
-		rphy->identify.phy_identifier = phy->phy->identify.phy_identifier;
-		rphy->identify.device_type = SAS_END_DEVICE;
-		rphy->identify.sas_address = SAS_ADDR(child->sas_addr);
-		rphy->identify.initiator_port_protocols = child->iproto;
-		rphy->identify.target_port_protocols = child->tproto;
+		sas_fill_in_rphy(child, rphy);
 
 		spin_lock(&parent->port->dev_list_lock);
 		list_add_tail(&child->dev_list_node, &parent->port->dev_list);
@@ -698,7 +694,8 @@
 	parent->port->disc.max_level = max(parent->port->disc.max_level,
 					   edev->level);
 	sas_init_dev(child);
-	sas_rphy_add(child->rphy);
+	sas_fill_in_rphy(child, rphy);
+	sas_rphy_add(rphy);
 
 	spin_lock(&parent->port->dev_list_lock);
 	list_add_tail(&child->dev_list_node, &parent->port->dev_list);
drivers/scsi/sas/sas_discover.c +1 -19
Index: BUILD-2.6/drivers/scsi/sas/sas_discover.c
===================================================================
@@ -278,25 +278,7 @@
 	}
 	rphy->identify.phy_identifier = phy->phy->identify.phy_identifier;
 	memcpy(dev->sas_addr, port->attached_sas_addr, SAS_ADDR_SIZE);
-	rphy->identify.sas_address = SAS_ADDR(dev->sas_addr);
-	rphy->identify.initiator_port_protocols = dev->iproto;
-	rphy->identify.target_port_protocols = dev->tproto;
-	switch (dev->dev_type) {
-	case SATA_DEV:
-		/* FIXME: need sata device type */
-	case SAS_END_DEV:
-		rphy->identify.device_type = SAS_END_DEVICE;
-		break;
-	case EDGE_DEV:
-		rphy->identify.device_type = SAS_EDGE_EXPANDER_DEVICE;
-		break;
-	case FANOUT_DEV:
-		rphy->identify.device_type = SAS_FANOUT_EXPANDER_DEVICE;
-		break;
-	default:
-		rphy->identify.device_type = SAS_PHY_UNUSED;
-		break;
-	}
+	sas_fill_in_rphy(dev, rphy);
 	sas_hash_addr(dev->hashed_sas_addr, dev->sas_addr);
 	port->port_dev = dev;
 	dev->port = port;
drivers/scsi/sas/sas_internal.h +26 -1
Index: BUILD-2.6/drivers/scsi/sas/sas_internal.h
===================================================================
@@ -26,8 +26,9 @@
 #ifndef _SAS_INTERNAL_H_
 #define _SAS_INTERNAL_H_
 
-#include <scsi/libsas.h>
 #include <scsi/scsi_host.h>
+#include <scsi/scsi_transport_sas.h>
+#include <scsi/libsas.h>
 
 #define sas_printk(fmt, ...) printk(KERN_NOTICE "sas: " fmt, ## __VA_ARGS__)
 
@@ -97,4 +98,28 @@
 	spin_unlock_irqrestore(lock, flags);
 }
 
+static inline void sas_fill_in_rphy(struct domain_device *dev,
+				    struct sas_rphy *rphy)
+{
+	rphy->identify.sas_address = SAS_ADDR(dev->sas_addr);
+	rphy->identify.initiator_port_protocols = dev->iproto;
+	rphy->identify.target_port_protocols = dev->tproto;
+	switch (dev->dev_type) {
+	case SATA_DEV:
+		/* FIXME: need sata device type */
+	case SAS_END_DEV:
+		rphy->identify.device_type = SAS_END_DEVICE;
+		break;
+	case EDGE_DEV:
+		rphy->identify.device_type = SAS_EDGE_EXPANDER_DEVICE;
+		break;
+	case FANOUT_DEV:
+		rphy->identify.device_type = SAS_FANOUT_EXPANDER_DEVICE;
+		break;
+	default:
+		rphy->identify.device_type = SAS_PHY_UNUSED;
+		break;
+	}
+}
+
 #endif /* _SAS_INTERNAL_H_ */