diff mbox

[rfc,2/5] r8169: rtl8169_set_speed_xmii cleanup.

Message ID 20110427203702.GE19708@electric-eye.fr.zoreil.com
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Francois Romieu April 27, 2011, 8:37 p.m. UTC
- use ADVERTISE_ALL
- shorten chipset version test

No functional change.

Careful readers will notice that the 'supports_gmii' flag is deduced
from the device PCI id. Though less specific than the chipset related
RTL_GIGA_MAC_VER_XY, it is currently good enough to detect a GMII
deprieved 810x.
Some features may push for a device specific configuration (improved
jumbo frame support for instance). 'supports_gmii' will follow this
path if / when the device PCI id stops working.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Cc: Realtek linux nic maintainers <nic_swsd@realtek.com>
---
 drivers/net/r8169.c |   14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

Comments

Ben Hutchings April 27, 2011, 9:13 p.m. UTC | #1
On Wed, 2011-04-27 at 22:37 +0200, Francois Romieu wrote:
> - use ADVERTISE_ALL
> - shorten chipset version test
> 
> No functional change.
> 
> Careful readers will notice that the 'supports_gmii' flag is deduced
> from the device PCI id. Though less specific than the chipset related
> RTL_GIGA_MAC_VER_XY, it is currently good enough to detect a GMII
> deprieved 810x.
> Some features may push for a device specific configuration (improved
> jumbo frame support for instance). 'supports_gmii' will follow this
> path if / when the device PCI id stops working.
> 
> Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
> Cc: Realtek linux nic maintainers <nic_swsd@realtek.com>
> ---
>  drivers/net/r8169.c |   14 ++------------
>  1 files changed, 2 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
> index 0bb0c0d..006f0df 100644
> --- a/drivers/net/r8169.c
> +++ b/drivers/net/r8169.c
> @@ -1242,8 +1242,7 @@ static int rtl8169_set_speed_xmii(struct net_device *dev,
>  		int auto_nego;
>  
>  		auto_nego = rtl_readphy(tp, MII_ADVERTISE);
> -		auto_nego &= ~(ADVERTISE_10HALF | ADVERTISE_10FULL |
> -				ADVERTISE_100HALF | ADVERTISE_100FULL);
> +		auto_nego &= ADVERTISE_ALL;
[...]

You mean ~ADVERTISE_ALL.  Though ADVERTISE_ALL is really not a good name
and I think this is clearer with the individual advertising flags
spelled out.

Ben.
diff mbox

Patch

diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 0bb0c0d..006f0df 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1242,8 +1242,7 @@  static int rtl8169_set_speed_xmii(struct net_device *dev,
 		int auto_nego;
 
 		auto_nego = rtl_readphy(tp, MII_ADVERTISE);
-		auto_nego &= ~(ADVERTISE_10HALF | ADVERTISE_10FULL |
-				ADVERTISE_100HALF | ADVERTISE_100FULL);
+		auto_nego &= ADVERTISE_ALL;
 
 		if (adv & ADVERTISED_10baseT_Half)
 			auto_nego |= ADVERTISE_10HALF;
@@ -1260,16 +1259,7 @@  static int rtl8169_set_speed_xmii(struct net_device *dev,
 		giga_ctrl &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
 
 		/* The 8100e/8101e/8102e do Fast Ethernet only. */
-		if ((tp->mac_version != RTL_GIGA_MAC_VER_07) &&
-		    (tp->mac_version != RTL_GIGA_MAC_VER_08) &&
-		    (tp->mac_version != RTL_GIGA_MAC_VER_09) &&
-		    (tp->mac_version != RTL_GIGA_MAC_VER_10) &&
-		    (tp->mac_version != RTL_GIGA_MAC_VER_13) &&
-		    (tp->mac_version != RTL_GIGA_MAC_VER_14) &&
-		    (tp->mac_version != RTL_GIGA_MAC_VER_15) &&
-		    (tp->mac_version != RTL_GIGA_MAC_VER_16) &&
-		    (tp->mac_version != RTL_GIGA_MAC_VER_29) &&
-		    (tp->mac_version != RTL_GIGA_MAC_VER_30)) {
+		if (tp->mii.supports_gmii) {
 			if (adv & ADVERTISED_1000baseT_Half)
 				giga_ctrl |= ADVERTISE_1000HALF;
 			if (adv & ADVERTISED_1000baseT_Full)