Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp192485rwb; Sat, 17 Sep 2022 03:33:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4jWZFdzWahB2dt7q5grPQTn3ueyflFgVxIZF5m53Ywlms97jyLT81qjhmeO/qtQWFW2pPd X-Received: by 2002:a17:90b:3148:b0:203:41c:2124 with SMTP id ip8-20020a17090b314800b00203041c2124mr19704873pjb.223.1663410830521; Sat, 17 Sep 2022 03:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663410830; cv=none; d=google.com; s=arc-20160816; b=BNR2hmC+b/H0yF4nuc7snnrg2eX25d/Hp3F02FXWZNceki96kKEI6ZjNLsSQkz6xx5 y11AuM+JO72RNdzvap9N8cUNfUOnOySfYPAeKWtzS8s19X8u/RHBy95ZZPI0kyMxSr8C bpGDJBArz8YVOqPQcUzRYf+Kd2WYmJTpFY4NUxb0+YNq3UsqaCdpwUKblhkMJ7O/239T itKhgtUITdXdyJAyeh3ABQPY3VmhLA96LiQZXgbzxvjintD2nrmhck9QRewWVCWwBRTo mxkvKJ5BEbi67AGqRJdd2rCHjCXsbv/VwrpwV1rsJvZMnEP0/XsP+pq0hGs+4pqNt7iH cvKQ== 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=81JG8GGePe8BH9usf37FTY6gfLN8xK7ZyE1KPQrDi/g=; b=njNhhijA+Awec9bLYe2g2+S1tz/6Xc3uqa6dN06/zXGISaNPQ4Uh9VLrEEZwHVBwz3 1UNNXAzApLy/4PwhUHIaUDRB/XxNn528lat25XVC7XHEVct8i+QT3/2SxDggqRw5QIb2 6M+RT227ULMIrt9nlFacaGPM3cBEoUxA+o/k90Sb/0BtzNrAzo2Jdjx2rKUBhRQDPuZE K50cfpyTFT4hHfsvmEn2ZzLdkQHGqNDhRfTvS2P16P2vjo0Hn1usnalDvbodDW/bLLUd 9WANadlQFb6n0EXFXcpwJYohuAWgdT2qf2LiIWUnbixcVdimybdZEeCkInk1SWRT43mM rZRA== 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 16-20020a630110000000b00438c9c9708bsi22961522pgb.836.2022.09.17.03.33.39; Sat, 17 Sep 2022 03:33:50 -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 S229648AbiIQKci (ORCPT + 99 others); Sat, 17 Sep 2022 06:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbiIQKc1 (ORCPT ); Sat, 17 Sep 2022 06:32:27 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D462B31348; Sat, 17 Sep 2022 03:32:24 -0700 (PDT) Received: from canpemm500004.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MV6cx53QgzpStj; Sat, 17 Sep 2022 18:29:37 +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; Sat, 17 Sep 2022 18:32:21 +0800 From: Jason Yan To: , CC: , , , , , , , Jason Yan Subject: [PATCH 1/7] scsi: libsas: introduce sas address conversion and comparation helpers Date: Sat, 17 Sep 2022 18:43:05 +0800 Message-ID: <20220917104311.1878250-2-yanaijie@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220917104311.1878250-1-yanaijie@huawei.com> References: <20220917104311.1878250-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: dggems702-chm.china.huawei.com (10.3.19.179) 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 conversion and comparation is widely used in libsas and drivers. 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 --- include/scsi/libsas.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 2dbead74a2af..382aedf31fa4 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -648,6 +648,38 @@ static inline bool sas_is_internal_abort(struct sas_task *task) return task->task_proto == SAS_PROTOCOL_INTERNAL_ABORT; } +static inline unsigned long long ex_phy_addr(struct ex_phy *phy) +{ + return SAS_ADDR(phy->attached_sas_addr); +} + +static inline unsigned long long dev_addr(struct domain_device *dev) +{ + return SAS_ADDR(dev->sas_addr); +} + +static inline unsigned long long port_addr(struct asd_sas_port *port) +{ + return SAS_ADDR(port->sas_addr); +} + +static inline bool dev_and_phy_addr_same(struct domain_device *dev, + struct ex_phy *phy) +{ + return dev_addr(dev) == ex_phy_addr(phy); +} + +static inline bool port_and_phy_addr_same(struct asd_sas_port *port, + struct ex_phy *phy) +{ + return port_addr(port) == ex_phy_addr(phy); +} + +static inline bool ex_phy_addr_same(struct ex_phy *phy1, struct ex_phy *phy2) +{ + return ex_phy_addr(phy1) == ex_phy_addr(phy2); +} + struct sas_domain_function_template { /* The class calls these to notify the LLDD of an event. */ void (*lldd_port_formed)(struct asd_sas_phy *); -- 2.31.1