Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1983235rwb; Sat, 24 Sep 2022 00:25:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4d9+IEpz74IlXj7bNnZrhKOR9ByhOPYB7dTzNc7pZcX/p4vsj8tM7fnTgu0uZsy8XIqwon X-Received: by 2002:a17:90b:4b4c:b0:203:1eef:d810 with SMTP id mi12-20020a17090b4b4c00b002031eefd810mr25655601pjb.75.1664004352233; Sat, 24 Sep 2022 00:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664004352; cv=none; d=google.com; s=arc-20160816; b=hB7aSWAXuFzURLlv+h7MJMAVxw/wUaJ7jGPw6yE+5zb0rYpEqTbIocCXTda45uDUzG e/gEfYPwsrWyIvUbm33qAn8RUFbVTrKC6uZ3erWEzL8bMHenkXRVqqyQArXzHyrZTy5f 9JJMxc/MUIBoF6Zn6qDRqn0EGWYBRQp1uZtrrkXsg7obB4ZGR5MQ2yO+o2yOuDZkA4IO INixXP0TuLzYO1zijhgkGVug6GYuBlehAJn1bKiQ7Hf//p+2hGreXuqOsCqmCjo/Rnwb bfVA/Qkq9IQvhsiRpzb8D5By6crKIPA8xbH39LmRmIJf5wtxl/SGzBNiHbOB7eCRcX1w iliA== 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=ji7EKvyEEwbtyTNd0K5rCZOjGA60Dnpb8Qp3ZYF0oLk=; b=yuET1h8LAa+i0fy4yh9PvwbH7+GOqh4h0/7F5m/u90Md8KNFdQoIRfSZP8dHK8q1dy MOl1UTzUmIiH6YFHq/EOyiqdtLrHaCS/pNgJaiFMwdTAm7zMf6YKDWlPcleSTwqyk+NH 3HDMmJjt0ahRDv69DkNmVtXm4wThz01nl4O0ZGM1CFxYQhPC99RxT7hx5fGjiLHPUHHc oVRuUwjiBWcauuH3gp3Ur55SH4spX0IeUU/61OEFvMBAOpqF6AT/QgonR40XwY7YBzrd ma9tExADZV3fFKF0w1DRSM8/56FLEPLpMQrJTJV1/CPq3d7vMa28gFIgiqXfKxKzIAzg awQg== 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 c18-20020a170902849200b00178b7f3b89esi5209556plo.352.2022.09.24.00.25.40; Sat, 24 Sep 2022 00:25:52 -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 S233237AbiIXHYY (ORCPT + 99 others); Sat, 24 Sep 2022 03:24:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233215AbiIXHYT (ORCPT ); Sat, 24 Sep 2022 03:24:19 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71BBD13D87A; Sat, 24 Sep 2022 00:24:18 -0700 (PDT) Received: from canpemm500004.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MZL521l0sz1P6vJ; Sat, 24 Sep 2022 15:20:06 +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; Sat, 24 Sep 2022 15:24:16 +0800 From: Jason Yan To: , CC: , , , , , , , Jason Yan Subject: [PATCH v2 2/8] scsi: pm8001: use sas_find_attached_phy() instead of open coded Date: Sat, 24 Sep 2022 15:34:49 +0800 Message-ID: <20220924073455.2186805-3-yanaijie@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220924073455.2186805-1-yanaijie@huawei.com> References: <20220924073455.2186805-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: dggems704-chm.china.huawei.com (10.3.19.181) 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 --- drivers/scsi/pm8001/pm8001_sas.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c index 8e3f2f9ddaac..d15a824bcea6 100644 --- a/drivers/scsi/pm8001/pm8001_sas.c +++ b/drivers/scsi/pm8001/pm8001_sas.c @@ -645,22 +645,16 @@ static int pm8001_dev_found_notify(struct domain_device *dev) pm8001_device->dcompletion = &completion; if (parent_dev && dev_is_expander(parent_dev->dev_type)) { int phy_id; - struct ex_phy *phy; - for (phy_id = 0; phy_id < parent_dev->ex_dev.num_phys; - phy_id++) { - phy = &parent_dev->ex_dev.ex_phy[phy_id]; - if (SAS_ADDR(phy->attached_sas_addr) - == SAS_ADDR(dev->sas_addr)) { - pm8001_device->attached_phy = phy_id; - break; - } - } - if (phy_id == parent_dev->ex_dev.num_phys) { + + phy_id = sas_find_attached_phy(&parent_dev->ex_dev, dev); + if (phy_id == -ENODEV) { pm8001_dbg(pm8001_ha, FAIL, "Error: no attached dev:%016llx at ex:%016llx.\n", SAS_ADDR(dev->sas_addr), SAS_ADDR(parent_dev->sas_addr)); res = -1; + } else { + pm8001_device->attached_phy = phy_id; } } else { if (dev->dev_type == SAS_SATA_DEV) { -- 2.31.1