net: dsa: microchip: Replace ksz9477_wait_alu_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: Marek 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: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
0f9c36e36b
commit
ef534195e1
@@ -176,22 +176,12 @@ static void ksz9477_write_table(struct ksz_device *dev, u32 *table)
|
|||||||
ksz_write32(dev, REG_SW_ALU_VAL_D, table[3]);
|
ksz_write32(dev, REG_SW_ALU_VAL_D, table[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ksz9477_wait_alu_ready(struct ksz_device *dev, u32 waiton,
|
static int ksz9477_wait_alu_ready(struct ksz_device *dev)
|
||||||
int timeout)
|
|
||||||
{
|
{
|
||||||
u32 data;
|
unsigned int val;
|
||||||
|
|
||||||
do {
|
return regmap_read_poll_timeout(dev->regmap[2], REG_SW_ALU_CTRL__4,
|
||||||
ksz_read32(dev, REG_SW_ALU_CTRL__4, &data);
|
val, !(val & ALU_START), 10, 1000);
|
||||||
if (!(data & waiton))
|
|
||||||
break;
|
|
||||||
usleep_range(1, 10);
|
|
||||||
} while (timeout-- > 0);
|
|
||||||
|
|
||||||
if (timeout <= 0)
|
|
||||||
return -ETIMEDOUT;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ksz9477_wait_alu_sta_ready(struct ksz_device *dev, u32 waiton,
|
static int ksz9477_wait_alu_sta_ready(struct ksz_device *dev, u32 waiton,
|
||||||
@@ -633,8 +623,8 @@ static int ksz9477_port_fdb_add(struct dsa_switch *ds, int port,
|
|||||||
ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_READ | ALU_START);
|
ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_READ | ALU_START);
|
||||||
|
|
||||||
/* wait to be finished */
|
/* wait to be finished */
|
||||||
ret = ksz9477_wait_alu_ready(dev, ALU_START, 1000);
|
ret = ksz9477_wait_alu_ready(dev);
|
||||||
if (ret < 0) {
|
if (ret) {
|
||||||
dev_dbg(dev->dev, "Failed to read ALU\n");
|
dev_dbg(dev->dev, "Failed to read ALU\n");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@@ -657,8 +647,8 @@ static int ksz9477_port_fdb_add(struct dsa_switch *ds, int port,
|
|||||||
ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_WRITE | ALU_START);
|
ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_WRITE | ALU_START);
|
||||||
|
|
||||||
/* wait to be finished */
|
/* wait to be finished */
|
||||||
ret = ksz9477_wait_alu_ready(dev, ALU_START, 1000);
|
ret = ksz9477_wait_alu_ready(dev);
|
||||||
if (ret < 0)
|
if (ret)
|
||||||
dev_dbg(dev->dev, "Failed to write ALU\n");
|
dev_dbg(dev->dev, "Failed to write ALU\n");
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@@ -690,8 +680,8 @@ static int ksz9477_port_fdb_del(struct dsa_switch *ds, int port,
|
|||||||
ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_READ | ALU_START);
|
ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_READ | ALU_START);
|
||||||
|
|
||||||
/* wait to be finished */
|
/* wait to be finished */
|
||||||
ret = ksz9477_wait_alu_ready(dev, ALU_START, 1000);
|
ret = ksz9477_wait_alu_ready(dev);
|
||||||
if (ret < 0) {
|
if (ret) {
|
||||||
dev_dbg(dev->dev, "Failed to read ALU\n");
|
dev_dbg(dev->dev, "Failed to read ALU\n");
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@@ -724,8 +714,8 @@ static int ksz9477_port_fdb_del(struct dsa_switch *ds, int port,
|
|||||||
ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_WRITE | ALU_START);
|
ksz_write32(dev, REG_SW_ALU_CTRL__4, ALU_WRITE | ALU_START);
|
||||||
|
|
||||||
/* wait to be finished */
|
/* wait to be finished */
|
||||||
ret = ksz9477_wait_alu_ready(dev, ALU_START, 1000);
|
ret = ksz9477_wait_alu_ready(dev);
|
||||||
if (ret < 0)
|
if (ret)
|
||||||
dev_dbg(dev->dev, "Failed to write ALU\n");
|
dev_dbg(dev->dev, "Failed to write ALU\n");
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
Reference in New Issue
Block a user