aboutsummaryrefslogtreecommitdiffstats
path: root/net/bridge/br_if.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/bridge/br_if.c')
-rw-r--r--net/bridge/br_if.c41
1 files changed, 15 insertions, 26 deletions
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 7b4ce9113be2..b40dada002bf 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -29,35 +29,24 @@
29 * Determine initial path cost based on speed. 29 * Determine initial path cost based on speed.
30 * using recommendations from 802.1d standard 30 * using recommendations from 802.1d standard
31 * 31 *
32 * Need to simulate user ioctl because not all device's that support 32 * Since driver might sleep need to not be holding any locks.
33 * ethtool, use ethtool_ops. Also, since driver might sleep need to
34 * not be holding any locks.
35 */ 33 */
36static int port_cost(struct net_device *dev) 34static int port_cost(struct net_device *dev)
37{ 35{
38 struct ethtool_cmd ecmd = { ETHTOOL_GSET }; 36 if (dev->ethtool_ops->get_settings) {
39 struct ifreq ifr; 37 struct ethtool_cmd ecmd = { ETHTOOL_GSET };
40 mm_segment_t old_fs; 38 int err = dev->ethtool_ops->get_settings(dev, &ecmd);
41 int err; 39 if (!err) {
42 40 switch(ecmd.speed) {
43 strncpy(ifr.ifr_name, dev->name, IFNAMSIZ); 41 case SPEED_100:
44 ifr.ifr_data = (void __user *) &ecmd; 42 return 19;
45 43 case SPEED_1000:
46 old_fs = get_fs(); 44 return 4;
47 set_fs(KERNEL_DS); 45 case SPEED_10000:
48 err = dev_ethtool(&ifr); 46 return 2;
49 set_fs(old_fs); 47 case SPEED_10:
50 48 return 100;
51 if (!err) { 49 }
52 switch(ecmd.speed) {
53 case SPEED_100:
54 return 19;
55 case SPEED_1000:
56 return 4;
57 case SPEED_10000:
58 return 2;
59 case SPEED_10:
60 return 100;
61 } 50 }
62 } 51 }
63 52