Message ID | 20230913122748.29530-8-ilpo.jarvinen@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:a8d:b0:3f2:4152:657d with SMTP id gr13csp69263vqb; Wed, 13 Sep 2023 13:29:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQDaqvH2Fsy2TK5EY7MaXW/sWVr92BdGHlegbcBHlTz39TbGVUF8+cmE8UrTGJyMn/dxA1 X-Received: by 2002:a17:90b:3a82:b0:268:dad:2fdc with SMTP id om2-20020a17090b3a8200b002680dad2fdcmr3528794pjb.21.1694636962795; Wed, 13 Sep 2023 13:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694636962; cv=none; d=google.com; s=arc-20160816; b=oXvuZEDdWwQnS/k3D/NUp5qqrqNMbcpnlyCzxQnQDok0UR8DcPNO7cL8VcF5k+8jgH fOw6NfbkBVi8oZLkCe/WDtS3bKbGAoYL62XQh61CwUzn95qNVVkt8T0Y657W0QRchgnl jz2jxiwatUFgHBL/2lD632fn64k7dD0G/7AzQ0/wJlQjvL/vDVz/d70yvO62AS7L+CrS rrCgrQCIrvL6aZFcA9GnS0k4rtJqAw7S8LxGR0KF+wCo5u5NxR/ZoPyntqU6r32pMwky XvYB9EWYmUBVWqWaTaZaGS+BLf8K1Y1Cr8Q8XOxrj0cu51i6UprzP45KV/VsLS1RSpxQ rDgg== 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 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id w20-20020a17090aea1400b0026b2fdb4f82si76280pjy.29.2023.09.13.13.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 13:29:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; 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 23.128.96.34 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 5AE85842AD01; Wed, 13 Sep 2023 05:31:10 -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 S240479AbjIMMbE (ORCPT <rfc822;pwkd43@gmail.com> + 36 others); Wed, 13 Sep 2023 08:31:04 -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 <rfc822;linux-kernel@vger.kernel.org>); 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_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> To: Jonathan Cameron <Jonathan.Cameron@Huawei.com>, linux-pci@vger.kernel.org, Bjorn Helgaas <helgaas@kernel.org>, Bradley Grove <linuxdrivers@attotech.com>, "James E.J. Bottomley" <jejb@linux.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com>, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> 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: <linux-kernel.vger.kernel.org> 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:10 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776955647911548627 X-GMAIL-MSGID: 1776955647911548627 |
Series |
PCI/treewide: PCIe capability access cleanups
|
|
Commit Message
Ilpo Järvinen
Sept. 13, 2023, 12:27 p.m. UTC
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 <ilpo.jarvinen@linux.intel.com>
---
drivers/scsi/esas2r/esas2r_ioctl.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
Comments
On Wed, 13 Sep 2023 15:27:45 +0300 Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> wrote: > 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 <ilpo.jarvinen@linux.intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > --- > 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 <linux/bitfield.h> > + > #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;
Ilpo, > 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. Applied to 6.7/scsi-staging, thanks!
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 <linux/bitfield.h> + #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;