From patchwork Wed Sep 13 12:27:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 13382948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF1CEEDEC4A for ; Wed, 13 Sep 2023 12:30:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240478AbjIMMaU (ORCPT ); Wed, 13 Sep 2023 08:30:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240480AbjIMMaS (ORCPT ); Wed, 13 Sep 2023 08:30:18 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ADF419AC; Wed, 13 Sep 2023 05:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694608214; x=1726144214; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=23uguZCvTV5t58r/xj3uv2xYgJi+V730Lx4ND5oIgSM=; b=M/Y3ZMhLF1paZE0jXaNAillNLiN+rry3+dNT750CWmdXm0SZ1CT5KCNv ar6+Z48T4uQ6p2il1XJOwAFRHWqIY/G2ApwzfWjT24R0UHDYiAckFpD0d lPa7HYWXvowzc6RxYERzcOviT6PAKNOtbre7R5ZvhWUo29p4tJwaZ4Aus w+GtN7PSeb9hMbBxdrgtN66j4i08pfuk55otklVu0mhiTO5gEkftCtggp r+EbViIsxMMPY3FxwrrK4ecc7VrTe77C4Nj4tKPqAyicrKZtQNgMTAa6k lCr8CFxXnwyJl++XF8WUi1hGq5tXoOwBzj1lKTtxkL0w4Rva9RgcWGfTE w==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="368912312" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="368912312" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 05:28:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="693836605" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="693836605" Received: from pakurapo-mobl3.ger.corp.intel.com (HELO ijarvine-mobl2.ger.corp.intel.com) ([10.249.45.213]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 05:28:01 -0700 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= To: Jonathan Cameron , linux-pci@vger.kernel.org, Bjorn Helgaas , Dennis Dalessandro , Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= Subject: [PATCH v2 01/10] IB/hfi1: Use FIELD_GET() to extract Link Width Date: Wed, 13 Sep 2023 15:27:39 +0300 Message-Id: <20230913122748.29530-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230913122748.29530-1-ilpo.jarvinen@linux.intel.com> References: <20230913122748.29530-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Use FIELD_GET() to extract PCIe Negotiated Link Width field instead of custom masking and shifting, and remove extract_width() which only wraps that FIELD_GET(). Signed-off-by: Ilpo Järvinen Reviewed-by: Jonathan Cameron --- drivers/infiniband/hw/hfi1/pcie.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c index 08732e1ac966..c132a9c073bf 100644 --- a/drivers/infiniband/hw/hfi1/pcie.c +++ b/drivers/infiniband/hw/hfi1/pcie.c @@ -3,6 +3,7 @@ * Copyright(c) 2015 - 2019 Intel Corporation. */ +#include #include #include #include @@ -210,12 +211,6 @@ static u32 extract_speed(u16 linkstat) return speed; } -/* return the PCIe link speed from the given link status */ -static u32 extract_width(u16 linkstat) -{ - return (linkstat & PCI_EXP_LNKSTA_NLW) >> PCI_EXP_LNKSTA_NLW_SHIFT; -} - /* read the link status and set dd->{lbus_width,lbus_speed,lbus_info} */ static void update_lbus_info(struct hfi1_devdata *dd) { @@ -228,7 +223,7 @@ static void update_lbus_info(struct hfi1_devdata *dd) return; } - dd->lbus_width = extract_width(linkstat); + dd->lbus_width = FIELD_GET(PCI_EXP_LNKSTA_NLW, linkstat); dd->lbus_speed = extract_speed(linkstat); snprintf(dd->lbus_info, sizeof(dd->lbus_info), "PCIe,%uMHz,x%u", dd->lbus_speed, dd->lbus_width);