Skip to content

Commit 5cdaaf8

Browse files
Jiang Liubjorn-helgaas
authored andcommitted
rapdio/tsi721: Use PCI Express Capability accessors
Use PCI Express Capability access functions to simplify tsi721 driver. [bhelgaas: use word (16-bit) accesses for PCI_EXP_DEVCTL, PCI_EXP_DEVCTL2] Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Alexandre Bounine <alexandre.bounine@idt.com>
1 parent 32195ae commit 5cdaaf8

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

‎drivers/rapidio/devices/tsi721.c‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,9 +2212,8 @@ static int __devinit tsi721_probe(struct pci_dev *pdev,
22122212
const struct pci_device_id *id)
22132213
{
22142214
struct tsi721_device *priv;
2215-
int i, cap;
2215+
int i;
22162216
int err;
2217-
u32 regval;
22182217

22192218
priv = kzalloc(sizeof(struct tsi721_device), GFP_KERNEL);
22202219
if (priv == NULL) {
@@ -2320,20 +2319,16 @@ static int __devinit tsi721_probe(struct pci_dev *pdev,
23202319
dev_info(&pdev->dev, "Unable to set consistent DMA mask\n");
23212320
}
23222321

2323-
cap = pci_pcie_cap(pdev);
2324-
BUG_ON(cap == 0);
2322+
BUG_ON(!pci_is_pcie(pdev));
23252323

23262324
/* Clear "no snoop" and "relaxed ordering" bits, use default MRRS. */
2327-
pci_read_config_dword(pdev, cap + PCI_EXP_DEVCTL, &regval);
2328-
regval &= ~(PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_RELAX_EN |
2329-
PCI_EXP_DEVCTL_NOSNOOP_EN);
2330-
regval |= 0x2 << MAX_READ_REQUEST_SZ_SHIFT;
2331-
pci_write_config_dword(pdev, cap + PCI_EXP_DEVCTL, regval);
2325+
pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL,
2326+
PCI_EXP_DEVCTL_READRQ | PCI_EXP_DEVCTL_RELAX_EN |
2327+
PCI_EXP_DEVCTL_NOSNOOP_EN,
2328+
0x2 << MAX_READ_REQUEST_SZ_SHIFT);
23322329

23332330
/* Adjust PCIe completion timeout. */
2334-
pci_read_config_dword(pdev, cap + PCI_EXP_DEVCTL2, &regval);
2335-
regval &= ~(0x0f);
2336-
pci_write_config_dword(pdev, cap + PCI_EXP_DEVCTL2, regval | 0x2);
2331+
pcie_capability_clear_and_set_word(pdev, PCI_EXP_DEVCTL2, 0xf, 0x2);
23372332

23382333
/*
23392334
* FIXUP: correct offsets of MSI-X tables in the MSI-X Capability Block

0 commit comments

Comments
 (0)