phy->phy_state == PHY_NOT_PRESENT)
                        continue;
 
-               if (SAS_ADDR(phy->attached_sas_addr) ==
-                   SAS_ADDR(child->sas_addr)) {
-
+               if (sas_phy_match_dev_addr(child, phy)) {
                        child->min_linkrate = min(parent->min_linkrate,
                                                  phy->linkrate);
                        child->max_linkrate = max(parent->max_linkrate,
                sas_add_parent_port(dev, phy_id);
                return 0;
        }
-       if (dev->parent && (SAS_ADDR(ex_phy->attached_sas_addr) ==
-                           SAS_ADDR(dev->parent->sas_addr))) {
+       if (dev->parent && sas_phy_match_dev_addr(dev->parent, ex_phy)) {
                sas_add_parent_port(dev, phy_id);
                if (ex_phy->routing_attr == TABLE_ROUTING)
                        sas_configure_phy(dev, phy_id, dev->port->sas_addr, 1);
                    parent_phy->phy_state == PHY_NOT_PRESENT)
                        continue;
 
-               if (SAS_ADDR(parent_phy->attached_sas_addr) != SAS_ADDR(child->sas_addr))
+               if (!sas_phy_match_dev_addr(child, parent_phy))
                        continue;
 
                child_phy = &child_ex->ex_phy[parent_phy->attached_phy_id];
                struct ex_phy *phy = &ex_parent->ex_phy[i];
 
                if ((phy->routing_attr == TABLE_ROUTING) &&
-                   (SAS_ADDR(phy->attached_sas_addr) ==
-                    SAS_ADDR(child->sas_addr))) {
+                   sas_phy_match_dev_addr(child, phy)) {
                        res = sas_configure_phy(parent, i, sas_addr, include);
                        if (res)
                                return res;
        if (last) {
                list_for_each_entry_safe(child, n,
                        &ex_dev->children, siblings) {
-                       if (SAS_ADDR(child->sas_addr) ==
-                           SAS_ADDR(phy->attached_sas_addr)) {
+                       if (sas_phy_match_dev_addr(child, phy)) {
                                set_bit(SAS_DEV_GONE, &child->state);
                                if (dev_is_expander(child->dev_type))
                                        sas_unregister_ex_tree(parent->port, child);
        if (res)
                return res;
        list_for_each_entry(child, &dev->ex_dev.children, siblings) {
-               if (SAS_ADDR(child->sas_addr) ==
-                   SAS_ADDR(ex_phy->attached_sas_addr)) {
+               if (sas_phy_match_dev_addr(child, ex_phy)) {
                        if (dev_is_expander(child->dev_type))
                                res = sas_discover_bfs_by_root(child);
                        break;