Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp341404rwb; Mon, 26 Sep 2022 20:18:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5SQYY6ITzh4Of+3B8oln7ZDp30n+dJvpm8GKvONa1mo/0N5CtIxlrTuLdmbhJqWegTOvxW X-Received: by 2002:a05:6402:2693:b0:450:a807:6c91 with SMTP id w19-20020a056402269300b00450a8076c91mr26011470edd.33.1664248706290; Mon, 26 Sep 2022 20:18:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664248706; cv=none; d=google.com; s=arc-20160816; b=v8OqRNADWoiWl5zhzqi8qouxZVTysGp0SA9ujEn//6SEbZF4ERGO8YLE8Z7eUq2jKF SaiFcIHNYj6qAL3zufCwwzmAD+GLIrKDa/iKK/j61URrQe4MWxN+mBtJVyDgPjrB1XmU /HP3lH7ok9IsMQYRMOpp4lKzgyP8bqmDTn3ALS0P5H1jUNZ6iJV8XeAFmuxJPYPk4Ztn qw+Ip0HXiXgUSyxLdhq0I8472OYdpdpc1nlzyiNcGS/VVZj4jyT/Ir66fwH+0CBulhZ2 1zzBss5a4dEmZ3LRDm4o+vra5WZsINR3/DGtkomnC1Ytcmo7p8xWCCmohAiZO6+IRmb9 1CQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=een6kpiNo7+KlkdIGssUDRMnItV6J2zvhunGJQBKyjk=; b=Brv8SYfw+OFHotbpCBGuDsz3x632ybnti3iQAxZ8i5zYH7j1sYjoymxVnFDTLCdA+5 vLCWvBz6nQRZKenSB4YOINYeUstk7o/Np0HGbUEqshA0qgUMdOj0tyyvklTmypqJU9p8 ldMa9btDW6qD2k0GOoWBnCj5n2Dl6NqiwEMrZgRSoypX1VMqIa7/uEZXZiYkHvxKQCvn 5a27HkCp5vJdfXN3x7PhLmsrP0O6dmo7hA+375KU1ZMrLVGcePmCO5V+vcR56CKfTybS D2zoSEG2+m7eTrCEq3wp8SuVph18Beq90HnYZjvCpTAHli378gn8h8v7+h/OoYM9DxSm wIqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n26-20020aa7c45a000000b0045102ae16dasi501966edr.198.2022.09.26.20.17.57; Mon, 26 Sep 2022 20:18:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231506AbiI0DQt (ORCPT + 99 others); Mon, 26 Sep 2022 23:16:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231245AbiI0DQA (ORCPT ); Mon, 26 Sep 2022 23:16:00 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C2C357BEC; Mon, 26 Sep 2022 20:15:37 -0700 (PDT) Received: from canpemm500004.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Mc4Qc6Wbnz1P6lc; Tue, 27 Sep 2022 11:11:20 +0800 (CST) Received: from huawei.com (10.175.127.227) by canpemm500004.china.huawei.com (7.192.104.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 27 Sep 2022 11:15:28 +0800 From: Jason Yan To: , CC: , , , , , , , , Jason Yan Subject: [PATCH v4 1/8] scsi: libsas: introduce sas address comparison helpers Date: Tue, 27 Sep 2022 11:25:58 +0800 Message-ID: <20220927032605.78103-2-yanaijie@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220927032605.78103-1-yanaijie@huawei.com> References: <20220927032605.78103-1-yanaijie@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To canpemm500004.china.huawei.com (7.192.104.92) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sas address comparison is widely used in libsas. However they are all opencoded and to avoid the line spill over 80 columns, are mostly split into multi-lines. Introduce some helpers to prepare some refactor. Signed-off-by: Jason Yan Reviewed-by: Damien Le Moal --- drivers/scsi/libsas/sas_internal.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h index 8d0ad3abc7b5..3384429b7eb0 100644 --- a/drivers/scsi/libsas/sas_internal.h +++ b/drivers/scsi/libsas/sas_internal.h @@ -111,6 +111,23 @@ static inline void sas_smp_host_handler(struct bsg_job *job, } #endif +static inline bool sas_phy_match_dev_addr(struct domain_device *dev, + struct ex_phy *phy) +{ + return SAS_ADDR(dev->sas_addr) == SAS_ADDR(phy->attached_sas_addr); +} + +static inline bool sas_phy_match_port_addr(struct asd_sas_port *port, + struct ex_phy *phy) +{ + return SAS_ADDR(port->sas_addr) == SAS_ADDR(phy->attached_sas_addr); +} + +static inline bool sas_phy_addr_match(struct ex_phy *p1, struct ex_phy *p2) +{ + return SAS_ADDR(p1->attached_sas_addr) == SAS_ADDR(p2->attached_sas_addr); +} + static inline void sas_fail_probe(struct domain_device *dev, const char *func, int err) { pr_warn("%s: for %s device %016llx returned %d\n", -- 2.31.1