diff options
author | James Bottomley <James.Bottomley@steeleye.com> | 2006-03-18 16:00:50 -0500 |
---|---|---|
committer | James Bottomley <jejb@mulgrave.il.steeleye.com> | 2006-03-19 11:21:16 -0500 |
commit | 2f8600dff2b140096a7df781884e918a16aa90e0 (patch) | |
tree | 313d53e23c618950b078b6fd39d9e078fdf79011 /drivers | |
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')
-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", | |||
699 | sas_expander_simple_attr(level, level, "%d\n", int); | 699 | sas_expander_simple_attr(level, level, "%d\n", int); |
700 | 700 | ||
701 | static DECLARE_TRANSPORT_CLASS(sas_rphy_class, | 701 | static DECLARE_TRANSPORT_CLASS(sas_rphy_class, |
702 | "sas_rphy", NULL, NULL, NULL); | 702 | "sas_device", NULL, NULL, NULL); |
703 | 703 | ||
704 | static int sas_rphy_match(struct attribute_container *cont, struct device *dev) | 704 | static int sas_rphy_match(struct attribute_container *cont, struct device *dev) |
705 | { | 705 | { |
@@ -740,9 +740,7 @@ static int sas_end_dev_match(struct attribute_container *cont, | |||
740 | 740 | ||
741 | i = to_sas_internal(shost->transportt); | 741 | i = to_sas_internal(shost->transportt); |
742 | return &i->end_dev_attr_cont.ac == cont && | 742 | return &i->end_dev_attr_cont.ac == cont && |
743 | rphy->identify.device_type == SAS_END_DEVICE && | 743 | rphy->identify.device_type == SAS_END_DEVICE; |
744 | /* FIXME: remove contained eventually */ | ||
745 | rphy->contained; | ||
746 | } | 744 | } |
747 | 745 | ||
748 | static int sas_expander_match(struct attribute_container *cont, | 746 | static int sas_expander_match(struct attribute_container *cont, |
@@ -766,49 +764,26 @@ static int sas_expander_match(struct attribute_container *cont, | |||
766 | i = to_sas_internal(shost->transportt); | 764 | i = to_sas_internal(shost->transportt); |
767 | return &i->expander_attr_cont.ac == cont && | 765 | return &i->expander_attr_cont.ac == cont && |
768 | (rphy->identify.device_type == SAS_EDGE_EXPANDER_DEVICE || | 766 | (rphy->identify.device_type == SAS_EDGE_EXPANDER_DEVICE || |
769 | rphy->identify.device_type == SAS_FANOUT_EXPANDER_DEVICE) && | 767 | rphy->identify.device_type == SAS_FANOUT_EXPANDER_DEVICE); |
770 | /* FIXME: remove contained eventually */ | ||
771 | rphy->contained; | ||
772 | } | 768 | } |
773 | 769 | ||
774 | static void sas_rphy_release(struct device *dev) | 770 | static void sas_expander_release(struct device *dev) |
775 | { | 771 | { |
776 | struct sas_rphy *rphy = dev_to_rphy(dev); | 772 | struct sas_rphy *rphy = dev_to_rphy(dev); |
773 | struct sas_expander_device *edev = rphy_to_expander_device(rphy); | ||
777 | 774 | ||
778 | put_device(dev->parent); | 775 | put_device(dev->parent); |
779 | kfree(rphy); | 776 | kfree(edev); |
780 | } | 777 | } |
781 | 778 | ||
782 | /** | 779 | static void sas_end_device_release(struct device *dev) |
783 | * sas_rphy_alloc -- allocates and initialize a SAS remote PHY structure | ||
784 | * @parent: SAS PHY this remote PHY is conneted to | ||
785 | * | ||
786 | * Allocates an SAS remote PHY structure, connected to @parent. | ||
787 | * | ||
788 | * Returns: | ||
789 | * SAS PHY allocated or %NULL if the allocation failed. | ||
790 | */ | ||
791 | struct sas_rphy *sas_rphy_alloc(struct sas_phy *parent) | ||
792 | { | 780 | { |
793 | struct Scsi_Host *shost = dev_to_shost(&parent->dev); | 781 | struct sas_rphy *rphy = dev_to_rphy(dev); |
794 | struct sas_rphy *rphy; | 782 | struct sas_end_device *edev = rphy_to_end_device(rphy); |
795 | |||
796 | rphy = kzalloc(sizeof(*rphy), GFP_KERNEL); | ||
797 | if (!rphy) { | ||
798 | put_device(&parent->dev); | ||
799 | return NULL; | ||
800 | } | ||
801 | |||
802 | device_initialize(&rphy->dev); | ||
803 | rphy->dev.parent = get_device(&parent->dev); | ||
804 | rphy->dev.release = sas_rphy_release; | ||
805 | sprintf(rphy->dev.bus_id, "rphy-%d:%d-%d", | ||
806 | shost->host_no, parent->port_identifier, parent->number); | ||
807 | transport_setup_device(&rphy->dev); | ||
808 | 783 | ||
809 | return rphy; | 784 | put_device(dev->parent); |
785 | kfree(edev); | ||
810 | } | 786 | } |
811 | EXPORT_SYMBOL(sas_rphy_alloc); | ||
812 | 787 | ||
813 | /** | 788 | /** |
814 | * sas_end_device_alloc - allocate an rphy for an end device | 789 | * 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) | |||
831 | 806 | ||
832 | device_initialize(&rdev->rphy.dev); | 807 | device_initialize(&rdev->rphy.dev); |
833 | rdev->rphy.dev.parent = get_device(&parent->dev); | 808 | rdev->rphy.dev.parent = get_device(&parent->dev); |
834 | rdev->rphy.dev.release = sas_rphy_release; | 809 | rdev->rphy.dev.release = sas_end_device_release; |
835 | sprintf(rdev->rphy.dev.bus_id, "rphy-%d:%d-%d", | 810 | sprintf(rdev->rphy.dev.bus_id, "end_device-%d:%d-%d", |
836 | shost->host_no, parent->port_identifier, parent->number); | 811 | shost->host_no, parent->port_identifier, parent->number); |
837 | rdev->rphy.identify.device_type = SAS_END_DEVICE; | 812 | rdev->rphy.identify.device_type = SAS_END_DEVICE; |
838 | /* FIXME: mark the rphy as being contained in a larger structure */ | ||
839 | rdev->rphy.contained = 1; | ||
840 | transport_setup_device(&rdev->rphy.dev); | 813 | transport_setup_device(&rdev->rphy.dev); |
841 | 814 | ||
842 | return &rdev->rphy; | 815 | return &rdev->rphy; |
@@ -869,15 +842,13 @@ struct sas_rphy *sas_expander_alloc(struct sas_phy *parent, | |||
869 | 842 | ||
870 | device_initialize(&rdev->rphy.dev); | 843 | device_initialize(&rdev->rphy.dev); |
871 | rdev->rphy.dev.parent = get_device(&parent->dev); | 844 | rdev->rphy.dev.parent = get_device(&parent->dev); |
872 | rdev->rphy.dev.release = sas_rphy_release; | 845 | rdev->rphy.dev.release = sas_expander_release; |
873 | mutex_lock(&sas_host->lock); | 846 | mutex_lock(&sas_host->lock); |
874 | rdev->rphy.scsi_target_id = sas_host->next_expander_id++; | 847 | rdev->rphy.scsi_target_id = sas_host->next_expander_id++; |
875 | mutex_unlock(&sas_host->lock); | 848 | mutex_unlock(&sas_host->lock); |
876 | sprintf(rdev->rphy.dev.bus_id, "expander-%d:%d", | 849 | sprintf(rdev->rphy.dev.bus_id, "expander-%d:%d", |
877 | shost->host_no, rdev->rphy.scsi_target_id); | 850 | shost->host_no, rdev->rphy.scsi_target_id); |
878 | rdev->rphy.identify.device_type = type; | 851 | rdev->rphy.identify.device_type = type; |
879 | /* FIXME: mark the rphy as being contained in a larger structure */ | ||
880 | rdev->rphy.contained = 1; | ||
881 | transport_setup_device(&rdev->rphy.dev); | 852 | transport_setup_device(&rdev->rphy.dev); |
882 | 853 | ||
883 | return &rdev->rphy; | 854 | return &rdev->rphy; |
@@ -950,7 +921,17 @@ void sas_rphy_free(struct sas_rphy *rphy) | |||
950 | put_device(rphy->dev.parent); | 921 | put_device(rphy->dev.parent); |
951 | put_device(rphy->dev.parent); | 922 | put_device(rphy->dev.parent); |
952 | put_device(rphy->dev.parent); | 923 | put_device(rphy->dev.parent); |
953 | kfree(rphy); | 924 | if (rphy->identify.device_type == SAS_END_DEVICE) { |
925 | struct sas_end_device *edev = rphy_to_end_device(rphy); | ||
926 | |||
927 | kfree(edev); | ||
928 | } else { | ||
929 | /* must be expander */ | ||
930 | struct sas_expander_device *edev = | ||
931 | rphy_to_expander_device(rphy); | ||
932 | |||
933 | kfree(edev); | ||
934 | } | ||
954 | } | 935 | } |
955 | EXPORT_SYMBOL(sas_rphy_free); | 936 | EXPORT_SYMBOL(sas_rphy_free); |
956 | 937 | ||
@@ -1003,7 +984,8 @@ EXPORT_SYMBOL(sas_rphy_delete); | |||
1003 | */ | 984 | */ |
1004 | int scsi_is_sas_rphy(const struct device *dev) | 985 | int scsi_is_sas_rphy(const struct device *dev) |
1005 | { | 986 | { |
1006 | return dev->release == sas_rphy_release; | 987 | return dev->release == sas_end_device_release || |
988 | dev->release == sas_expander_release; | ||
1007 | } | 989 | } |
1008 | EXPORT_SYMBOL(scsi_is_sas_rphy); | 990 | EXPORT_SYMBOL(scsi_is_sas_rphy); |
1009 | 991 | ||