Commit 8887ca54 authored by Russell King's avatar Russell King Committed by David S. Miller

net: phy: at803x: simplify custom phy id matching

The at803x driver contains a function, at803x_match_phy_id(), which
tests whether the PHY ID matches the value passed, comparing phy_id
with phydev->phy_id and testing all bits that in the driver's mask.

This is the same test that is used to match the driver, with phy_id
replaced with the driver specified ID, phydev->drv->phy_id.

Hence, we already know the value of the bits being tested if we look
at phydev->drv->phy_id directly, and we do not require a complicated
test to check them. Test directly against phydev->drv->phy_id instead.
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: default avatarFabio Estevam <festevam@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fa660684
...@@ -532,12 +532,6 @@ static int at8031_register_regulators(struct phy_device *phydev) ...@@ -532,12 +532,6 @@ static int at8031_register_regulators(struct phy_device *phydev)
return 0; return 0;
} }
static bool at803x_match_phy_id(struct phy_device *phydev, u32 phy_id)
{
return (phydev->phy_id & phydev->drv->phy_id_mask)
== (phy_id & phydev->drv->phy_id_mask);
}
static int at803x_parse_dt(struct phy_device *phydev) static int at803x_parse_dt(struct phy_device *phydev)
{ {
struct device_node *node = phydev->mdio.dev.of_node; struct device_node *node = phydev->mdio.dev.of_node;
...@@ -602,8 +596,8 @@ static int at803x_parse_dt(struct phy_device *phydev) ...@@ -602,8 +596,8 @@ static int at803x_parse_dt(struct phy_device *phydev)
* to the AR8030 so there might be a good chance it works on * to the AR8030 so there might be a good chance it works on
* the AR8030 too. * the AR8030 too.
*/ */
if (at803x_match_phy_id(phydev, ATH8030_PHY_ID) || if (phydev->drv->phy_id == ATH8030_PHY_ID ||
at803x_match_phy_id(phydev, ATH8035_PHY_ID)) { phydev->drv->phy_id == ATH8035_PHY_ID) {
priv->clk_25m_reg &= AT8035_CLK_OUT_MASK; priv->clk_25m_reg &= AT8035_CLK_OUT_MASK;
priv->clk_25m_mask &= AT8035_CLK_OUT_MASK; priv->clk_25m_mask &= AT8035_CLK_OUT_MASK;
} }
...@@ -631,7 +625,7 @@ static int at803x_parse_dt(struct phy_device *phydev) ...@@ -631,7 +625,7 @@ static int at803x_parse_dt(struct phy_device *phydev)
/* Only supported on AR8031/AR8033, the AR8030/AR8035 use strapping /* Only supported on AR8031/AR8033, the AR8030/AR8035 use strapping
* options. * options.
*/ */
if (at803x_match_phy_id(phydev, ATH8031_PHY_ID)) { if (phydev->drv->phy_id == ATH8031_PHY_ID) {
if (of_property_read_bool(node, "qca,keep-pll-enabled")) if (of_property_read_bool(node, "qca,keep-pll-enabled"))
priv->flags |= AT803X_KEEP_PLL_ENABLED; priv->flags |= AT803X_KEEP_PLL_ENABLED;
...@@ -676,7 +670,7 @@ static int at803x_probe(struct phy_device *phydev) ...@@ -676,7 +670,7 @@ static int at803x_probe(struct phy_device *phydev)
* Switch to the copper page, as otherwise we read * Switch to the copper page, as otherwise we read
* the PHY capabilities from the fiber side. * the PHY capabilities from the fiber side.
*/ */
if (at803x_match_phy_id(phydev, ATH8031_PHY_ID)) { if (phydev->drv->phy_id == ATH8031_PHY_ID) {
phy_lock_mdio_bus(phydev); phy_lock_mdio_bus(phydev);
ret = at803x_write_page(phydev, AT803X_PAGE_COPPER); ret = at803x_write_page(phydev, AT803X_PAGE_COPPER);
phy_unlock_mdio_bus(phydev); phy_unlock_mdio_bus(phydev);
...@@ -820,7 +814,7 @@ static int at803x_config_init(struct phy_device *phydev) ...@@ -820,7 +814,7 @@ static int at803x_config_init(struct phy_device *phydev)
if (ret < 0) if (ret < 0)
return ret; return ret;
if (at803x_match_phy_id(phydev, ATH8031_PHY_ID)) { if (phydev->drv->phy_id == ATH8031_PHY_ID) {
ret = at8031_pll_config(phydev); ret = at8031_pll_config(phydev);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
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