mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
[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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
f859581519
commit
c45d286e72
5 changed files with 18 additions and 10 deletions
|
|
@ -372,9 +372,9 @@ static __inline__ int led_get_net_activity(void)
|
|||
continue;
|
||||
if (LOOPBACK(in_dev->ifa_list->ifa_local))
|
||||
continue;
|
||||
if (!dev->get_stats)
|
||||
continue;
|
||||
stats = dev->get_stats(dev);
|
||||
if (!stats)
|
||||
continue;
|
||||
rx_total += stats->rx_packets;
|
||||
tx_total += stats->tx_packets;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue