Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp655046rwb; Tue, 27 Sep 2022 02:49:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5OffXJf0a/BsAE9xK9OWjjCslufGzt90A1/ityss5GX6tToPrd4Rv0r2TaNV9LyTa5m7ya X-Received: by 2002:a17:90b:180a:b0:202:ae1f:328a with SMTP id lw10-20020a17090b180a00b00202ae1f328amr3717498pjb.78.1664272174109; Tue, 27 Sep 2022 02:49:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664272174; cv=none; d=google.com; s=arc-20160816; b=SciZX3vT8AFV+lPTOxcedABS4bvwjLilWuT9ss3+ZoP/L8DFQ4tQMoYd8MrUoMjLXB cZYPxKQchxmT+h5GpVkeB8w1E4cLQtxwg05l4bUDKwq52a0uN8RdPKtBui/u74UGmBLC uoiFtDugPEEft5LN1bYfmvRmeWU4SGtPNgUOkdLTWGb6V/HKGp5FmJZ4mA1KAir8brOn 3VVUldleFWGJN13VrEI/LOVOziL0jxHpaOVzaLdFUQYCkvLcF930hf79uPGkbQBkb4UG pIqzrGwM3+lw8YaNxfGt9tc3Hu/Q0IfWovcJwG/QZM+USRc5O5+0Y+B2hmdh0H9IFrP1 1kAQ== 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=L7PcQsSOwPcwkFvaAUzmV5g4q5jB+tCCADKhzY1z/dc=; b=LNnWs8+uzoMw3/PfOmx/s+xF4h5KoT38HasQz18epO7AT2u332U3eR9ZlAZRjC1Scw Vxn/DofS+SAoEzV/g93aoHQdOGYRafZWH1vgDCgdoHvt9kii9wJRRZR9IUwAhS64jmfM A3/r8G6VrmztI08ruOx4P7G4i2yTrSoTNiOya5gnvmYsv+I4pY0neIjxJK3oezEgZCZG 6F2k5UN7pADLxr+DK7QG5/r2fxq2N8Q+Tr0N3Y4GeEhS1eiRkHuGtVvg8QvwAqg+4cQx 3UMJ7Bre/hsCrxX0A+dPSpm03OWX0JSsozk1jg70vx7hruKF8rgw7dRantFQe81qdMHS vl6w== 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 c19-20020aa781d3000000b00535fd435cf6si1394913pfn.208.2022.09.27.02.49.21; Tue, 27 Sep 2022 02:49:34 -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 S231461AbiI0Iq0 (ORCPT + 99 others); Tue, 27 Sep 2022 04:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230354AbiI0IqW (ORCPT ); Tue, 27 Sep 2022 04:46:22 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96A1A67177; Tue, 27 Sep 2022 01:46:20 -0700 (PDT) Received: from fraeml704-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4McCs44kyJz689t8; Tue, 27 Sep 2022 16:46:16 +0800 (CST) Received: from lhrpeml500003.china.huawei.com (7.191.162.67) by fraeml704-chm.china.huawei.com (10.206.15.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Tue, 27 Sep 2022 10:46:17 +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:46:17 +0100 Message-ID: <19189c2c-91ee-f389-314f-a5133a5d3ef2@huawei.com> Date: Tue, 27 Sep 2022 09:46:19 +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 2/8] scsi: libsas: introduce sas_find_attached_phy() helper To: Jason Yan , , CC: , , , , , , , Jack Wang References: <20220927032605.78103-1-yanaijie@huawei.com> <20220927032605.78103-3-yanaijie@huawei.com> From: John Garry In-Reply-To: <20220927032605.78103-3-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: > LLDDs are implementing their own attached phy finding code repeatedly. > Factor it out to libsas. > > Signed-off-by: Jason Yan > Reviewed-by: Jack Wang > Reviewed-by: Damien Le Moal Apart from nit, below: Reviewed-by: John Garry > --- > drivers/scsi/libsas/sas_expander.c | 16 ++++++++++++++++ > include/scsi/libsas.h | 2 ++ > 2 files changed, 18 insertions(+) > > diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c > index fa2209080cc2..df5a64ad902f 100644 > --- a/drivers/scsi/libsas/sas_expander.c > +++ b/drivers/scsi/libsas/sas_expander.c > @@ -2107,6 +2107,22 @@ int sas_ex_revalidate_domain(struct domain_device *port_dev) > return res; > } > > +int sas_find_attached_phy(struct expander_device *ex_dev, > + struct domain_device *dev) Maybe sas_find_attached_phy_id() is a better name > +{ > + 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_phy_match_dev_addr(dev, phy)) > + return phy_id; > + } > + > + return -ENODEV; > +} > +EXPORT_SYMBOL_GPL(sas_find_attached_phy); > + > void sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost, > struct sas_rphy *rphy) > { > diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h > index 2dbead74a2af..75faf2308eae 100644 > --- a/include/scsi/libsas.h > +++ b/include/scsi/libsas.h > @@ -750,6 +750,8 @@ int sas_clear_task_set(struct domain_device *dev, u8 *lun); > int sas_lu_reset(struct domain_device *dev, u8 *lun); > int sas_query_task(struct sas_task *task, u16 tag); > int sas_abort_task(struct sas_task *task, u16 tag); > +int sas_find_attached_phy(struct expander_device *ex_dev, > + struct domain_device *dev); > > void sas_notify_port_event(struct asd_sas_phy *phy, enum port_event event, > gfp_t gfp_flags);