Commit 0f9c36e3 authored by Marek Vasut's avatar Marek Vasut Committed by David S. Miller

net: dsa: microchip: Replace ksz9477_wait_vlan_ctrl_ready polling with regmap

Regmap provides polling function to poll for bits in a register. This
function is another reimplementation of polling for bit being clear in
a register. Replace this with regmap polling function. Moreover, inline
the function parameters, as the function is never called with any other
parameter values than this one.
Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Tristram Ha <Tristram.Ha@microchip.com>
Cc: Woojung Huh <Woojung.Huh@microchip.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1c1eb580
...@@ -89,22 +89,12 @@ static void ksz9477_port_cfg32(struct ksz_device *dev, int port, int offset, ...@@ -89,22 +89,12 @@ static void ksz9477_port_cfg32(struct ksz_device *dev, int port, int offset,
bits, set ? bits : 0); bits, set ? bits : 0);
} }
static int ksz9477_wait_vlan_ctrl_ready(struct ksz_device *dev, u32 waiton, static int ksz9477_wait_vlan_ctrl_ready(struct ksz_device *dev)
int timeout)
{ {
u8 data; unsigned int val;
do {
ksz_read8(dev, REG_SW_VLAN_CTRL, &data);
if (!(data & waiton))
break;
usleep_range(1, 10);
} while (timeout-- > 0);
if (timeout <= 0)
return -ETIMEDOUT;
return 0; return regmap_read_poll_timeout(dev->regmap[0], REG_SW_VLAN_CTRL,
val, !(val & VLAN_START), 10, 1000);
} }
static int ksz9477_get_vlan_table(struct ksz_device *dev, u16 vid, static int ksz9477_get_vlan_table(struct ksz_device *dev, u16 vid,
...@@ -118,8 +108,8 @@ static int ksz9477_get_vlan_table(struct ksz_device *dev, u16 vid, ...@@ -118,8 +108,8 @@ static int ksz9477_get_vlan_table(struct ksz_device *dev, u16 vid,
ksz_write8(dev, REG_SW_VLAN_CTRL, VLAN_READ | VLAN_START); ksz_write8(dev, REG_SW_VLAN_CTRL, VLAN_READ | VLAN_START);
/* wait to be cleared */ /* wait to be cleared */
ret = ksz9477_wait_vlan_ctrl_ready(dev, VLAN_START, 1000); ret = ksz9477_wait_vlan_ctrl_ready(dev);
if (ret < 0) { if (ret) {
dev_dbg(dev->dev, "Failed to read vlan table\n"); dev_dbg(dev->dev, "Failed to read vlan table\n");
goto exit; goto exit;
} }
...@@ -151,8 +141,8 @@ static int ksz9477_set_vlan_table(struct ksz_device *dev, u16 vid, ...@@ -151,8 +141,8 @@ static int ksz9477_set_vlan_table(struct ksz_device *dev, u16 vid,
ksz_write8(dev, REG_SW_VLAN_CTRL, VLAN_START | VLAN_WRITE); ksz_write8(dev, REG_SW_VLAN_CTRL, VLAN_START | VLAN_WRITE);
/* wait to be cleared */ /* wait to be cleared */
ret = ksz9477_wait_vlan_ctrl_ready(dev, VLAN_START, 1000); ret = ksz9477_wait_vlan_ctrl_ready(dev);
if (ret < 0) { if (ret) {
dev_dbg(dev->dev, "Failed to write vlan table\n"); dev_dbg(dev->dev, "Failed to write vlan table\n");
goto exit; goto exit;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment