All of lore.kernel.org
 help / color / mirror / Atom feed
From: Frederick Lawler <fred@fredlawl.com>
To: jejb@linux.ibm.com, martin.petersen@oracle.com
Cc: Frederick Lawler <fred@fredlawl.com>,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	bhelgaas@google.com
Subject: [PATCH] scsi: esas2r: Prefer pcie_capability_read_word()
Date: Wed, 17 Jul 2019 21:07:44 -0500	[thread overview]
Message-ID: <20190718020745.8867-9-fred@fredlawl.com> (raw)
In-Reply-To: <20190718020745.8867-1-fred@fredlawl.com>

Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability")
added accessors for the PCI Express Capability so that drivers didn't
need to be aware of differences between v1 and v2 of the PCI
Express Capability.

Replace pci_read_config_word() and pci_write_config_word() calls with
pcie_capability_read_word() and pcie_capability_write_word().

Signed-off-by: Frederick Lawler <fred@fredlawl.com>
---
 drivers/scsi/esas2r/esas2r_init.c  | 13 ++++---------
 drivers/scsi/esas2r/esas2r_ioctl.c | 14 +++++---------
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c
index 950cd92df2ff..eb7d139ffc00 100644
--- a/drivers/scsi/esas2r/esas2r_init.c
+++ b/drivers/scsi/esas2r/esas2r_init.c
@@ -762,14 +762,10 @@ u32 esas2r_get_uncached_size(struct esas2r_adapter *a)
 
 static void esas2r_init_pci_cfg_space(struct esas2r_adapter *a)
 {
-	int pcie_cap_reg;
-
-	pcie_cap_reg = pci_find_capability(a->pcid, PCI_CAP_ID_EXP);
-	if (pcie_cap_reg) {
+	if (pci_is_pcie(a->pcid)) {
 		u16 devcontrol;
 
-		pci_read_config_word(a->pcid, pcie_cap_reg + PCI_EXP_DEVCTL,
-				     &devcontrol);
+		pcie_capability_read_word(a->pcid, PCI_EXP_DEVCTL, &devcontrol);
 
 		if ((devcontrol & PCI_EXP_DEVCTL_READRQ) >
 		     PCI_EXP_DEVCTL_READRQ_512B) {
@@ -778,9 +774,8 @@ static void esas2r_init_pci_cfg_space(struct esas2r_adapter *a)
 
 			devcontrol &= ~PCI_EXP_DEVCTL_READRQ;
 			devcontrol |= PCI_EXP_DEVCTL_READRQ_512B;
-			pci_write_config_word(a->pcid,
-					      pcie_cap_reg + PCI_EXP_DEVCTL,
-					      devcontrol);
+			pcie_capability_write_word(a->pcid, PCI_EXP_DEVCTL,
+						   devcontrol);
 		}
 	}
 }
diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c
index 3d130523c288..442c5e70a7b4 100644
--- a/drivers/scsi/esas2r/esas2r_ioctl.c
+++ b/drivers/scsi/esas2r/esas2r_ioctl.c
@@ -757,7 +757,6 @@ static int hba_ioctl_callback(struct esas2r_adapter *a,
 
 		struct atto_hba_get_adapter_info *gai =
 			&hi->data.get_adap_info;
-		int pcie_cap_reg;
 
 		if (hi->flags & HBAF_TUNNEL) {
 			hi->status = ATTO_STS_UNSUPPORTED;
@@ -784,17 +783,14 @@ static int hba_ioctl_callback(struct esas2r_adapter *a,
 		gai->pci.dev_num = PCI_SLOT(a->pcid->devfn);
 		gai->pci.func_num = PCI_FUNC(a->pcid->devfn);
 
-		pcie_cap_reg = pci_find_capability(a->pcid, PCI_CAP_ID_EXP);
-		if (pcie_cap_reg) {
+		if (pci_is_pcie(a->pcid)) {
 			u16 stat;
 			u32 caps;
 
-			pci_read_config_word(a->pcid,
-					     pcie_cap_reg + PCI_EXP_LNKSTA,
-					     &stat);
-			pci_read_config_dword(a->pcid,
-					      pcie_cap_reg + PCI_EXP_LNKCAP,
-					      &caps);
+			pcie_capability_read_word(a->pcid, PCI_EXP_LNKSTA,
+						  &stat);
+			pcie_capability_read_dword(a->pcid, PCI_EXP_LNKCAP,
+						   &caps);
 
 			gai->pci.link_speed_curr =
 				(u8)(stat & PCI_EXP_LNKSTA_CLS);
-- 
2.17.1


  parent reply	other threads:[~2019-07-18  2:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18  2:07 [PATCH] cxgb4: Prefer pcie_capability_read_word() Frederick Lawler
2019-07-18  2:07 ` [PATCH] drm/amdgpu: " Frederick Lawler
2019-07-18 12:58   ` Bjorn Helgaas
2019-07-18  2:07 ` [PATCH] drm/radeon: " Frederick Lawler
2019-07-18 12:56   ` Bjorn Helgaas
2019-07-18 12:56     ` Bjorn Helgaas
2019-07-18  2:07 ` [PATCH] igc: " Frederick Lawler
2019-07-18  2:07   ` [Intel-wired-lan] " Frederick Lawler
2019-07-21 20:30   ` David Miller
2019-07-21 20:30     ` [Intel-wired-lan] " David Miller
2019-07-18  2:07 ` [PATCH] media: cobalt: " Frederick Lawler
2019-07-18  2:07 ` [PATCH] mtip32xx: " Frederick Lawler
2019-07-18 12:48   ` Bjorn Helgaas
2019-07-18  2:07 ` [PATCH] qed: " Frederick Lawler
2019-07-18  8:22   ` [EXT] " Michal Kalderon
2019-07-21 20:30   ` David Miller
2019-07-18  2:07 ` [PATCH] scsi: csiostor: " Frederick Lawler
2019-08-13  2:04   ` Martin K. Petersen
2019-07-18  2:07 ` Frederick Lawler [this message]
2019-08-13  2:05   ` [PATCH] scsi: esas2r: " Martin K. Petersen
2019-07-18  2:07 ` [PATCH] skd: " Frederick Lawler
2019-07-18 12:43   ` Bjorn Helgaas
2019-07-18 13:50 ` [PATCH] cxgb4: " Bjorn Helgaas
2019-07-21 20:30 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190718020745.8867-9-fred@fredlawl.com \
    --to=fred@fredlawl.com \
    --cc=bhelgaas@google.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.