提交 b8665c6c 编写于 作者: V Vivien Didelot 提交者: David S. Miller

net: dsa/mv88e6352: make mv88e6352_wait generic

Some busy bits are available in the global register 1, such as the ATU
Busy bit. We may want to use this function to wait for them to change,
so add a new parameter to mv88e6352_wait() instead of hard-coding
REG_GLOBAL2.

In the meantime, since the REG_READ() macro already checks for error,
remove the redundant check for ret < 0.
Signed-off-by: NVivien Didelot <vivien.didelot@savoirfairelinux.com>
Acked-by: NGuenter Roeck <linux@roeck-us.net>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 bb92ea5e
...@@ -22,17 +22,14 @@ ...@@ -22,17 +22,14 @@
#include <net/dsa.h> #include <net/dsa.h>
#include "mv88e6xxx.h" #include "mv88e6xxx.h"
static int mv88e6352_wait(struct dsa_switch *ds, int reg, u16 mask) static int mv88e6352_wait(struct dsa_switch *ds, int reg, int offset, u16 mask)
{ {
unsigned long timeout = jiffies + HZ / 10; unsigned long timeout = jiffies + HZ / 10;
while (time_before(jiffies, timeout)) { while (time_before(jiffies, timeout)) {
int ret; int ret;
ret = REG_READ(REG_GLOBAL2, reg); ret = REG_READ(reg, offset);
if (ret < 0)
return ret;
if (!(ret & mask)) if (!(ret & mask))
return 0; return 0;
...@@ -43,17 +40,17 @@ static int mv88e6352_wait(struct dsa_switch *ds, int reg, u16 mask) ...@@ -43,17 +40,17 @@ static int mv88e6352_wait(struct dsa_switch *ds, int reg, u16 mask)
static inline int mv88e6352_phy_wait(struct dsa_switch *ds) static inline int mv88e6352_phy_wait(struct dsa_switch *ds)
{ {
return mv88e6352_wait(ds, 0x18, 0x8000); return mv88e6352_wait(ds, REG_GLOBAL2, 0x18, 0x8000);
} }
static inline int mv88e6352_eeprom_load_wait(struct dsa_switch *ds) static inline int mv88e6352_eeprom_load_wait(struct dsa_switch *ds)
{ {
return mv88e6352_wait(ds, 0x14, 0x0800); return mv88e6352_wait(ds, REG_GLOBAL2, 0x14, 0x0800);
} }
static inline int mv88e6352_eeprom_busy_wait(struct dsa_switch *ds) static inline int mv88e6352_eeprom_busy_wait(struct dsa_switch *ds)
{ {
return mv88e6352_wait(ds, 0x14, 0x8000); return mv88e6352_wait(ds, REG_GLOBAL2, 0x14, 0x8000);
} }
static int __mv88e6352_phy_read(struct dsa_switch *ds, int addr, int regnum) static int __mv88e6352_phy_read(struct dsa_switch *ds, int addr, int regnum)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册