Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3541650rdb; Wed, 13 Sep 2023 15:42:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHR9Y9Xc0U34jKtg2hG5iY4hHCqeS3IrYJsFJwOzhHVv/uioRD0XZzd1dgVMJKucmSIdZik X-Received: by 2002:a17:90a:70c7:b0:26d:414d:a98a with SMTP id a7-20020a17090a70c700b0026d414da98amr3373333pjm.1.1694644925256; Wed, 13 Sep 2023 15:42:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694644925; cv=none; d=google.com; s=arc-20160816; b=0sU3IugD6yDd0OhfbpVPEmOH6xlyhstkhKR43xa9hOBy7tgfp2/a/CQXPwzjZYF/zQ ax/c5cW8uuqA3BZHJgkPrhikzj1MPqC3Ho1uKcPSeQYxxxpZ4qr0NNPTjKCOrh/Fh4Rc WmgcIqzfc3IfA/irKZOD3xOSB1YozeI9SeA+lO2ac0WgoTSpl25kApkp2Kxdi1oCNo49 czMDh54cbsrZpEQldlXfkqK4Gd3n3CfyleCIKrTYIqhpvt8ZTVu97p5uCouECVyhnAEM Vlwg9wpAoCD+AkssC7HC2flnYudw+95jwR6Wsnsb8ssOUQtkt3F9oETNcMAdJaquPGEL 6f7A== 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 :dkim-signature; bh=S0ZxoL0dKXej0KBmSyoXImLY9I2APB/UUGWMtQ4hS+o=; fh=nA2vVj1DM1EyO+m2HoYoQfT/8NHvxXMyPbwvoRmXN6c=; b=UZ7St1OtwByVmPNOuVvHmGvLBimPj1HYCzq+5Km8rDfuGpXJuO2zq1lfwpKx8fKI/D QTb4UGccqgli1VYJZ9MjpHcb8jhgVeykyO4chj4N1jpLYld1/iY/P9TevqkHTPQlSIDp 8bWNbU7sutQ+NgQMums9e+9+wmK6yS0/a8FhjmiG6TZkkejPk6UjUjG7WFNqFCxDn1pL c/v8+PmGKp27CCAbBvK+/jBNd4S1+UCfts55V+jUbyS+fZ4Hf5Yv0KwjznbCQctWAjto 5E541qqowti3yUgtx8x8T4xZlfCdNEnPctJu0xGMOkqOWhFrj2r7nRS28Jp/rGFDCoei CowQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IuwJfy2b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id gq15-20020a17090b104f00b00269781d3a3dsi269307pjb.111.2023.09.13.15.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 15:42:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IuwJfy2b; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id B4F158411D78; Wed, 13 Sep 2023 05:31:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240655AbjIMMbD (ORCPT + 99 others); Wed, 13 Sep 2023 08:31:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240609AbjIMMbA (ORCPT ); Wed, 13 Sep 2023 08:31:00 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CAE61BC8; Wed, 13 Sep 2023 05:30:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694608249; x=1726144249; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1/Ks4shsYec7fIvyglfV0nBYf14xH5c+nwe3xSib8S0=; b=IuwJfy2bN+EuGCvy3e79A+V2ExaFySKwqOsDAhHkzsFsrZF+azWEA7Xl D5GIRJdv5aCCU+lz3VogF4NrSajM1cZbghT3dlNBhKfuDoY2KQvK+DtJf 0Im4iBl7MFbmi2AhU/6TgkTSitqzYB6uMxPz+7H3vdcdiM1IhVY6nXSKB 6z5AAB82B+EUuoi4xp2PJsEeunf6vMKYuzk6+ZGmatqTSXJQXuqDiStCR OS31pFICW2F7keSpgMyF7tSeBzTD0+n+AUJIUoOt67dh1jRku1IAaXjlH o3VRX9tarh2V3zdawY4xgMN7Y+dU9xKmSnCFoHhozKhXY+nfyhA34tsKI Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="368912530" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="368912530" 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:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="693836656" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="693836656" 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:25 -0700 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Jonathan Cameron , linux-pci@vger.kernel.org, Bjorn Helgaas , Bradley Grove , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= Subject: [PATCH v2 07/10] scsi: esas2r: Use FIELD_GET() to extract PCIe capability fields Date: Wed, 13 Sep 2023 15:27:45 +0300 Message-Id: <20230913122748.29530-8-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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 05:31:03 -0700 (PDT) Use FIELD_GET() to extract PCIe capability register fields instead of custom masking and shifting. Also remove the unnecessary cast to u8, the value in those fields always fits to u8. Signed-off-by: Ilpo Järvinen --- drivers/scsi/esas2r/esas2r_ioctl.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c index 055d2e87a2c8..3f7c1d131ec3 100644 --- a/drivers/scsi/esas2r/esas2r_ioctl.c +++ b/drivers/scsi/esas2r/esas2r_ioctl.c @@ -41,6 +41,8 @@ * USA. */ +#include + #include "esas2r.h" /* @@ -792,16 +794,10 @@ static int hba_ioctl_callback(struct esas2r_adapter *a, pcie_capability_read_dword(a->pcid, PCI_EXP_LNKCAP, &caps); - gai->pci.link_speed_curr = - (u8)(stat & PCI_EXP_LNKSTA_CLS); - gai->pci.link_speed_max = - (u8)(caps & PCI_EXP_LNKCAP_SLS); - gai->pci.link_width_curr = - (u8)((stat & PCI_EXP_LNKSTA_NLW) - >> PCI_EXP_LNKSTA_NLW_SHIFT); - gai->pci.link_width_max = - (u8)((caps & PCI_EXP_LNKCAP_MLW) - >> 4); + gai->pci.link_speed_curr = FIELD_GET(PCI_EXP_LNKSTA_CLS, stat); + gai->pci.link_speed_max = FIELD_GET(PCI_EXP_LNKCAP_SLS, caps); + gai->pci.link_width_curr = FIELD_GET(PCI_EXP_LNKSTA_NLW, stat); + gai->pci.link_width_max = FIELD_GET(PCI_EXP_LNKCAP_MLW, caps); } gai->pci.msi_vector_cnt = 1; -- 2.30.2