Skip to content

Commit 0800d88

Browse files
hkallweitdavem330
authored andcommitted
net: sun: use pci_status_get_and_clear_errors
Use new helper pci_status_get_and_clear_errors() to simplify the code. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2864a88 commit 0800d88

File tree

2 files changed

+19
-39
lines changed

2 files changed

+19
-39
lines changed

drivers/net/ethernet/sun/cassini.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,34 +1716,26 @@ static int cas_pci_interrupt(struct net_device *dev, struct cas *cp,
17161716
pr_cont("\n");
17171717

17181718
if (stat & PCI_ERR_OTHER) {
1719-
u16 cfg;
1719+
int pci_errs;
17201720

17211721
/* Interrogate PCI config space for the
17221722
* true cause.
17231723
*/
1724-
pci_read_config_word(cp->pdev, PCI_STATUS, &cfg);
1725-
netdev_err(dev, "Read PCI cfg space status [%04x]\n", cfg);
1726-
if (cfg & PCI_STATUS_PARITY)
1724+
pci_errs = pci_status_get_and_clear_errors(cp->pdev);
1725+
1726+
netdev_err(dev, "PCI status errors[%04x]\n", pci_errs);
1727+
if (pci_errs & PCI_STATUS_PARITY)
17271728
netdev_err(dev, "PCI parity error detected\n");
1728-
if (cfg & PCI_STATUS_SIG_TARGET_ABORT)
1729+
if (pci_errs & PCI_STATUS_SIG_TARGET_ABORT)
17291730
netdev_err(dev, "PCI target abort\n");
1730-
if (cfg & PCI_STATUS_REC_TARGET_ABORT)
1731+
if (pci_errs & PCI_STATUS_REC_TARGET_ABORT)
17311732
netdev_err(dev, "PCI master acks target abort\n");
1732-
if (cfg & PCI_STATUS_REC_MASTER_ABORT)
1733+
if (pci_errs & PCI_STATUS_REC_MASTER_ABORT)
17331734
netdev_err(dev, "PCI master abort\n");
1734-
if (cfg & PCI_STATUS_SIG_SYSTEM_ERROR)
1735+
if (pci_errs & PCI_STATUS_SIG_SYSTEM_ERROR)
17351736
netdev_err(dev, "PCI system error SERR#\n");
1736-
if (cfg & PCI_STATUS_DETECTED_PARITY)
1737+
if (pci_errs & PCI_STATUS_DETECTED_PARITY)
17371738
netdev_err(dev, "PCI parity error\n");
1738-
1739-
/* Write the error bits back to clear them. */
1740-
cfg &= (PCI_STATUS_PARITY |
1741-
PCI_STATUS_SIG_TARGET_ABORT |
1742-
PCI_STATUS_REC_TARGET_ABORT |
1743-
PCI_STATUS_REC_MASTER_ABORT |
1744-
PCI_STATUS_SIG_SYSTEM_ERROR |
1745-
PCI_STATUS_DETECTED_PARITY);
1746-
pci_write_config_word(cp->pdev, PCI_STATUS, cfg);
17471739
}
17481740

17491741
/* For all PCI errors, we should reset the chip. */

drivers/net/ethernet/sun/sungem.c

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -545,37 +545,25 @@ static int gem_pci_interrupt(struct net_device *dev, struct gem *gp, u32 gem_sta
545545
}
546546

547547
if (pci_estat & GREG_PCIESTAT_OTHER) {
548-
u16 pci_cfg_stat;
548+
int pci_errs;
549549

550550
/* Interrogate PCI config space for the
551551
* true cause.
552552
*/
553-
pci_read_config_word(gp->pdev, PCI_STATUS,
554-
&pci_cfg_stat);
555-
netdev_err(dev, "Read PCI cfg space status [%04x]\n",
556-
pci_cfg_stat);
557-
if (pci_cfg_stat & PCI_STATUS_PARITY)
553+
pci_errs = pci_status_get_and_clear_errors(gp->pdev);
554+
netdev_err(dev, "PCI status errors[%04x]\n", pci_errs);
555+
if (pci_errs & PCI_STATUS_PARITY)
558556
netdev_err(dev, "PCI parity error detected\n");
559-
if (pci_cfg_stat & PCI_STATUS_SIG_TARGET_ABORT)
557+
if (pci_errs & PCI_STATUS_SIG_TARGET_ABORT)
560558
netdev_err(dev, "PCI target abort\n");
561-
if (pci_cfg_stat & PCI_STATUS_REC_TARGET_ABORT)
559+
if (pci_errs & PCI_STATUS_REC_TARGET_ABORT)
562560
netdev_err(dev, "PCI master acks target abort\n");
563-
if (pci_cfg_stat & PCI_STATUS_REC_MASTER_ABORT)
561+
if (pci_errs & PCI_STATUS_REC_MASTER_ABORT)
564562
netdev_err(dev, "PCI master abort\n");
565-
if (pci_cfg_stat & PCI_STATUS_SIG_SYSTEM_ERROR)
563+
if (pci_errs & PCI_STATUS_SIG_SYSTEM_ERROR)
566564
netdev_err(dev, "PCI system error SERR#\n");
567-
if (pci_cfg_stat & PCI_STATUS_DETECTED_PARITY)
565+
if (pci_errs & PCI_STATUS_DETECTED_PARITY)
568566
netdev_err(dev, "PCI parity error\n");
569-
570-
/* Write the error bits back to clear them. */
571-
pci_cfg_stat &= (PCI_STATUS_PARITY |
572-
PCI_STATUS_SIG_TARGET_ABORT |
573-
PCI_STATUS_REC_TARGET_ABORT |
574-
PCI_STATUS_REC_MASTER_ABORT |
575-
PCI_STATUS_SIG_SYSTEM_ERROR |
576-
PCI_STATUS_DETECTED_PARITY);
577-
pci_write_config_word(gp->pdev,
578-
PCI_STATUS, pci_cfg_stat);
579567
}
580568

581569
/* For all PCI errors, we should reset the chip. */

0 commit comments

Comments
 (0)