From: Hauke Mehrtens Date: Sun, 18 Aug 2013 23:37:52 +0000 (+0200) Subject: backports: backport sysfs api in wireless X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0409ddafc06381fd1fb4afab80ac37b273eb7119;p=openwrt%2Fstaging%2Fblogic.git backports: backport sysfs api in wireless Older kernel versions do not support the new sysfs api with dev_groups. This makes net/wireless/sysfs.c use the old api on older kernels. This is a backport of this commit: commit f0bc99c84349ce87af5b35839d19bfb17bb9b27f Author: Greg Kroah-Hartman Date: Wed Jul 24 15:05:35 2013 -0700 net: wireless: convert class code to use dev_groups This was mostly done by Johannes Berg . Signed-off-by: Hauke Mehrtens Cc: Johannes Berg Signed-off-by: Luis R. Rodriguez --- diff --git a/backport/backport-include/linux/device.h b/backport/backport-include/linux/device.h index 909a534c16fb..518803e73e66 100644 --- a/backport/backport-include/linux/device.h +++ b/backport/backport-include/linux/device.h @@ -188,4 +188,29 @@ backport_device_release_driver(struct device *dev) #define device_release_driver LINUX_BACKPORT(device_release_driver) #endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,0) */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0) +#define DEVICE_ATTR_RO(_name) \ +struct device_attribute dev_attr_ ## _name = __ATTR_RO(_name); + +#define ATTRIBUTE_GROUPS(_name) \ +static struct BP_ATTR_GRP_STRUCT _name##_dev_attrs[ARRAY_SIZE(_name##_attrs)];\ +static void init_##_name##_attrs(void) \ +{ \ + int i; \ + for (i = 0; _name##_attrs[i]; i++) \ + _name##_dev_attrs[i] = \ + *container_of(_name##_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_##_name##_attrs(void) {} \ +__ATTRIBUTE_GROUPS(_name) +#endif + #endif /* __BACKPORT_DEVICE_H */ diff --git a/patches/collateral-evolutions/network/76-sysfs-api/net_wireless_sysfs.patch b/patches/collateral-evolutions/network/76-sysfs-api/net_wireless_sysfs.patch new file mode 100644 index 000000000000..5537c2b9edf6 --- /dev/null +++ b/patches/collateral-evolutions/network/76-sysfs-api/net_wireless_sysfs.patch @@ -0,0 +1,30 @@ +--- a/net/wireless/sysfs.c ++++ b/net/wireless/sysfs.c +@@ -71,6 +71,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) +@@ -151,7 +152,11 @@ struct class ieee80211_class = { + .name = "ieee80211", + .owner = THIS_MODULE, + .dev_release = wiphy_dev_release, ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0) + .dev_groups = ieee80211_groups, ++#else ++ .dev_attrs = ieee80211_dev_attrs, ++#endif + .dev_uevent = wiphy_uevent, + #ifdef CONFIG_PM + .suspend = wiphy_suspend, +@@ -165,6 +170,7 @@ struct class ieee80211_class = { + + int wiphy_sysfs_init(void) + { ++ init_ieee80211_attrs(); + return class_register(&ieee80211_class); + } +