Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp776387rwb; Fri, 23 Sep 2022 04:08:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6zVUuVvIHG8bcK5/p359yaTevfFwxUR/PGqWFL1oVnehlGCtq0KW68FrMV/vGHVIBCS9dv X-Received: by 2002:a17:90b:1c07:b0:202:8ad0:3210 with SMTP id oc7-20020a17090b1c0700b002028ad03210mr21124854pjb.193.1663931300854; Fri, 23 Sep 2022 04:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663931300; cv=none; d=google.com; s=arc-20160816; b=Zx6qcHCdOw3sf5iVmVTXJbN/A4ghalR/SoKF3VG0dSwZ1sAaxf4D25ez5fDkcOWolg o2fXzO+RaUGusJKOB9DKCwdErq7SZZMwdRNDrhIXeVFrY68W3CkArilTCWjJe0VOhTU8 8KQiwRDRmOz1QG6vuPq/sPIeLg4vLcpMukC97vZRYgj2fGiFG+b1Rpm5QyZthIzhff2W OZ4xr90tFUr4eYXdXh8odIyGwPzcV01vvoJTLj/z6hDhF/y/4m/SvQjQmWb++WiL+PZj p4PMaq9PUKjfC5S4eAOl0qYDSFXHzavYGJgFO3XpgZDOZioYaQ0G3iw5OIR6bDQnJBZi 1NTg== 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=XqtbIGzlgQxFxhyDsYXciGStConu0NFVi2SfS40ex+A=; b=yw/zux5VyGrtR8DUve8CBmkYdVUBnEusD3A9riB2v0a8yxNKrg214NpRnha00s6fzw Q+vLK+E2Gj4VtcQ3pOJP62Ivd5kMZ4kbRhLSXTyjGdmD4bdPB50Gqzl3SkrzJN81kg8a G1yxpbLnU+WOVlAi31bS2ZpcIHtWplFYAMPBp85jtcZhIYGQVMhe/0grWRBIBWTwITAm JZWdfBwaOiSo5zGDpAyAphPeRElfxYBbHJHLge4Ez2IPPjIypdpYTqm7BX1LHAYdFsnb QXVYdlULRibxIOe27zzIJuaQaPQXjfUzHasiyoGsaM6HBSa4137v/BA76F0jd+dxMuq9 3avw== 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 h189-20020a636cc6000000b00429e52c1de8si8077950pgc.816.2022.09.23.04.08.08; Fri, 23 Sep 2022 04:08:20 -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 S231445AbiIWKbO (ORCPT + 99 others); Fri, 23 Sep 2022 06:31:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231418AbiIWKaz (ORCPT ); Fri, 23 Sep 2022 06:30:55 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8941111E95E; Fri, 23 Sep 2022 03:30:53 -0700 (PDT) Received: from fraeml739-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4MYpG12Tpsz6HHxp; Fri, 23 Sep 2022 18:26:01 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml739-chm.china.huawei.com (10.206.15.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 23 Sep 2022 12:30:50 +0200 Received: from [10.48.153.47] (10.48.153.47) 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; Fri, 23 Sep 2022 11:30:50 +0100 Message-ID: <569cb47c-af63-cf70-ae1a-4c5116dd4877@huawei.com> Date: Fri, 23 Sep 2022 11:30:49 +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 6/7] scsi: pm8001: use dev_and_phy_addr_same() instead of open coded To: Jason Yan , , CC: , , , , , References: <20220917104311.1878250-1-yanaijie@huawei.com> <20220917104311.1878250-7-yanaijie@huawei.com> <0034eff3-70a5-becb-0821-f9c36371e6d9@huawei.com> <3c1aa262-7e9b-cb6c-e8a1-a1a201050a10@huawei.com> <6c299e8f-80be-0276-c8b1-9df1946434da@huawei.com> From: John Garry In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.48.153.47] X-ClientProxiedBy: lhrpeml100006.china.huawei.com (7.191.160.224) To lhrpeml500003.china.huawei.com (7.191.162.67) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 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 23/09/2022 11:13, Jason Yan wrote: >> >> Please explain why. >> >> I would assume that if those helpers were only used in libsas code >> (and not LLDDs) then they could be put in sas_internal.h and no need >> for export >> > > > Sorry, I did not make it clear. I mean we need to export > sas_find_attathed_phy() below. Not the sas address comparation helpers. That seems fine to me. About sas_find_attathed_phy() implementation, > +static inline int sas_find_attathed_phy(struct expander_device *ex_dev, > + struct domain_device *dev) > +{ > + struct ex_phy *phy; > + int phy_id; > + > + for (phy_id = 0; phy_id < ex_dev->num_phys; phy_id++) { > + phy = &ex_dev->ex_phy[phy_id]; > + if (SAS_ADDR(phy->attached_sas_addr) > + == SAS_ADDR(dev->sas_addr)) > + return phy_id; > + } > + > + return ex_dev->num_phys; Returning ex_dev->num_phys would seem ok, but then the LLDD needs to check that return against ex_dev->num_phys. It seems ok, but I'm still not 100% comfortable with that. Maybe returning -ENODEV may be better. Or return boolean and pass phy_id as pointer to be filled in when returning true. > +} Thanks, John