diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c index 9ee6bc1..3e6e62c 100644 --- a/net/wireless/sysfs.c +++ b/net/wireless/sysfs.c @@ -18,6 +18,34 @@ #include "core.h" #include "rdev-ops.h" +/* this needs to go into the header file, obviously */ +#include +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0) +#define DEVICE_ATTR_RO(_name) \ +struct device_attribute dev_attr_ ## _name = __ATTR_RO(_name); + +#define ATTRIBUTE_GROUPS(x) \ +static struct BP_ATTR_GRP_STRUCT x ## _dev_attrs[ARRAY_SIZE(x ## _attrs)];\ +static void init_ ## x ## _attrs(void) \ +{ \ + int i; \ + for (i = 0; x ## _attrs[i]; i++) \ + x ## _dev_attrs[i] = \ + *container_of(x ## _attrs[i], \ + struct BP_ATTR_GRP_STRUCT, \ + attr); \ +} +#else +#undef ATTRIBUTE_GROUPS +#define ATTRIBUTE_GROUPS(_name) \ +static const struct attribute_group _name##_group = { \ + .attrs = _name##_attrs, \ +}; \ +static inline void init_ ## x ## _attrs(void) {} \ +__ATTRIBUTE_GROUPS(_name) +#endif + + static inline struct cfg80211_registered_device *dev_to_rdev( struct device *dev) { @@ -71,6 +99,7 @@ static struct attribute *ieee80211_attrs[] = { &dev_attr_name.attr, NULL, }; +#define BP_ATTR_GRP_STRUCT device_attribute ATTRIBUTE_GROUPS(ieee80211); static void wiphy_dev_release(struct device *dev) @@ -149,7 +178,11 @@ struct class ieee80211_class = { .name = "ieee80211", .owner = THIS_MODULE, .dev_release = wiphy_dev_release, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0) .dev_groups = ieee80211_groups, +#else + .dev_attrs = ieee80211_dev_attrs, +#endif .dev_uevent = wiphy_uevent, #ifdef CONFIG_PM .suspend = wiphy_suspend, @@ -161,6 +194,7 @@ struct class ieee80211_class = { int wiphy_sysfs_init(void) { + init_ieee80211_attrs(); return class_register(&ieee80211_class); }