[PATCH] fix /sys/class/net/<if>/wireless without dev->get_wireless_stats

dev->get_wireless_stats is deprecated but removing it also removes wireless
subdirectory in sysfs. This patch puts it back.

akpm: I don't know what's happening here.  This might be appropriate as a
2.6.15.x compatibility backport.  Waiting to hear from Jeff.

Signed-off-by: Andrey Borzenkov <arvidjaar@mail.ru>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jeff Garzik <jgarzik@pobox.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
Andrey Borzenkov 2006-01-09 20:51:28 -08:00 committed by Linus Torvalds
parent 0137ecfdc3
commit 6dd214b554

View File

@ -16,6 +16,7 @@
#include <net/sock.h> #include <net/sock.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/wireless.h> #include <linux/wireless.h>
#include <net/iw_handler.h>
#define to_class_dev(obj) container_of(obj,struct class_device,kobj) #define to_class_dev(obj) container_of(obj,struct class_device,kobj)
#define to_net_dev(class) container_of(class, struct net_device, class_dev) #define to_net_dev(class) container_of(class, struct net_device, class_dev)
@ -294,13 +295,19 @@ static ssize_t wireless_show(struct class_device *cd, char *buf,
char *)) char *))
{ {
struct net_device *dev = to_net_dev(cd); struct net_device *dev = to_net_dev(cd);
const struct iw_statistics *iw; const struct iw_statistics *iw = NULL;
ssize_t ret = -EINVAL; ssize_t ret = -EINVAL;
read_lock(&dev_base_lock); read_lock(&dev_base_lock);
if (dev_isalive(dev) && dev->get_wireless_stats if (dev_isalive(dev)) {
&& (iw = dev->get_wireless_stats(dev)) != NULL) if(dev->wireless_handlers &&
ret = (*format)(iw, buf); dev->wireless_handlers->get_wireless_stats)
iw = dev->wireless_handlers->get_wireless_stats(dev);
else if (dev->get_wireless_stats)
iw = dev->get_wireless_stats(dev);
if (iw != NULL)
ret = (*format)(iw, buf);
}
read_unlock(&dev_base_lock); read_unlock(&dev_base_lock);
return ret; return ret;
@ -402,7 +409,8 @@ void netdev_unregister_sysfs(struct net_device * net)
sysfs_remove_group(&class_dev->kobj, &netstat_group); sysfs_remove_group(&class_dev->kobj, &netstat_group);
#ifdef WIRELESS_EXT #ifdef WIRELESS_EXT
if (net->get_wireless_stats) if (net->get_wireless_stats || (net->wireless_handlers &&
net->wireless_handlers->get_wireless_stats))
sysfs_remove_group(&class_dev->kobj, &wireless_group); sysfs_remove_group(&class_dev->kobj, &wireless_group);
#endif #endif
class_device_del(class_dev); class_device_del(class_dev);
@ -427,10 +435,12 @@ int netdev_register_sysfs(struct net_device *net)
goto out_unreg; goto out_unreg;
#ifdef WIRELESS_EXT #ifdef WIRELESS_EXT
if (net->get_wireless_stats && if (net->get_wireless_stats || (net->wireless_handlers &&
(ret = sysfs_create_group(&class_dev->kobj, &wireless_group))) net->wireless_handlers->get_wireless_stats)) {
goto out_cleanup; ret = sysfs_create_group(&class_dev->kobj, &wireless_group);
if (ret)
goto out_cleanup;
}
return 0; return 0;
out_cleanup: out_cleanup:
if (net->get_stats) if (net->get_stats)