]>
Commit | Line | Data |
---|---|---|
dc7572bc SL |
1 | From e2e6c1ea15d971a9a50863782b72e934c2ff46b5 Mon Sep 17 00:00:00 2001 |
2 | From: Sasha Levin <sashal@kernel.org> | |
3 | Date: Thu, 7 Mar 2024 14:14:12 +0000 | |
4 | Subject: scsi: libsas: Add a helper sas_get_sas_addr_and_dev_type() | |
5 | ||
6 | From: Xingui Yang <yangxingui@huawei.com> | |
7 | ||
8 | [ Upstream commit a57345279fd311ba679b8083feb0eec5272c7729 ] | |
9 | ||
10 | Add a helper to get attached_sas_addr and device type from disc_resp. | |
11 | ||
12 | Suggested-by: John Garry <john.g.garry@oracle.com> | |
13 | Signed-off-by: Xingui Yang <yangxingui@huawei.com> | |
14 | Link: https://lore.kernel.org/r/20240307141413.48049-2-yangxingui@huawei.com | |
15 | Reviewed-by: John Garry <john.g.garry@oracle.com> | |
16 | Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> | |
17 | Stable-dep-of: 8e68a458bcf5 ("scsi: libsas: Fix disk not being scanned in after being removed") | |
18 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
19 | --- | |
20 | drivers/scsi/libsas/sas_expander.c | 19 ++++++++++++------- | |
21 | 1 file changed, 12 insertions(+), 7 deletions(-) | |
22 | ||
23 | diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c | |
24 | index 8b061347a8ac7..a673a08c72126 100644 | |
25 | --- a/drivers/scsi/libsas/sas_expander.c | |
26 | +++ b/drivers/scsi/libsas/sas_expander.c | |
27 | @@ -1672,6 +1672,16 @@ int sas_discover_root_expander(struct domain_device *dev) | |
28 | ||
29 | /* ---------- Domain revalidation ---------- */ | |
30 | ||
31 | +static void sas_get_sas_addr_and_dev_type(struct smp_disc_resp *disc_resp, | |
32 | + u8 *sas_addr, | |
33 | + enum sas_device_type *type) | |
34 | +{ | |
35 | + memcpy(sas_addr, disc_resp->disc.attached_sas_addr, SAS_ADDR_SIZE); | |
36 | + *type = to_dev_type(&disc_resp->disc); | |
37 | + if (*type == SAS_PHY_UNUSED) | |
38 | + memset(sas_addr, 0, SAS_ADDR_SIZE); | |
39 | +} | |
40 | + | |
41 | static int sas_get_phy_discover(struct domain_device *dev, | |
42 | int phy_id, struct smp_disc_resp *disc_resp) | |
43 | { | |
44 | @@ -1725,13 +1735,8 @@ static int sas_get_phy_attached_dev(struct domain_device *dev, int phy_id, | |
45 | return -ENOMEM; | |
46 | ||
47 | res = sas_get_phy_discover(dev, phy_id, disc_resp); | |
48 | - if (res == 0) { | |
49 | - memcpy(sas_addr, disc_resp->disc.attached_sas_addr, | |
50 | - SAS_ADDR_SIZE); | |
51 | - *type = to_dev_type(&disc_resp->disc); | |
52 | - if (*type == 0) | |
53 | - memset(sas_addr, 0, SAS_ADDR_SIZE); | |
54 | - } | |
55 | + if (res == 0) | |
56 | + sas_get_sas_addr_and_dev_type(disc_resp, sas_addr, type); | |
57 | kfree(disc_resp); | |
58 | return res; | |
59 | } | |
60 | -- | |
61 | 2.43.0 | |
62 |