[BRIDGE]: Fix OOPS when bridging device without ethtool.

Bridge code calls ethtool to get speed. The conversion to using
only ethtool_ops broke the case of devices without ethtool_ops.
This is a new regression in 2.6.23.

Rearranged the switch to a logical order, and use gcc initializer.

Ps: speed should have been part of the network device structure from
the start rather than burying it in ethtool.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
Acked-by: Matthew Wilcox <matthew@wil.cx>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Stephen Hemminger and committed by David S. Miller b4a488d1 df1c0b84

+8 -8
+8 -8
net/bridge/br_if.c
··· 33 */ 34 static int port_cost(struct net_device *dev) 35 { 36 - if (dev->ethtool_ops->get_settings) { 37 - struct ethtool_cmd ecmd = { ETHTOOL_GSET }; 38 - int err = dev->ethtool_ops->get_settings(dev, &ecmd); 39 - if (!err) { 40 switch(ecmd.speed) { 41 - case SPEED_100: 42 - return 19; 43 - case SPEED_1000: 44 - return 4; 45 case SPEED_10000: 46 return 2; 47 case SPEED_10: 48 return 100; 49 }
··· 33 */ 34 static int port_cost(struct net_device *dev) 35 { 36 + if (dev->ethtool_ops && dev->ethtool_ops->get_settings) { 37 + struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET, }; 38 + 39 + if (!dev->ethtool_ops->get_settings(dev, &ecmd)) { 40 switch(ecmd.speed) { 41 case SPEED_10000: 42 return 2; 43 + case SPEED_1000: 44 + return 4; 45 + case SPEED_100: 46 + return 19; 47 case SPEED_10: 48 return 100; 49 }