提交 589d1976 编写于 作者: E Egil Hjelmeland 提交者: David S. Miller

net: dsa: lan9303: Adjust phy_addr_base expressions

Simplify calculation of chip->phy_addr_base in lan9303_detect_phy_setup().

Use GENMASK to calculate phys_mii_mask from LAN9303_NUM_PORTS and
phy_addr_base.
Signed-off-by: NEgil Hjelmeland <privat@egil-hjelmeland.no>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b17c6b1f
...@@ -495,10 +495,7 @@ static int lan9303_detect_phy_setup(struct lan9303 *chip) ...@@ -495,10 +495,7 @@ static int lan9303_detect_phy_setup(struct lan9303 *chip)
return reg; return reg;
} }
if ((reg != 0) && (reg != 0xffff)) chip->phy_addr_base = reg != 0 && reg != 0xffff;
chip->phy_addr_base = 1;
else
chip->phy_addr_base = 0;
dev_dbg(chip->dev, "Phy setup '%s' detected\n", dev_dbg(chip->dev, "Phy setup '%s' detected\n",
chip->phy_addr_base ? "1-2-3" : "0-1-2"); chip->phy_addr_base ? "1-2-3" : "0-1-2");
...@@ -1283,13 +1280,16 @@ static const struct dsa_switch_ops lan9303_switch_ops = { ...@@ -1283,13 +1280,16 @@ static const struct dsa_switch_ops lan9303_switch_ops = {
static int lan9303_register_switch(struct lan9303 *chip) static int lan9303_register_switch(struct lan9303 *chip)
{ {
int base;
chip->ds = dsa_switch_alloc(chip->dev, LAN9303_NUM_PORTS); chip->ds = dsa_switch_alloc(chip->dev, LAN9303_NUM_PORTS);
if (!chip->ds) if (!chip->ds)
return -ENOMEM; return -ENOMEM;
chip->ds->priv = chip; chip->ds->priv = chip;
chip->ds->ops = &lan9303_switch_ops; chip->ds->ops = &lan9303_switch_ops;
chip->ds->phys_mii_mask = chip->phy_addr_base ? 0xe : 0x7; base = chip->phy_addr_base;
chip->ds->phys_mii_mask = GENMASK(LAN9303_NUM_PORTS - 1 + base, base);
return dsa_register_switch(chip->ds); return dsa_register_switch(chip->ds);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册