aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/scsi_transport_sas.c72
-rw-r--r--include/scsi/scsi_transport_sas.h5
2 files changed, 27 insertions, 50 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",
699sas_expander_simple_attr(level, level, "%d\n", int); 699sas_expander_simple_attr(level, level, "%d\n", int);
700 700
701static DECLARE_TRANSPORT_CLASS(sas_rphy_class, 701static DECLARE_TRANSPORT_CLASS(sas_rphy_class,
702 "sas_rphy", NULL, NULL, NULL); 702 "sas_device", NULL, NULL, NULL);
703 703
704static int sas_rphy_match(struct attribute_container *cont, struct device *dev) 704static 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
748static int sas_expander_match(struct attribute_container *cont, 746static 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
774static void sas_rphy_release(struct device *dev) 770static 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/** 779static 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 */
791struct 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}
811EXPORT_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}
955EXPORT_SYMBOL(sas_rphy_free); 936EXPORT_SYMBOL(sas_rphy_free);
956 937
@@ -1003,7 +984,8 @@ EXPORT_SYMBOL(sas_rphy_delete);
1003 */ 984 */
1004int scsi_is_sas_rphy(const struct device *dev) 985int 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}
1008EXPORT_SYMBOL(scsi_is_sas_rphy); 990EXPORT_SYMBOL(scsi_is_sas_rphy);
1009 991
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h
index 2943ccc22a43..93cfb4bf4211 100644
--- a/include/scsi/scsi_transport_sas.h
+++ b/include/scsi/scsi_transport_sas.h
@@ -82,10 +82,6 @@ struct sas_rphy {
82 struct sas_identify identify; 82 struct sas_identify identify;
83 struct list_head list; 83 struct list_head list;
84 u32 scsi_target_id; 84 u32 scsi_target_id;
85 /* temporary expedient: mark the rphy as being contained
86 * within a type specific rphy
87 * FIXME: pull this out when everything uses the containers */
88 unsigned contained:1;
89}; 85};
90 86
91#define dev_to_rphy(d) \ 87#define dev_to_rphy(d) \
@@ -145,7 +141,6 @@ extern int sas_phy_add(struct sas_phy *);
145extern void sas_phy_delete(struct sas_phy *); 141extern void sas_phy_delete(struct sas_phy *);
146extern int scsi_is_sas_phy(const struct device *); 142extern int scsi_is_sas_phy(const struct device *);
147 143
148extern struct sas_rphy *sas_rphy_alloc(struct sas_phy *);
149extern struct sas_rphy *sas_end_device_alloc(struct sas_phy *); 144extern struct sas_rphy *sas_end_device_alloc(struct sas_phy *);
150extern struct sas_rphy *sas_expander_alloc(struct sas_phy *, enum sas_device_type); 145extern struct sas_rphy *sas_expander_alloc(struct sas_phy *, enum sas_device_type);
151void sas_rphy_free(struct sas_rphy *); 146void sas_rphy_free(struct sas_rphy *);