Commit 2f8600df authored by James Bottomley's avatar James Bottomley Committed by James Bottomley

[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: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent f013db32
......@@ -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);
......
......@@ -82,10 +82,6 @@ struct sas_rphy {
struct sas_identify identify;
struct list_head list;
u32 scsi_target_id;
/* temporary expedient: mark the rphy as being contained
* within a type specific rphy
* FIXME: pull this out when everything uses the containers */
unsigned contained:1;
};
#define dev_to_rphy(d) \
......@@ -145,7 +141,6 @@ extern int sas_phy_add(struct sas_phy *);
extern void sas_phy_delete(struct sas_phy *);
extern int scsi_is_sas_phy(const struct device *);
extern struct sas_rphy *sas_rphy_alloc(struct sas_phy *);
extern struct sas_rphy *sas_end_device_alloc(struct sas_phy *);
extern struct sas_rphy *sas_expander_alloc(struct sas_phy *, enum sas_device_type);
void sas_rphy_free(struct sas_rphy *);
......
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