Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp441111lqi; Thu, 7 Mar 2024 01:40:11 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU4Bd6Xuo2TGkiePjY5l1aKolrUt/h995MeIIz9b4wqitwkB7Yhdn1M+mb0Sxo0Dxv4CXLaoZCYDdI/Rqiod2lmUCqukWHaFb+UToKb2w== X-Google-Smtp-Source: AGHT+IGDDceF0GFO5rSdFxlDXEXE1+q65YshiZoWScmaVZPsE1vGMEc7Nlaoj2SNiXKDLT0HF/DF X-Received: by 2002:a17:906:abd6:b0:a45:66c8:26ae with SMTP id kq22-20020a170906abd600b00a4566c826aemr7563699ejb.33.1709804411097; Thu, 07 Mar 2024 01:40:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709804411; cv=pass; d=google.com; s=arc-20160816; b=QS7zwZyuXeUK7i/8OHqJ4H8ckwyfoA3GO6mpIc2Q0OPUTnUUiQvi9Ap0K0+e+g+ue3 69Cl6My2AUjG9xQtoPicNkVlWhTbRnLvmDFL254RmnsiDBUV+ZXwUQ/9sYVDCkCa4rq7 q1ZG3zbuTl1XeJPaiwVmR1XLUPWWqsymYCG/VJsJObRqO4jgsJUhNM5fzdvJnc9ac8rR QH0TB0kepJ2kUZgerBPfqNtGmqk2yLDwDA51N2UjfvGYrHI7wfaOh+gvEtjBMUP+YbZW YCx4n2iIUaHdPP+8tGhs/qWgDtJUEYYFo/5zooHmhIcl2lxIjdYfiVQmNlTiDKGucIN6 p0sg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iDAp9yxSdjeYFq6U7K4F0YC2/WPiXDDbgd74KlBhDgI=; fh=PKov2v7mtZqWrG2ToL14QCqscLF6oofVifdomTnOWI8=; b=q85L3C01j5oD/svrQ4o0wFmznLGJvpOZCzNpPK4XlOzEnJL3jgpxX8rTYPrMcdh/oJ PRpULH/byB+cI26N0tB+y64oxYmcStRh954OgHWep44shcqVzCxkbI46dxJP7sVhIyk2 gorrLAvxleFP5hRvJVhY9j253HxG8l2FY1no1a7iWEqtxfx5RLZQuB/Jwt2O2Cgd8omr 0CGItnNU54ovcPbaRQ+xXA2Z7weyDsDy16MRdPsFWP6lZYqKW+A1gZ82PdzxubYzP12u wE/EHNN1oi4iDQbILLi8bUVUcmQytg5Z3NuffzsBfGufuOKfIctAfqNvvwk49uf/MbgP Aj2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-95239-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95239-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a24-20020a1709064a5800b00a43838cbd7csi6604720ejv.148.2024.03.07.01.40.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 01:40:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95239-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-95239-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95239-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CF7031F2B1D4 for ; Thu, 7 Mar 2024 09:40:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F75E84FB3; Thu, 7 Mar 2024 09:39:15 +0000 (UTC) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88C4D83CDD; Thu, 7 Mar 2024 09:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709804354; cv=none; b=Tc9pwqhZiPrT2A0Tjw2yA5kCTFhrHBfaERRHIr6lDKnoeHL+zWnK+OVDDhjMXFEWGRNK9RcXJOke3NhymTmlWsyR0cOc411EIbvrj8auapoi37LQ5k0a2mowp31BBYBlfxnbIwOfMQGwrn38bPwHY5KOAoT2/oX/rGBqx1iO6F0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709804354; c=relaxed/simple; bh=6/g2twa7SZ1wwd/bmFk+LdlNvEtLHm/7fgAKyqC66rw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TwOLvQJrYqB644OxuFh9U78ZkBrsDMnSg3br8/ErPGT+A3/yMEmu8dgpoEh7OGZF/ezUSHlcn79mGxQEt7+OsISIGucFmxObdJj5bbLJ/tlgWnsxV7NQAFiQfDPzByGEO5KDL6b2oqD5jTYbrVwLf5e2ZRi+RjUXbApMMXHvpVk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4Tr426209Gz1QB5g; Thu, 7 Mar 2024 17:36:46 +0800 (CST) Received: from dggpemd100001.china.huawei.com (unknown [7.185.36.94]) by mail.maildlp.com (Postfix) with ESMTPS id 936AC1402CA; Thu, 7 Mar 2024 17:39:08 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by dggpemd100001.china.huawei.com (7.185.36.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Thu, 7 Mar 2024 17:39:08 +0800 From: Xingui Yang To: , , , , CC: , , , , , Subject: [PATCH v3 2/3] scsi: libsas: Add a helper sas_get_sas_addr_and_dev_type() Date: Thu, 7 Mar 2024 09:37:32 +0000 Message-ID: <20240307093733.41222-3-yangxingui@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240307093733.41222-1-yangxingui@huawei.com> References: <20240307093733.41222-1-yangxingui@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemd100001.china.huawei.com (7.185.36.94) Add a helper to get attached_sas_addr and device type from disc_resp. Suggested-by: John Garry Signed-off-by: Xingui Yang --- drivers/scsi/libsas/sas_expander.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 1eeb69cba8da..d6147616339f 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c @@ -1631,6 +1631,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) { @@ -1684,13 +1694,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; } -- 2.17.1