Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp617414rwb; Tue, 27 Sep 2022 02:10:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6xBxae46OtbR7UQXttvrB61OcDch8n5hgoPsB7/EX9CTi6hVqo362uA3Jt3oAYA4lHCdGF X-Received: by 2002:a63:9042:0:b0:438:8ef2:2476 with SMTP id a63-20020a639042000000b004388ef22476mr24588643pge.55.1664269846336; Tue, 27 Sep 2022 02:10:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664269846; cv=none; d=google.com; s=arc-20160816; b=pJjzjINb8+RKzohb9wTSufx+SuY9gln2KWHCtPk51C07+g1Ybt8VndCJfHIkSpiuXx iqGT6+HFXAAaL4T4uc2gEUzYXsMm7ztIK/2JVIhnHRd1JQP9R99mAYmF3BDLj7csOzCP spZQKJLALe2RTQf+Ncf2sW4an7tpTXv9JaLv4nswptlealRmz90FjDTVbpahIcAOE2ol OsGAOpRUrokdyLZBGF12gXr2NUclQr21uhT7dQqeAuRht2a0608oIaRrzs6cUjDiuB9r gO8P4BhPNK2nItaotgiQned4H6ESiSm6jcrECOTKeQmbbKzO62C3D0JwVeRLG7Yl6Lfv 83TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=DSvdP8/hETity+IXwRJT4Z6nrFrHP/cDhVkCPOJvkgA=; b=0ADRGUl92pnNc8uPswTbbI2pmhtI0GPrXI/GGc1srSppsfrVaqgA5MM2GgPQuQ4/R8 xBzhGwrT0ImaMk2Ds1lB5KEE6rB/YziBSvSIvUVwOZ3ZNWmChAIg2R1MZrbW8QU+8Cfg 0TsgptlPU7flTSlagHsY4s0R7vYmXgQlqhWNPvpmsAVIJW6NRP+FNPtjXhXfS/lOwQ9N 9zvVLIm+kX/5SxvaqAbs0e5heJ5H+k5617/yOrAbSOjlcDLVPwT5CrkBkn2GK5SSTmrZ aprXl81hPOuvuF6QcG9i6T0XfvX/cfafl++Jx+WTI0sJso+WhQEh6gszHPAUbUu1Zfq4 Up/g== 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 f6-20020a170902ce8600b00178b7f3b89esi1374336plg.352.2022.09.27.02.10.33; Tue, 27 Sep 2022 02:10:46 -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 S231180AbiI0Ij0 (ORCPT + 99 others); Tue, 27 Sep 2022 04:39:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231278AbiI0IjD (ORCPT ); Tue, 27 Sep 2022 04:39:03 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E906345069; Tue, 27 Sep 2022 01:38:30 -0700 (PDT) Received: from fraeml711-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4McCh34XGDz687w4; Tue, 27 Sep 2022 16:38:27 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml711-chm.china.huawei.com (10.206.15.60) 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 10:38:28 +0200 Received: from [10.48.156.245] (10.48.156.245) by lhrpeml500003.china.huawei.com (7.191.162.67) 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 09:38:27 +0100 Message-ID: Date: Tue, 27 Sep 2022 09:38:30 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v4 1/8] scsi: libsas: introduce sas address comparison helpers To: Jason Yan , , CC: , , , , , , References: <20220927032605.78103-1-yanaijie@huawei.com> <20220927032605.78103-2-yanaijie@huawei.com> From: John Garry In-Reply-To: <20220927032605.78103-2-yanaijie@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.48.156.245] X-ClientProxiedBy: lhrpeml100002.china.huawei.com (7.191.160.241) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,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 On 27/09/2022 04:25, Jason Yan wrote: > 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 Reviewed-by: John Garry > --- > 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); > +} > + note: I did think that we could use a macro as a generic matching API, like: #define sas_phy_match_addr_common(x, ex_phy) \ ({ typeof(x) __dummy; \ if (__builtin_types_compatible_p(typeof(__dummy), struct asd_sas_port))\ sas_phy_match_port_addr(x, ex_phy);\ if (__builtin_types_compatible_p(typeof(__dummy), struct domain_device))\ sas_phy_match_dev_addr(x, ex_phy);\ 0; \ }) But I couldn't get it to work after 60 minutes of messing ... indeed, that latest code doesn't even compile.. Thanks, John > 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",