diff options
author | James Bottomley <James.Bottomley@steeleye.com> | 2006-03-18 15:00:50 -0600 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-03-19 10:21:16 -0600 |
commit | 2f8600dff2b140096a7df781884e918a16aa90e0 (patch) | |
tree | 313d53e23c618950b078b6fd39d9e078fdf79011 /drivers/scsi/scsi_transport_sas.c | |
parent | f013db3284376070fc4c196e58d204180b8ed62a (diff) |
[SCSI] eliminate rphy allocation in favour of expander/end device allocation
This allows the removal of the contained flag and also does a bit of
class renaming (sas_rphy->sas_device).
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'drivers/scsi/scsi_transport_sas.c')
-rw-r--r-- | drivers/scsi/scsi_transport_sas.c | 72 |
1 files changed, 27 insertions, 45 deletions
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index 5a70d04352cc..134c44c8538a 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c @@ -699,7 +699,7 @@ sas_expander_simple_attr(component_revision_id, component_revision_id, "%u\n", sas_expander_simple_attr(level, level, "%d\n", int); static DECLARE_TRANSPORT_CLASS(sas_rphy_class, - "sas_rphy", NULL, NULL, NULL); + "sas_device", NULL, NULL, NULL); static int sas_rphy_match(struct attribute_container *cont, struct device *dev) { @@ -740,9 +740,7 @@ static int sas_end_dev_match(struct attribute_container *cont, i = to_sas_internal(shost->transportt); return &i->end_dev_attr_cont.ac == cont && - rphy->identify.device_type == SAS_END_DEVICE && - /* FIXME: remove contained eventually */ - rphy->contained; + rphy->identify.device_type == SAS_END_DEVICE; } static int sas_expander_match(struct attribute_container *cont, @@ -766,49 +764,26 @@ static int sas_expander_match(struct attribute_container *cont, i = to_sas_internal(shost->transportt); return &i->expander_attr_cont.ac == cont && (rphy->identify.device_type == SAS_EDGE_EXPANDER_DEVICE || - rphy->identify.device_type == SAS_FANOUT_EXPANDER_DEVICE) && - /* FIXME: remove contained eventually */ - rphy->contained; + rphy->identify.device_type == SAS_FANOUT_EXPANDER_DEVICE); } -static void sas_rphy_release(struct device *dev) +static void sas_expander_release(struct device *dev) { struct sas_rphy *rphy = dev_to_rphy(dev); + struct sas_expander_device *edev = rphy_to_expander_device(rphy); put_device(dev->parent); - kfree(rphy); + kfree(edev); } -/** - * sas_rphy_alloc -- allocates and initialize a SAS remote PHY structure - * @parent: SAS PHY this remote PHY is conneted to - * - * Allocates an SAS remote PHY structure, connected to @parent. - * - * Returns: - * SAS PHY allocated or %NULL if the allocation failed. - */ -struct sas_rphy *sas_rphy_alloc(struct sas_phy *parent) +static void sas_end_device_release(struct device *dev) { - struct Scsi_Host *shost = dev_to_shost(&parent->dev); - struct sas_rphy *rphy; - - rphy = kzalloc(sizeof(*rphy), GFP_KERNEL); - if (!rphy) { - put_device(&parent->dev); - return NULL; - } - - device_initialize(&rphy->dev); - rphy->dev.parent = get_device(&parent->dev); - rphy->dev.release = sas_rphy_release; - sprintf(rphy->dev.bus_id, "rphy-%d:%d-%d", - shost->host_no, parent->port_identifier, parent->number); - transport_setup_device(&rphy->dev); + struct sas_rphy *rphy = dev_to_rphy(dev); + struct sas_end_device *edev = rphy_to_end_device(rphy); - return rphy; + put_device(dev->parent); + kfree(edev); } -EXPORT_SYMBOL(sas_rphy_alloc); /** * sas_end_device_alloc - allocate an rphy for an end device @@ -831,12 +806,10 @@ struct sas_rphy *sas_end_device_alloc(struct sas_phy *parent) device_initialize(&rdev->rphy.dev); rdev->rphy.dev.parent = get_device(&parent->dev); - rdev->rphy.dev.release = sas_rphy_release; - sprintf(rdev->rphy.dev.bus_id, "rphy-%d:%d-%d", + rdev->rphy.dev.release = sas_end_device_release; + sprintf(rdev->rphy.dev.bus_id, "end_device-%d:%d-%d", shost->host_no, parent->port_identifier, parent->number); rdev->rphy.identify.device_type = SAS_END_DEVICE; - /* FIXME: mark the rphy as being contained in a larger structure */ - rdev->rphy.contained = 1; transport_setup_device(&rdev->rphy.dev); return &rdev->rphy; @@ -869,15 +842,13 @@ struct sas_rphy *sas_expander_alloc(struct sas_phy *parent, device_initialize(&rdev->rphy.dev); rdev->rphy.dev.parent = get_device(&parent->dev); - rdev->rphy.dev.release = sas_rphy_release; + rdev->rphy.dev.release = sas_expander_release; mutex_lock(&sas_host->lock); rdev->rphy.scsi_target_id = sas_host->next_expander_id++; mutex_unlock(&sas_host->lock); sprintf(rdev->rphy.dev.bus_id, "expander-%d:%d", shost->host_no, rdev->rphy.scsi_target_id); rdev->rphy.identify.device_type = type; - /* FIXME: mark the rphy as being contained in a larger structure */ - rdev->rphy.contained = 1; transport_setup_device(&rdev->rphy.dev); return &rdev->rphy; @@ -950,7 +921,17 @@ void sas_rphy_free(struct sas_rphy *rphy) put_device(rphy->dev.parent); put_device(rphy->dev.parent); put_device(rphy->dev.parent); - kfree(rphy); + if (rphy->identify.device_type == SAS_END_DEVICE) { + struct sas_end_device *edev = rphy_to_end_device(rphy); + + kfree(edev); + } else { + /* must be expander */ + struct sas_expander_device *edev = + rphy_to_expander_device(rphy); + + kfree(edev); + } } EXPORT_SYMBOL(sas_rphy_free); @@ -1003,7 +984,8 @@ EXPORT_SYMBOL(sas_rphy_delete); */ int scsi_is_sas_rphy(const struct device *dev) { - return dev->release == sas_rphy_release; + return dev->release == sas_end_device_release || + dev->release == sas_expander_release; } EXPORT_SYMBOL(scsi_is_sas_rphy); |