]> www.infradead.org Git - users/willy/xarray.git/commitdiff
net: pch_gbe: use readx_poll_timeout_atomic() variant
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 10 May 2021 16:39:29 +0000 (19:39 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 10 May 2021 21:58:20 +0000 (14:58 -0700)
Use readx_poll_timeout_atomic() instead of open coded variants.

While at it, add __iomem attribute to the parameter of pch_gbe_wait_clr_bit().
This in particular will fix a lot of warnings detected by Sparse, e.g.

.../pch_gbe_main.c:308:26: warning: incorrect type in argument 1 (different address spaces)
.../pch_gbe_main.c:308:26:    expected void const [noderef] __iomem *
.../pch_gbe_main.c:308:26:    got void *reg

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Flavio Suligoi <f.suligoi@asem.it>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c

index 8adc8cfaca03384345c6d959c29bb6f0ad6390e7..7b224745bf3e7f85d72513ba7eca4ec9af853949 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/machine.h>
+#include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/net_tstamp.h>
 #include <linux/ptp_classify.h>
@@ -299,15 +300,12 @@ static s32 pch_gbe_mac_read_mac_addr(struct pch_gbe_hw *hw)
  * @reg:       Pointer of register
  * @bit:       Busy bit
  */
-static void pch_gbe_wait_clr_bit(void *reg, u32 bit)
+static void pch_gbe_wait_clr_bit(void __iomem *reg, u32 bit)
 {
        u32 tmp;
 
        /* wait busy */
-       tmp = 1000;
-       while ((ioread32(reg) & bit) && --tmp)
-               cpu_relax();
-       if (!tmp)
+       if (readx_poll_timeout_atomic(ioread32, reg, tmp, !(tmp & bit), 0, 10))
                pr_err("Error: busy bit is not cleared\n");
 }
 
@@ -491,18 +489,13 @@ u16 pch_gbe_mac_ctrl_miim(struct pch_gbe_hw *hw, u32 addr, u32 dir, u32 reg,
                        u16 data)
 {
        struct pch_gbe_adapter *adapter = pch_gbe_hw_to_adapter(hw);
-       u32 data_out = 0;
-       unsigned int i;
        unsigned long flags;
+       u32 data_out;
 
        spin_lock_irqsave(&hw->miim_lock, flags);
 
-       for (i = 100; i; --i) {
-               if ((ioread32(&hw->reg->MIIM) & PCH_GBE_MIIM_OPER_READY))
-                       break;
-               udelay(20);
-       }
-       if (i == 0) {
+       if (readx_poll_timeout_atomic(ioread32, &hw->reg->MIIM, data_out,
+                                     data_out & PCH_GBE_MIIM_OPER_READY, 20, 2000)) {
                netdev_err(adapter->netdev, "pch-gbe.miim won't go Ready\n");
                spin_unlock_irqrestore(&hw->miim_lock, flags);
                return 0;       /* No way to indicate timeout error */
@@ -510,12 +503,8 @@ u16 pch_gbe_mac_ctrl_miim(struct pch_gbe_hw *hw, u32 addr, u32 dir, u32 reg,
        iowrite32(((reg << PCH_GBE_MIIM_REG_ADDR_SHIFT) |
                  (addr << PCH_GBE_MIIM_PHY_ADDR_SHIFT) |
                  dir | data), &hw->reg->MIIM);
-       for (i = 0; i < 100; i++) {
-               udelay(20);
-               data_out = ioread32(&hw->reg->MIIM);
-               if ((data_out & PCH_GBE_MIIM_OPER_READY))
-                       break;
-       }
+       readx_poll_timeout_atomic(ioread32, &hw->reg->MIIM, data_out,
+                                 data_out & PCH_GBE_MIIM_OPER_READY, 20, 2000);
        spin_unlock_irqrestore(&hw->miim_lock, flags);
 
        netdev_dbg(adapter->netdev, "PHY %s: reg=%d, data=0x%04X\n",