Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1831776rwb; Fri, 23 Sep 2022 20:35:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7QyJQFrXojvh2M+Bdlrk3+LFMqBaUiGcW4ccf4fWZArRzV+gCRzUvl1G/OJRdHulq4vk77 X-Received: by 2002:a17:902:f546:b0:177:ed6b:4696 with SMTP id h6-20020a170902f54600b00177ed6b4696mr11454336plf.171.1663990553084; Fri, 23 Sep 2022 20:35:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663990553; cv=none; d=google.com; s=arc-20160816; b=jg44VFJxe25O40MxpV5F4IzMPp6m8ElZWmD8aVic5LeQC7Yq0RmqvqEJMM59k62sTz vnWSAP5VQQAluOR03KyB8nZbqa9IHVpaXrVFt3mCriDAPHnj1HQo3hiOnk5mBLl/5wsz EVsVqM4nC1GA7P7WPodU5xqI+Qy4jImR15R9WtgK+ry/SwaSwae49DiUQUPwJeMZ26sY fFzjVd8HcU38RnkCUHqoy39nXIt5rgfvfCOUqVhpvZDbErsRBdPCxqEQeIrtIj5R3JM2 nP+jjV/LTezjeCghRsX6tKUdQp7ov6cdtEr5PXsqdg0pvJAM0o6g0hsnCXvITpbWhaTl 21WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ZiV4e+kKTqlqa46QyXp/m3qlVd4VC528OkktQTRKQrY=; b=sPqH2Fxuo79hMx61rmFCiOlXRqYhQyrI7PJE5ZL7PASI7J4z+YowZc1njqgobMZLrf uexVTKio6W2OO0cW9gfeLGVjUNv44HPh0GvLwNCYAEgtCs4q4Pj7bDJ+c3aq5DIyCXTW d2rNJGpjiHJfQNfAUgaeeQjLmCSX7wJwSCK+n812zd+ZAtYPCeHcYeU3iZfj7cBq+T7E EVlJB3PnZ9n0+G013kWAEsImXgPv8SrdhqA0s5zROYIwvlKONDv4B4RIR9T9X+8nbi5K 8xcccBpxQIkvwo0iIY4yPIAninyOvpn+Ns98IBMoGBp+o2qPCirdylngdKXjtN/vo2Cd sJiQ== 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 n4-20020a170902d2c400b0017849d0200csi5975488plc.219.2022.09.23.20.35.41; Fri, 23 Sep 2022 20:35:53 -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 S233088AbiIXDWj (ORCPT + 99 others); Fri, 23 Sep 2022 23:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231833AbiIXDWh (ORCPT ); Fri, 23 Sep 2022 23:22:37 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BD7212059A; Fri, 23 Sep 2022 20:22:35 -0700 (PDT) Received: from canpemm500004.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MZDk659q7zlWnR; Sat, 24 Sep 2022 11:18:22 +0800 (CST) Received: from [10.174.179.14] (10.174.179.14) 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, 24 Sep 2022 11:22:33 +0800 Subject: Re: [PATCH 6/7] scsi: pm8001: use dev_and_phy_addr_same() instead of open coded To: John Garry , , 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> <569cb47c-af63-cf70-ae1a-4c5116dd4877@huawei.com> From: Jason Yan Message-ID: Date: Sat, 24 Sep 2022 11:22:32 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <569cb47c-af63-cf70-ae1a-4c5116dd4877@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.179.14] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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,NICE_REPLY_A, 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 On 2022/9/23 18:30, John Garry wrote: > 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. > I've been thinking about this for a while too. Thank you for the advise. Thanks, Jason > > +} > > Thanks, > John > > .