diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2007-03-28 17:29:08 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-04-26 01:28:26 -0400 |
commit | c45d286e72dd72c0229dc9e2849743ba427fee84 (patch) | |
tree | 1fb22a5e71c89043671380087def5bc419a37886 /drivers | |
parent | f85958151900f9d30fa5ff941b0ce71eaa45a7de (diff) |
[NET]: Inline net_device_stats
Network drivers which keep stats allocate their own stats structure
then write a get_stats() function to return them. It would be nice if
this were done by default.
1) Add a new "stats" field to "struct net_device".
2) Add a new feature field to say "this driver uses the internal one"
3) Have a default "get_stats" which returns NULL if that feature not set.
4) Change callers to check result of get_stats call for NULL, not if
->get_stats is set.
This should not break backwards compatibility with older drivers, yet
allow modern drivers to shed some boilerplate code.
Lightly tested: works for a modified lguest network driver.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 5 | ||||
-rw-r--r-- | drivers/parisc/led.c | 4 |
2 files changed, 4 insertions, 5 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 76d3504505bd..cea3783c92c5 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -3640,9 +3640,8 @@ static struct net_device_stats *bond_get_stats(struct net_device *bond_dev) | |||
3640 | read_lock_bh(&bond->lock); | 3640 | read_lock_bh(&bond->lock); |
3641 | 3641 | ||
3642 | bond_for_each_slave(bond, slave, i) { | 3642 | bond_for_each_slave(bond, slave, i) { |
3643 | if (slave->dev->get_stats) { | 3643 | sstats = slave->dev->get_stats(slave->dev); |
3644 | sstats = slave->dev->get_stats(slave->dev); | 3644 | if (sstats) { |
3645 | |||
3646 | stats->rx_packets += sstats->rx_packets; | 3645 | stats->rx_packets += sstats->rx_packets; |
3647 | stats->rx_bytes += sstats->rx_bytes; | 3646 | stats->rx_bytes += sstats->rx_bytes; |
3648 | stats->rx_errors += sstats->rx_errors; | 3647 | stats->rx_errors += sstats->rx_errors; |
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index d190c05d87ed..453e6829756c 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c | |||
@@ -372,9 +372,9 @@ static __inline__ int led_get_net_activity(void) | |||
372 | continue; | 372 | continue; |
373 | if (LOOPBACK(in_dev->ifa_list->ifa_local)) | 373 | if (LOOPBACK(in_dev->ifa_list->ifa_local)) |
374 | continue; | 374 | continue; |
375 | if (!dev->get_stats) | ||
376 | continue; | ||
377 | stats = dev->get_stats(dev); | 375 | stats = dev->get_stats(dev); |
376 | if (!stats) | ||
377 | continue; | ||
378 | rx_total += stats->rx_packets; | 378 | rx_total += stats->rx_packets; |
379 | tx_total += stats->tx_packets; | 379 | tx_total += stats->tx_packets; |
380 | } | 380 | } |