Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp131967rwb; Tue, 27 Sep 2022 23:58:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4hic0xTWA4XGk8wpFxRaeC37I9FK1oD7hIsjwuqWv/2OeFZoZRcxhUCbp2MQixsLzNbW5u X-Received: by 2002:a17:90a:2fc9:b0:202:5605:65ae with SMTP id n9-20020a17090a2fc900b00202560565aemr8948503pjm.167.1664348302482; Tue, 27 Sep 2022 23:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664348302; cv=none; d=google.com; s=arc-20160816; b=jokvLWE3Ay3iScRyoFS6lQrKpjNYmL+8USuS7AbYRMdRIIsvd3OEhen8CH35FB7zG1 CyG1n/R4H5babUUBMg5PzuxII6K1N2MiMnNa4y1QdqF7SmzpR57z3fQLkZp5ci5cw2Fh Y4OkpVfGhiALk8Mkxo47Gwdju1Dtvov0f+xjhgE/IdYPsxyHM2rOUfaPZ7jhs4XM6ttX aPc+Z8j8r/+ybgo3bl034bHZZeJr1CPjlMg1K4pV/sqM9ptCfqXkT8sBmH9tdrbQ8AZT M37NcBnwzWBowYksEEfJlAYoXGeWVSAIl+0pTlmDaxyqMEvyuHO1xLfBWga0638FWBXG f+Ig== 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=nCYCVVHGR0MWoB68vLeZ56AOS/s6UxDWHuddXhpyVvo=; b=fOoPcsO3dLaJrFlQDtq3rVNPLmz74+a53YyXnmrJyqfsxBXXzdht6ho8LMku5jp78C 8A/F/pZft/nf76UfoE95BkdzRYGwz2Qd8XEtYWcdhMewIStX/jZYQpFWRvx44XQoolun q0SDc3UiUAAKnOx/+poDyS4/EqFW1V3PPGLbZCOqE9csfpZbFqiuQMppkKd6z3pPIstO TEEKQCjBbBac7ig7XOn/simuzk622hEd6zvjZTOqcP+Si9MH+hA0vuz73yMkiTILbsHW Z280yFeNtR1nBgzPGFgrRjwuXchuWMS9foNge4juXpqNnRdesvwBxTzs/orxDC9smdKJ N7QA== 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 d16-20020aa78e50000000b005364d3b5482si2112667pfr.99.2022.09.27.23.58.10; Tue, 27 Sep 2022 23:58:22 -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 S233127AbiI1Gjp (ORCPT + 99 others); Wed, 28 Sep 2022 02:39:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbiI1Gji (ORCPT ); Wed, 28 Sep 2022 02:39:38 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB0F41EC9AA; Tue, 27 Sep 2022 23:39:30 -0700 (PDT) Received: from canpemm500004.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Mcmvb0KVnzWgxN; Wed, 28 Sep 2022 14:35:23 +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; Wed, 28 Sep 2022 14:39:28 +0800 From: Jason Yan To: , CC: , , , , , , , , Jason Yan , Jack Wang Subject: [PATCH v6 2/8] scsi: libsas: introduce sas_find_attached_phy_id() helper Date: Wed, 28 Sep 2022 15:01:24 +0800 Message-ID: <20220928070130.3657183-3-yanaijie@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220928070130.3657183-1-yanaijie@huawei.com> References: <20220928070130.3657183-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: 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,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 LLDDs are implementing their own attached phy id finding code repeatedly. Factor it out to libsas. Signed-off-by: Jason Yan Reviewed-by: Jack Wang Reviewed-by: Damien Le Moal 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..2caf366b9f74 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_id(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_phy_match_dev_addr(dev, phy)) + return phy_id; + } + + return -ENODEV; +} +EXPORT_SYMBOL_GPL(sas_find_attached_phy_id); + 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..ec08008b919c 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_id(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); -- 2.31.1