net: sun: use pci_status_get_and_clear_errors
authorHeiner Kallweit <hkallweit1@gmail.com>
Sat, 29 Feb 2020 22:26:49 +0000 (23:26 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 4 Mar 2020 22:21:00 +0000 (14:21 -0800)
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>
drivers/net/ethernet/sun/cassini.c
drivers/net/ethernet/sun/sungem.c

index 6ec9163e232c41c12e95a50ab62fdffb4949864b..e6d1aa882fa5b116b224ce9c801664954d075f36 100644 (file)
@@ -1716,34 +1716,26 @@ static int cas_pci_interrupt(struct net_device *dev, struct cas *cp,
        pr_cont("\n");
 
        if (stat & PCI_ERR_OTHER) {
-               u16 cfg;
+               int pci_errs;
 
                /* Interrogate PCI config space for the
                 * true cause.
                 */
-               pci_read_config_word(cp->pdev, PCI_STATUS, &cfg);
-               netdev_err(dev, "Read PCI cfg space status [%04x]\n", cfg);
-               if (cfg & PCI_STATUS_PARITY)
+               pci_errs = pci_status_get_and_clear_errors(cp->pdev);
+
+               netdev_err(dev, "PCI status errors[%04x]\n", pci_errs);
+               if (pci_errs & PCI_STATUS_PARITY)
                        netdev_err(dev, "PCI parity error detected\n");
-               if (cfg & PCI_STATUS_SIG_TARGET_ABORT)
+               if (pci_errs & PCI_STATUS_SIG_TARGET_ABORT)
                        netdev_err(dev, "PCI target abort\n");
-               if (cfg & PCI_STATUS_REC_TARGET_ABORT)
+               if (pci_errs & PCI_STATUS_REC_TARGET_ABORT)
                        netdev_err(dev, "PCI master acks target abort\n");
-               if (cfg & PCI_STATUS_REC_MASTER_ABORT)
+               if (pci_errs & PCI_STATUS_REC_MASTER_ABORT)
                        netdev_err(dev, "PCI master abort\n");
-               if (cfg & PCI_STATUS_SIG_SYSTEM_ERROR)
+               if (pci_errs & PCI_STATUS_SIG_SYSTEM_ERROR)
                        netdev_err(dev, "PCI system error SERR#\n");
-               if (cfg & PCI_STATUS_DETECTED_PARITY)
+               if (pci_errs & PCI_STATUS_DETECTED_PARITY)
                        netdev_err(dev, "PCI parity error\n");
-
-               /* Write the error bits back to clear them. */
-               cfg &= (PCI_STATUS_PARITY |
-                       PCI_STATUS_SIG_TARGET_ABORT |
-                       PCI_STATUS_REC_TARGET_ABORT |
-                       PCI_STATUS_REC_MASTER_ABORT |
-                       PCI_STATUS_SIG_SYSTEM_ERROR |
-                       PCI_STATUS_DETECTED_PARITY);
-               pci_write_config_word(cp->pdev, PCI_STATUS, cfg);
        }
 
        /* For all PCI errors, we should reset the chip. */
index 8358064fbd488b93163dadd342b0469c4f7c0aa6..2d392a7b179a0311e1f19c4bd01f91112398d85f 100644 (file)
@@ -545,37 +545,25 @@ static int gem_pci_interrupt(struct net_device *dev, struct gem *gp, u32 gem_sta
        }
 
        if (pci_estat & GREG_PCIESTAT_OTHER) {
-               u16 pci_cfg_stat;
+               int pci_errs;
 
                /* Interrogate PCI config space for the
                 * true cause.
                 */
-               pci_read_config_word(gp->pdev, PCI_STATUS,
-                                    &pci_cfg_stat);
-               netdev_err(dev, "Read PCI cfg space status [%04x]\n",
-                          pci_cfg_stat);
-               if (pci_cfg_stat & PCI_STATUS_PARITY)
+               pci_errs = pci_status_get_and_clear_errors(gp->pdev);
+               netdev_err(dev, "PCI status errors[%04x]\n", pci_errs);
+               if (pci_errs & PCI_STATUS_PARITY)
                        netdev_err(dev, "PCI parity error detected\n");
-               if (pci_cfg_stat & PCI_STATUS_SIG_TARGET_ABORT)
+               if (pci_errs & PCI_STATUS_SIG_TARGET_ABORT)
                        netdev_err(dev, "PCI target abort\n");
-               if (pci_cfg_stat & PCI_STATUS_REC_TARGET_ABORT)
+               if (pci_errs & PCI_STATUS_REC_TARGET_ABORT)
                        netdev_err(dev, "PCI master acks target abort\n");
-               if (pci_cfg_stat & PCI_STATUS_REC_MASTER_ABORT)
+               if (pci_errs & PCI_STATUS_REC_MASTER_ABORT)
                        netdev_err(dev, "PCI master abort\n");
-               if (pci_cfg_stat & PCI_STATUS_SIG_SYSTEM_ERROR)
+               if (pci_errs & PCI_STATUS_SIG_SYSTEM_ERROR)
                        netdev_err(dev, "PCI system error SERR#\n");
-               if (pci_cfg_stat & PCI_STATUS_DETECTED_PARITY)
+               if (pci_errs & PCI_STATUS_DETECTED_PARITY)
                        netdev_err(dev, "PCI parity error\n");
-
-               /* Write the error bits back to clear them. */
-               pci_cfg_stat &= (PCI_STATUS_PARITY |
-                                PCI_STATUS_SIG_TARGET_ABORT |
-                                PCI_STATUS_REC_TARGET_ABORT |
-                                PCI_STATUS_REC_MASTER_ABORT |
-                                PCI_STATUS_SIG_SYSTEM_ERROR |
-                                PCI_STATUS_DETECTED_PARITY);
-               pci_write_config_word(gp->pdev,
-                                     PCI_STATUS, pci_cfg_stat);
        }
 
        /* For all PCI errors, we should reset the chip. */