Skip to content

Commit a573452

Browse files
Xingui Yangmartinkpetersen
authored andcommitted
scsi: libsas: Add a helper sas_get_sas_addr_and_dev_type()
Add a helper to get attached_sas_addr and device type from disc_resp. Suggested-by: John Garry <[email protected]> Signed-off-by: Xingui Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: John Garry <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 99cfb21 commit a573452

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

drivers/scsi/libsas/sas_expander.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,16 @@ int sas_discover_root_expander(struct domain_device *dev)
16211621

16221622
/* ---------- Domain revalidation ---------- */
16231623

1624+
static void sas_get_sas_addr_and_dev_type(struct smp_disc_resp *disc_resp,
1625+
u8 *sas_addr,
1626+
enum sas_device_type *type)
1627+
{
1628+
memcpy(sas_addr, disc_resp->disc.attached_sas_addr, SAS_ADDR_SIZE);
1629+
*type = to_dev_type(&disc_resp->disc);
1630+
if (*type == SAS_PHY_UNUSED)
1631+
memset(sas_addr, 0, SAS_ADDR_SIZE);
1632+
}
1633+
16241634
static int sas_get_phy_discover(struct domain_device *dev,
16251635
int phy_id, struct smp_disc_resp *disc_resp)
16261636
{
@@ -1674,13 +1684,8 @@ int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id,
16741684
return -ENOMEM;
16751685

16761686
res = sas_get_phy_discover(dev, phy_id, disc_resp);
1677-
if (res == 0) {
1678-
memcpy(sas_addr, disc_resp->disc.attached_sas_addr,
1679-
SAS_ADDR_SIZE);
1680-
*type = to_dev_type(&disc_resp->disc);
1681-
if (*type == 0)
1682-
memset(sas_addr, 0, SAS_ADDR_SIZE);
1683-
}
1687+
if (res == 0)
1688+
sas_get_sas_addr_and_dev_type(disc_resp, sas_addr, type);
16841689
kfree(disc_resp);
16851690
return res;
16861691
}

0 commit comments

Comments
 (0)