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)
{
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,
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
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;
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;
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);
*/
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);