]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - queue-5.10/scsi-libsas-add-a-helper-sas_get_sas_addr_and_dev_ty.patch
5.10-stable patches
[thirdparty/kernel/stable-queue.git] / queue-5.10 / scsi-libsas-add-a-helper-sas_get_sas_addr_and_dev_ty.patch
CommitLineData
dc7572bc
SL
1From e2e6c1ea15d971a9a50863782b72e934c2ff46b5 Mon Sep 17 00:00:00 2001
2From: Sasha Levin <sashal@kernel.org>
3Date: Thu, 7 Mar 2024 14:14:12 +0000
4Subject: scsi: libsas: Add a helper sas_get_sas_addr_and_dev_type()
5
6From: Xingui Yang <yangxingui@huawei.com>
7
8[ Upstream commit a57345279fd311ba679b8083feb0eec5272c7729 ]
9
10Add a helper to get attached_sas_addr and device type from disc_resp.
11
12Suggested-by: John Garry <john.g.garry@oracle.com>
13Signed-off-by: Xingui Yang <yangxingui@huawei.com>
14Link: https://lore.kernel.org/r/20240307141413.48049-2-yangxingui@huawei.com
15Reviewed-by: John Garry <john.g.garry@oracle.com>
16Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
17Stable-dep-of: 8e68a458bcf5 ("scsi: libsas: Fix disk not being scanned in after being removed")
18Signed-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
23diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
24index 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--
612.43.0
62