diff options
author | John Garry <john.garry@huawei.com> | 2019-06-10 08:41:41 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2019-06-20 15:37:02 -0400 |
commit | 924a3541eab0d28101baf0831e4315593f06ba4a (patch) | |
tree | da4ef5d394c324e91279650a8cc4ee34da7b3694 /drivers/scsi/libsas | |
parent | 895d8860a1a9b13ebddccb76a70faf4c01081699 (diff) |
scsi: libsas: aic94xx: hisi_sas: mvsas: pm8001: Use dev_is_expander()
Many times in libsas, and in LLDDs which use libsas, the check for an
expander device is re-implemented or open coded.
Use dev_is_expander() instead. We rename this from
sas_dev_type_is_expander() to not spill so many lines in referencing.
Signed-off-by: John Garry <john.garry@huawei.com>
Reviewed-by: Jason Yan <yanaijie@huawei.com>
Reviewed-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/libsas')
-rw-r--r-- | drivers/scsi/libsas/sas_discover.c | 5 | ||||
-rw-r--r-- | drivers/scsi/libsas/sas_expander.c | 29 | ||||
-rw-r--r-- | drivers/scsi/libsas/sas_port.c | 6 |
3 files changed, 15 insertions, 25 deletions
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c index 2518cecb7edf..abcad097ff2f 100644 --- a/drivers/scsi/libsas/sas_discover.c +++ b/drivers/scsi/libsas/sas_discover.c | |||
@@ -293,7 +293,7 @@ void sas_free_device(struct kref *kref) | |||
293 | dev->phy = NULL; | 293 | dev->phy = NULL; |
294 | 294 | ||
295 | /* remove the phys and ports, everything else should be gone */ | 295 | /* remove the phys and ports, everything else should be gone */ |
296 | if (dev->dev_type == SAS_EDGE_EXPANDER_DEVICE || dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE) | 296 | if (dev_is_expander(dev->dev_type)) |
297 | kfree(dev->ex_dev.ex_phy); | 297 | kfree(dev->ex_dev.ex_phy); |
298 | 298 | ||
299 | if (dev_is_sata(dev) && dev->sata_dev.ap) { | 299 | if (dev_is_sata(dev) && dev->sata_dev.ap) { |
@@ -503,8 +503,7 @@ static void sas_revalidate_domain(struct work_struct *work) | |||
503 | pr_debug("REVALIDATING DOMAIN on port %d, pid:%d\n", port->id, | 503 | pr_debug("REVALIDATING DOMAIN on port %d, pid:%d\n", port->id, |
504 | task_pid_nr(current)); | 504 | task_pid_nr(current)); |
505 | 505 | ||
506 | if (ddev && (ddev->dev_type == SAS_FANOUT_EXPANDER_DEVICE || | 506 | if (ddev && dev_is_expander(ddev->dev_type)) |
507 | ddev->dev_type == SAS_EDGE_EXPANDER_DEVICE)) | ||
508 | res = sas_ex_revalidate_domain(ddev); | 507 | res = sas_ex_revalidate_domain(ddev); |
509 | 508 | ||
510 | pr_debug("done REVALIDATING DOMAIN on port %d, pid:%d, res 0x%x\n", | 509 | pr_debug("done REVALIDATING DOMAIN on port %d, pid:%d, res 0x%x\n", |
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index fd16a3debef4..ecae55f117a3 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c | |||
@@ -1120,8 +1120,7 @@ static int sas_find_sub_addr(struct domain_device *dev, u8 *sub_addr) | |||
1120 | phy->phy_state == PHY_NOT_PRESENT) | 1120 | phy->phy_state == PHY_NOT_PRESENT) |
1121 | continue; | 1121 | continue; |
1122 | 1122 | ||
1123 | if ((phy->attached_dev_type == SAS_EDGE_EXPANDER_DEVICE || | 1123 | if (dev_is_expander(phy->attached_dev_type) && |
1124 | phy->attached_dev_type == SAS_FANOUT_EXPANDER_DEVICE) && | ||
1125 | phy->routing_attr == SUBTRACTIVE_ROUTING) { | 1124 | phy->routing_attr == SUBTRACTIVE_ROUTING) { |
1126 | 1125 | ||
1127 | memcpy(sub_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); | 1126 | memcpy(sub_addr, phy->attached_sas_addr, SAS_ADDR_SIZE); |
@@ -1139,8 +1138,7 @@ static int sas_check_level_subtractive_boundary(struct domain_device *dev) | |||
1139 | u8 sub_addr[SAS_ADDR_SIZE] = {0, }; | 1138 | u8 sub_addr[SAS_ADDR_SIZE] = {0, }; |
1140 | 1139 | ||
1141 | list_for_each_entry(child, &ex->children, siblings) { | 1140 | list_for_each_entry(child, &ex->children, siblings) { |
1142 | if (child->dev_type != SAS_EDGE_EXPANDER_DEVICE && | 1141 | if (!dev_is_expander(child->dev_type)) |
1143 | child->dev_type != SAS_FANOUT_EXPANDER_DEVICE) | ||
1144 | continue; | 1142 | continue; |
1145 | if (sub_addr[0] == 0) { | 1143 | if (sub_addr[0] == 0) { |
1146 | sas_find_sub_addr(child, sub_addr); | 1144 | sas_find_sub_addr(child, sub_addr); |
@@ -1225,8 +1223,7 @@ static int sas_check_ex_subtractive_boundary(struct domain_device *dev) | |||
1225 | phy->phy_state == PHY_NOT_PRESENT) | 1223 | phy->phy_state == PHY_NOT_PRESENT) |
1226 | continue; | 1224 | continue; |
1227 | 1225 | ||
1228 | if ((phy->attached_dev_type == SAS_FANOUT_EXPANDER_DEVICE || | 1226 | if (dev_is_expander(phy->attached_dev_type) && |
1229 | phy->attached_dev_type == SAS_EDGE_EXPANDER_DEVICE) && | ||
1230 | phy->routing_attr == SUBTRACTIVE_ROUTING) { | 1227 | phy->routing_attr == SUBTRACTIVE_ROUTING) { |
1231 | 1228 | ||
1232 | if (!sub_sas_addr) | 1229 | if (!sub_sas_addr) |
@@ -1322,8 +1319,7 @@ static int sas_check_parent_topology(struct domain_device *child) | |||
1322 | if (!child->parent) | 1319 | if (!child->parent) |
1323 | return 0; | 1320 | return 0; |
1324 | 1321 | ||
1325 | if (child->parent->dev_type != SAS_EDGE_EXPANDER_DEVICE && | 1322 | if (!dev_is_expander(child->parent->dev_type)) |
1326 | child->parent->dev_type != SAS_FANOUT_EXPANDER_DEVICE) | ||
1327 | return 0; | 1323 | return 0; |
1328 | 1324 | ||
1329 | parent_ex = &child->parent->ex_dev; | 1325 | parent_ex = &child->parent->ex_dev; |
@@ -1619,8 +1615,7 @@ static int sas_ex_level_discovery(struct asd_sas_port *port, const int level) | |||
1619 | struct domain_device *dev; | 1615 | struct domain_device *dev; |
1620 | 1616 | ||
1621 | list_for_each_entry(dev, &port->dev_list, dev_list_node) { | 1617 | list_for_each_entry(dev, &port->dev_list, dev_list_node) { |
1622 | if (dev->dev_type == SAS_EDGE_EXPANDER_DEVICE || | 1618 | if (dev_is_expander(dev->dev_type)) { |
1623 | dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE) { | ||
1624 | struct sas_expander_device *ex = | 1619 | struct sas_expander_device *ex = |
1625 | rphy_to_expander_device(dev->rphy); | 1620 | rphy_to_expander_device(dev->rphy); |
1626 | 1621 | ||
@@ -1852,7 +1847,7 @@ static int sas_find_bcast_dev(struct domain_device *dev, | |||
1852 | SAS_ADDR(dev->sas_addr)); | 1847 | SAS_ADDR(dev->sas_addr)); |
1853 | } | 1848 | } |
1854 | list_for_each_entry(ch, &ex->children, siblings) { | 1849 | list_for_each_entry(ch, &ex->children, siblings) { |
1855 | if (ch->dev_type == SAS_EDGE_EXPANDER_DEVICE || ch->dev_type == SAS_FANOUT_EXPANDER_DEVICE) { | 1850 | if (dev_is_expander(ch->dev_type)) { |
1856 | res = sas_find_bcast_dev(ch, src_dev); | 1851 | res = sas_find_bcast_dev(ch, src_dev); |
1857 | if (*src_dev) | 1852 | if (*src_dev) |
1858 | return res; | 1853 | return res; |
@@ -1869,8 +1864,7 @@ static void sas_unregister_ex_tree(struct asd_sas_port *port, struct domain_devi | |||
1869 | 1864 | ||
1870 | list_for_each_entry_safe(child, n, &ex->children, siblings) { | 1865 | list_for_each_entry_safe(child, n, &ex->children, siblings) { |
1871 | set_bit(SAS_DEV_GONE, &child->state); | 1866 | set_bit(SAS_DEV_GONE, &child->state); |
1872 | if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE || | 1867 | if (dev_is_expander(child->dev_type)) |
1873 | child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) | ||
1874 | sas_unregister_ex_tree(port, child); | 1868 | sas_unregister_ex_tree(port, child); |
1875 | else | 1869 | else |
1876 | sas_unregister_dev(port, child); | 1870 | sas_unregister_dev(port, child); |
@@ -1890,8 +1884,7 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent, | |||
1890 | if (SAS_ADDR(child->sas_addr) == | 1884 | if (SAS_ADDR(child->sas_addr) == |
1891 | SAS_ADDR(phy->attached_sas_addr)) { | 1885 | SAS_ADDR(phy->attached_sas_addr)) { |
1892 | set_bit(SAS_DEV_GONE, &child->state); | 1886 | set_bit(SAS_DEV_GONE, &child->state); |
1893 | if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE || | 1887 | if (dev_is_expander(child->dev_type)) |
1894 | child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) | ||
1895 | sas_unregister_ex_tree(parent->port, child); | 1888 | sas_unregister_ex_tree(parent->port, child); |
1896 | else | 1889 | else |
1897 | sas_unregister_dev(parent->port, child); | 1890 | sas_unregister_dev(parent->port, child); |
@@ -1920,8 +1913,7 @@ static int sas_discover_bfs_by_root_level(struct domain_device *root, | |||
1920 | int res = 0; | 1913 | int res = 0; |
1921 | 1914 | ||
1922 | list_for_each_entry(child, &ex_root->children, siblings) { | 1915 | list_for_each_entry(child, &ex_root->children, siblings) { |
1923 | if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE || | 1916 | if (dev_is_expander(child->dev_type)) { |
1924 | child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) { | ||
1925 | struct sas_expander_device *ex = | 1917 | struct sas_expander_device *ex = |
1926 | rphy_to_expander_device(child->rphy); | 1918 | rphy_to_expander_device(child->rphy); |
1927 | 1919 | ||
@@ -1974,8 +1966,7 @@ static int sas_discover_new(struct domain_device *dev, int phy_id) | |||
1974 | list_for_each_entry(child, &dev->ex_dev.children, siblings) { | 1966 | list_for_each_entry(child, &dev->ex_dev.children, siblings) { |
1975 | if (SAS_ADDR(child->sas_addr) == | 1967 | if (SAS_ADDR(child->sas_addr) == |
1976 | SAS_ADDR(ex_phy->attached_sas_addr)) { | 1968 | SAS_ADDR(ex_phy->attached_sas_addr)) { |
1977 | if (child->dev_type == SAS_EDGE_EXPANDER_DEVICE || | 1969 | if (dev_is_expander(child->dev_type)) |
1978 | child->dev_type == SAS_FANOUT_EXPANDER_DEVICE) | ||
1979 | res = sas_discover_bfs_by_root(child); | 1970 | res = sas_discover_bfs_by_root(child); |
1980 | break; | 1971 | break; |
1981 | } | 1972 | } |
diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c index 11f028a441dd..7c86fd248129 100644 --- a/drivers/scsi/libsas/sas_port.c +++ b/drivers/scsi/libsas/sas_port.c | |||
@@ -54,7 +54,7 @@ static void sas_resume_port(struct asd_sas_phy *phy) | |||
54 | continue; | 54 | continue; |
55 | } | 55 | } |
56 | 56 | ||
57 | if (dev->dev_type == SAS_EDGE_EXPANDER_DEVICE || dev->dev_type == SAS_FANOUT_EXPANDER_DEVICE) { | 57 | if (dev_is_expander(dev->dev_type)) { |
58 | dev->ex_dev.ex_change_count = -1; | 58 | dev->ex_dev.ex_change_count = -1; |
59 | for (i = 0; i < dev->ex_dev.num_phys; i++) { | 59 | for (i = 0; i < dev->ex_dev.num_phys; i++) { |
60 | struct ex_phy *phy = &dev->ex_dev.ex_phy[i]; | 60 | struct ex_phy *phy = &dev->ex_dev.ex_phy[i]; |
@@ -179,7 +179,7 @@ static void sas_form_port(struct asd_sas_phy *phy) | |||
179 | 179 | ||
180 | sas_discover_event(phy->port, DISCE_DISCOVER_DOMAIN); | 180 | sas_discover_event(phy->port, DISCE_DISCOVER_DOMAIN); |
181 | /* Only insert a revalidate event after initial discovery */ | 181 | /* Only insert a revalidate event after initial discovery */ |
182 | if (port_dev && sas_dev_type_is_expander(port_dev->dev_type)) { | 182 | if (port_dev && dev_is_expander(port_dev->dev_type)) { |
183 | struct expander_device *ex_dev = &port_dev->ex_dev; | 183 | struct expander_device *ex_dev = &port_dev->ex_dev; |
184 | 184 | ||
185 | ex_dev->ex_change_count = -1; | 185 | ex_dev->ex_change_count = -1; |
@@ -248,7 +248,7 @@ void sas_deform_port(struct asd_sas_phy *phy, int gone) | |||
248 | spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags); | 248 | spin_unlock_irqrestore(&sas_ha->phy_port_lock, flags); |
249 | 249 | ||
250 | /* Only insert revalidate event if the port still has members */ | 250 | /* Only insert revalidate event if the port still has members */ |
251 | if (port->port && dev && sas_dev_type_is_expander(dev->dev_type)) { | 251 | if (port->port && dev && dev_is_expander(dev->dev_type)) { |
252 | struct expander_device *ex_dev = &dev->ex_dev; | 252 | struct expander_device *ex_dev = &dev->ex_dev; |
253 | 253 | ||
254 | ex_dev->ex_change_count = -1; | 254 | ex_dev->ex_change_count = -1; |