Patchwork [-next] pch_gbe: fix if condition in set_settings()

login
register
mail settings
Submitter Dan Carpenter
Date Oct. 13, 2010, 9:36 a.m.
Message ID <20101013093619.GC6060@bicker>
Download mbox | patch
Permalink /patch/67665/
State Accepted
Delegated to: David Miller
Headers show

Comments

Dan Carpenter - Oct. 13, 2010, 9:36 a.m.
There were no curly braces in this if condition so it always enabled full
duplex.

And ecmd->speed is an unsigned short so it is never equal to -1.  The
effect is that mii_ethtool_sset() fails with -EINVAL and an error is
printed to dmesg.

Signed-off-by: Dan Carpenter <error27@gmail.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Oct. 16, 2010, 6:55 p.m.
From: Dan Carpenter <error27@gmail.com>
Date: Wed, 13 Oct 2010 11:36:19 +0200

> There were no curly braces in this if condition so it always enabled full
> duplex.
> 
> And ecmd->speed is an unsigned short so it is never equal to -1.  The
> effect is that mii_ethtool_sset() fails with -EINVAL and an error is
> printed to dmesg.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/pch_gbe/pch_gbe_ethtool.c b/drivers/net/pch_gbe/pch_gbe_ethtool.c
index e06c6ae..c8cc32c 100644
--- a/drivers/net/pch_gbe/pch_gbe_ethtool.c
+++ b/drivers/net/pch_gbe/pch_gbe_ethtool.c
@@ -113,9 +113,10 @@  static int pch_gbe_set_settings(struct net_device *netdev,
 
 	pch_gbe_hal_write_phy_reg(hw, MII_BMCR, BMCR_RESET);
 
-	if (ecmd->speed == -1)
+	if (ecmd->speed == USHRT_MAX) {
 		ecmd->speed = SPEED_1000;
 		ecmd->duplex = DUPLEX_FULL;
+	}
 	ret = mii_ethtool_sset(&adapter->mii, ecmd);
 	if (ret) {
 		pr_err("Error: mii_ethtool_sset\n");