Skip to content

Commit

Permalink
scsi: libsas: Add a helper sas_get_sas_addr_and_dev_type()
Browse files Browse the repository at this point in the history
commit a573452 upstream.

Add a helper to get attached_sas_addr and device type from disc_resp.

Suggested-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Xingui Yang <yangxingui@huawei.com>
Link: https://lore.kernel.org/r/20240307141413.48049-2-yangxingui@huawei.com
Reviewed-by: John Garry <john.g.garry@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Xingui Yang authored and gregkh committed Apr 3, 2024
1 parent 76edb98 commit f23db75
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions drivers/scsi/libsas/sas_expander.c
Expand Up @@ -1621,6 +1621,16 @@ int sas_discover_root_expander(struct domain_device *dev)

/* ---------- Domain revalidation ---------- */

static void sas_get_sas_addr_and_dev_type(struct smp_disc_resp *disc_resp,
u8 *sas_addr,
enum sas_device_type *type)
{
memcpy(sas_addr, disc_resp->disc.attached_sas_addr, SAS_ADDR_SIZE);
*type = to_dev_type(&disc_resp->disc);
if (*type == SAS_PHY_UNUSED)
memset(sas_addr, 0, SAS_ADDR_SIZE);
}

static int sas_get_phy_discover(struct domain_device *dev,
int phy_id, struct smp_disc_resp *disc_resp)
{
Expand Down Expand Up @@ -1674,13 +1684,8 @@ int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id,
return -ENOMEM;

res = sas_get_phy_discover(dev, phy_id, disc_resp);
if (res == 0) {
memcpy(sas_addr, disc_resp->disc.attached_sas_addr,
SAS_ADDR_SIZE);
*type = to_dev_type(&disc_resp->disc);
if (*type == 0)
memset(sas_addr, 0, SAS_ADDR_SIZE);
}
if (res == 0)
sas_get_sas_addr_and_dev_type(disc_resp, sas_addr, type);
kfree(disc_resp);
return res;
}
Expand Down

0 comments on commit f23db75

Please sign in to comment.