Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp299669rwb; Mon, 26 Sep 2022 19:20:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7I8qw7w0/0/QLHURufV0ncYUDGd1mVvrtKpZfZ0Ehe+BPKSre56+Z9BeaMaVZux2dVE9uD X-Received: by 2002:a63:8848:0:b0:434:b5d7:b4fa with SMTP id l69-20020a638848000000b00434b5d7b4famr22110581pgd.181.1664245242251; Mon, 26 Sep 2022 19:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664245242; cv=none; d=google.com; s=arc-20160816; b=yr/D57K+loYG64KHFtlWX3/mY/a0iOZg9AFihz2CELZNFFBKMEOoJxqy/6HkYP26u/ 7x0cheixMA3DSiKBpQGJ71yF6WqdTWCnKncXBPxLepC5JL07MMGHUGlXC3uumyUIc/ap GTQWw6hAxplNQ0KMgiDkfbZ8QdYYkn/dduOeFoBh1FCy84MYiLLb18xalo28Cp/BHC0u Ex2tCYSECUL8pEtGqFZ/Ea9tky3D/mewUBqcb5JRA6lv3yaEbHDKiDZ1oQoo6T4TWs2r QkX4+IqkRaBMnSALaJR711PmafSiUC8l1vGdn0qcSqA4a3VzUqWICXnx6pJ2B6Qhla1E YDUA== 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=Wjtdp9TS6++3hvs1l9zdqOuIc4a02CrOvmZdpjgNcPQ=; b=y/DpMzS7X822LsbGB4Wd/CIiFd/UTbKvzOMvGCORzR6f9spLOsdAPqWrJy6J34MvK0 86Y3XLxjAmeohDC7mZT0ehMTxKmgDZjWBDu0IHzYpOQ/SVgtOO9Js6CSkTvTmB2dwmCW r9gNHQ+fwr35xjECV/1P3dFYwVitw/5nDBWFe0Ilqo9bKtbMej7KbLAa2YdfZTz6L5mD CY24pHa0q8lDptE3VkCEioqm4iG/eYZPAK0+NHaVjZcvUHu0ilsE6e67DBo02eAec5/s +WOmOvv7cb7tyMyuaaE6WMPKQ4A8jB7hepSThr0EZU9IXhNPjeDxWcsOdelEzvryTWfE U1Bg== 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 j15-20020a056a00234f00b0053ac347a786si616289pfj.259.2022.09.26.19.20.31; Mon, 26 Sep 2022 19:20:42 -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 S230082AbiI0CTZ (ORCPT + 99 others); Mon, 26 Sep 2022 22:19:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229849AbiI0CTJ (ORCPT ); Mon, 26 Sep 2022 22:19:09 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FA6E96762; Mon, 26 Sep 2022 19:19:08 -0700 (PDT) Received: from canpemm500004.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Mc3Bz5DxfzpVMy; Tue, 27 Sep 2022 10:16:11 +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; Tue, 27 Sep 2022 10:19:05 +0800 From: Jason Yan To: , CC: , , , , , , , Jason Yan , Jack Wang Subject: [PATCH v3 4/8] scsi: mvsas: use sas_find_attached_phy() instead of open coded Date: Tue, 27 Sep 2022 10:29:37 +0800 Message-ID: <20220927022941.4029476-5-yanaijie@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220927022941.4029476-1-yanaijie@huawei.com> References: <20220927022941.4029476-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: dggems702-chm.china.huawei.com (10.3.19.179) 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 The attached phy finding is open coded. Now we can replace it with sas_find_attached_phy(). Signed-off-by: Jason Yan Reviewed-by: Jack Wang --- drivers/scsi/mvsas/mv_sas.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/mvsas/mv_sas.c b/drivers/scsi/mvsas/mv_sas.c index a6867dae0e7c..f6576ffabe9f 100644 --- a/drivers/scsi/mvsas/mv_sas.c +++ b/drivers/scsi/mvsas/mv_sas.c @@ -1190,23 +1190,16 @@ static int mvs_dev_found_notify(struct domain_device *dev, int lock) mvi_device->sas_device = dev; if (parent_dev && dev_is_expander(parent_dev->dev_type)) { int phy_id; - u8 phy_num = parent_dev->ex_dev.num_phys; - struct ex_phy *phy; - for (phy_id = 0; phy_id < phy_num; phy_id++) { - phy = &parent_dev->ex_dev.ex_phy[phy_id]; - if (SAS_ADDR(phy->attached_sas_addr) == - SAS_ADDR(dev->sas_addr)) { - mvi_device->attached_phy = phy_id; - break; - } - } - if (phy_id == phy_num) { + phy_id = sas_find_attached_phy(&parent_dev->ex_dev, dev); + if (phy_id == -ENODEV) { mv_printk("Error: no attached dev:%016llx" "at ex:%016llx.\n", SAS_ADDR(dev->sas_addr), SAS_ADDR(parent_dev->sas_addr)); res = -1; + } else { + mvi_device->attached_phy = phy_id; } } -- 2.31.1