If the phy is attached to a new sas address unregister the first address
before processing the new attachment.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
                return res;
        }
 
+       /* delete the old link */
+       if (SAS_ADDR(phy->attached_sas_addr) &&
+           SAS_ADDR(sas_addr) != SAS_ADDR(phy->attached_sas_addr)) {
+               SAS_DPRINTK("ex %016llx phy 0x%x replace %016llx\n",
+                           SAS_ADDR(dev->sas_addr), phy_id,
+                           SAS_ADDR(phy->attached_sas_addr));
+               sas_unregister_devs_sas_addr(dev, phy_id, last);
+       }
+
        return sas_discover_new(dev, phy_id);
 }