Commit f25247d8 authored by Colin Ian King's avatar Colin Ian King Committed by David S. Miller

net: phy: realtek: net: Fix less than zero comparison of a u16

The comparisons of the u16 values priv->phycr1 and priv->phycr2 to less
than zero always false because they are unsigned. Fix this by using an
int for the assignment and less than zero check.

Addresses-Coverity: ("Unsigned compared against 0")
Fixes: 0a4355c2 ("net: phy: realtek: add dt property to disable CLKOUT clock")
Fixes: d90db36a ("net: phy: realtek: add dt property to enable ALDPS mode")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 345502af
...@@ -94,24 +94,25 @@ static int rtl821x_probe(struct phy_device *phydev) ...@@ -94,24 +94,25 @@ static int rtl821x_probe(struct phy_device *phydev)
{ {
struct device *dev = &phydev->mdio.dev; struct device *dev = &phydev->mdio.dev;
struct rtl821x_priv *priv; struct rtl821x_priv *priv;
int ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
return -ENOMEM; return -ENOMEM;
priv->phycr1 = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR1); ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR1);
if (priv->phycr1 < 0) if (ret < 0)
return priv->phycr1; return ret;
priv->phycr1 &= (RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF); priv->phycr1 = ret & (RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF);
if (of_property_read_bool(dev->of_node, "realtek,aldps-enable")) if (of_property_read_bool(dev->of_node, "realtek,aldps-enable"))
priv->phycr1 |= RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF; priv->phycr1 |= RTL8211F_ALDPS_PLL_OFF | RTL8211F_ALDPS_ENABLE | RTL8211F_ALDPS_XTAL_OFF;
priv->phycr2 = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR2); ret = phy_read_paged(phydev, 0xa43, RTL8211F_PHYCR2);
if (priv->phycr2 < 0) if (ret < 0)
return priv->phycr2; return ret;
priv->phycr2 &= RTL8211F_CLKOUT_EN; priv->phycr2 = ret & RTL8211F_CLKOUT_EN;
if (of_property_read_bool(dev->of_node, "realtek,clkout-disable")) if (of_property_read_bool(dev->of_node, "realtek,clkout-disable"))
priv->phycr2 &= ~RTL8211F_CLKOUT_EN; priv->phycr2 &= ~RTL8211F_CLKOUT_EN;
......
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