diff options
author | David Decotigny <decot@google.com> | 2011-04-27 14:32:38 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-29 17:01:30 -0400 |
commit | 8ae6daca85c8bbd6a32c382db5e2a2a989f8bed2 (patch) | |
tree | 0c85476c2af6568c3d3a73a960d582d2f91a1256 /arch/mips | |
parent | 36504605432996590f889e33d47e2d9c581f7569 (diff) |
ethtool: Call ethtool's get/set_settings callbacks with cleaned data
This makes sure that when a driver calls the ethtool's
get/set_settings() callback of another driver, the data passed to it
is clean. This guarantees that speed_hi will be zeroed correctly if
the called callback doesn't explicitely set it: we are sure we don't
get a corrupted speed from the underlying driver. We also take care of
setting the cmd field appropriately (ETHTOOL_GSET/SSET).
This applies to dev_ethtool_get_settings(), which now makes sure it
sets up that ethtool command parameter correctly before passing it to
drivers. This also means that whoever calls dev_ethtool_get_settings()
does not have to clean the ethtool command parameter. This function
also becomes an exported symbol instead of an inline.
All drivers visible to make allyesconfig under x86_64 have been
updated.
Signed-off-by: David Decotigny <decot@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/txx9/generic/setup_tx4939.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/arch/mips/txx9/generic/setup_tx4939.c b/arch/mips/txx9/generic/setup_tx4939.c index 3dc19f482959..e9f95dcde379 100644 --- a/arch/mips/txx9/generic/setup_tx4939.c +++ b/arch/mips/txx9/generic/setup_tx4939.c | |||
@@ -318,19 +318,15 @@ void __init tx4939_sio_init(unsigned int sclk, unsigned int cts_mask) | |||
318 | } | 318 | } |
319 | 319 | ||
320 | #if defined(CONFIG_TC35815) || defined(CONFIG_TC35815_MODULE) | 320 | #if defined(CONFIG_TC35815) || defined(CONFIG_TC35815_MODULE) |
321 | static int tx4939_get_eth_speed(struct net_device *dev) | 321 | static u32 tx4939_get_eth_speed(struct net_device *dev) |
322 | { | 322 | { |
323 | struct ethtool_cmd cmd = { ETHTOOL_GSET }; | 323 | struct ethtool_cmd cmd; |
324 | int speed = 100; /* default 100Mbps */ | 324 | if (dev_ethtool_get_settings(dev, &cmd)) |
325 | int err; | 325 | return 100; /* default 100Mbps */ |
326 | if (!dev->ethtool_ops || !dev->ethtool_ops->get_settings) | 326 | |
327 | return speed; | 327 | return ethtool_cmd_speed(&cmd); |
328 | err = dev->ethtool_ops->get_settings(dev, &cmd); | ||
329 | if (err < 0) | ||
330 | return speed; | ||
331 | speed = cmd.speed == SPEED_100 ? 100 : 10; | ||
332 | return speed; | ||
333 | } | 328 | } |
329 | |||
334 | static int tx4939_netdev_event(struct notifier_block *this, | 330 | static int tx4939_netdev_event(struct notifier_block *this, |
335 | unsigned long event, | 331 | unsigned long event, |
336 | void *ptr) | 332 | void *ptr) |
@@ -343,8 +339,7 @@ static int tx4939_netdev_event(struct notifier_block *this, | |||
343 | else if (dev->irq == TXX9_IRQ_BASE + TX4939_IR_ETH(1)) | 339 | else if (dev->irq == TXX9_IRQ_BASE + TX4939_IR_ETH(1)) |
344 | bit = TX4939_PCFG_SPEED1; | 340 | bit = TX4939_PCFG_SPEED1; |
345 | if (bit) { | 341 | if (bit) { |
346 | int speed = tx4939_get_eth_speed(dev); | 342 | if (tx4939_get_eth_speed(dev) == 100) |
347 | if (speed == 100) | ||
348 | txx9_set64(&tx4939_ccfgptr->pcfg, bit); | 343 | txx9_set64(&tx4939_ccfgptr->pcfg, bit); |
349 | else | 344 | else |
350 | txx9_clear64(&tx4939_ccfgptr->pcfg, bit); | 345 | txx9_clear64(&tx4939_ccfgptr->pcfg, bit); |