diff options
author | Xingui Yang <yangxingui@huawei.com> | 2024-03-07 14:14:12 +0000 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2024-03-10 18:02:53 -0400 |
commit | a57345279fd311ba679b8083feb0eec5272c7729 (patch) | |
tree | 100061e40fa63b47f69a6cb80c97e7e82a135519 /drivers/scsi | |
parent | 99cfb212ef4d04515efcd88fd05cd9cdff4f9542 (diff) | |
download | linux-stable-a57345279fd311ba679b8083feb0eec5272c7729.tar.gz linux-stable-a57345279fd311ba679b8083feb0eec5272c7729.tar.bz2 linux-stable-a57345279fd311ba679b8083feb0eec5272c7729.zip |
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 <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>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/libsas/sas_expander.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index a2204674b680..de9dee488277 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -1621,6 +1621,16 @@ out_err: /* ---------- 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) { @@ -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; } |