diff options
Diffstat (limited to 'net')
| -rw-r--r-- | net/core/net-sysfs.c | 136 | ||||
| -rw-r--r-- | net/ieee802154/wpan-class.c | 23 | ||||
| -rw-r--r-- | net/rfkill/core.c | 90 | ||||
| -rw-r--r-- | net/wireless/sysfs.c | 25 |
4 files changed, 143 insertions, 131 deletions
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c index 981fed397d1d..707c3134ddf2 100644 --- a/net/core/net-sysfs.c +++ b/net/core/net-sysfs.c | |||
| @@ -60,12 +60,19 @@ static ssize_t format_##field(const struct net_device *net, char *buf) \ | |||
| 60 | { \ | 60 | { \ |
| 61 | return sprintf(buf, format_string, net->field); \ | 61 | return sprintf(buf, format_string, net->field); \ |
| 62 | } \ | 62 | } \ |
| 63 | static ssize_t show_##field(struct device *dev, \ | 63 | static ssize_t field##_show(struct device *dev, \ |
| 64 | struct device_attribute *attr, char *buf) \ | 64 | struct device_attribute *attr, char *buf) \ |
| 65 | { \ | 65 | { \ |
| 66 | return netdev_show(dev, attr, buf, format_##field); \ | 66 | return netdev_show(dev, attr, buf, format_##field); \ |
| 67 | } | 67 | } \ |
| 68 | |||
| 69 | #define NETDEVICE_SHOW_RO(field, format_string) \ | ||
| 70 | NETDEVICE_SHOW(field, format_string); \ | ||
| 71 | static DEVICE_ATTR_RO(field) | ||
| 68 | 72 | ||
| 73 | #define NETDEVICE_SHOW_RW(field, format_string) \ | ||
| 74 | NETDEVICE_SHOW(field, format_string); \ | ||
| 75 | static DEVICE_ATTR_RW(field) | ||
| 69 | 76 | ||
| 70 | /* use same locking and permission rules as SIF* ioctl's */ | 77 | /* use same locking and permission rules as SIF* ioctl's */ |
| 71 | static ssize_t netdev_store(struct device *dev, struct device_attribute *attr, | 78 | static ssize_t netdev_store(struct device *dev, struct device_attribute *attr, |
| @@ -96,16 +103,16 @@ static ssize_t netdev_store(struct device *dev, struct device_attribute *attr, | |||
| 96 | return ret; | 103 | return ret; |
| 97 | } | 104 | } |
| 98 | 105 | ||
| 99 | NETDEVICE_SHOW(dev_id, fmt_hex); | 106 | NETDEVICE_SHOW_RO(dev_id, fmt_hex); |
| 100 | NETDEVICE_SHOW(addr_assign_type, fmt_dec); | 107 | NETDEVICE_SHOW_RO(addr_assign_type, fmt_dec); |
| 101 | NETDEVICE_SHOW(addr_len, fmt_dec); | 108 | NETDEVICE_SHOW_RO(addr_len, fmt_dec); |
| 102 | NETDEVICE_SHOW(iflink, fmt_dec); | 109 | NETDEVICE_SHOW_RO(iflink, fmt_dec); |
| 103 | NETDEVICE_SHOW(ifindex, fmt_dec); | 110 | NETDEVICE_SHOW_RO(ifindex, fmt_dec); |
| 104 | NETDEVICE_SHOW(type, fmt_dec); | 111 | NETDEVICE_SHOW_RO(type, fmt_dec); |
| 105 | NETDEVICE_SHOW(link_mode, fmt_dec); | 112 | NETDEVICE_SHOW_RO(link_mode, fmt_dec); |
| 106 | 113 | ||
| 107 | /* use same locking rules as GIFHWADDR ioctl's */ | 114 | /* use same locking rules as GIFHWADDR ioctl's */ |
| 108 | static ssize_t show_address(struct device *dev, struct device_attribute *attr, | 115 | static ssize_t address_show(struct device *dev, struct device_attribute *attr, |
| 109 | char *buf) | 116 | char *buf) |
| 110 | { | 117 | { |
| 111 | struct net_device *net = to_net_dev(dev); | 118 | struct net_device *net = to_net_dev(dev); |
| @@ -117,15 +124,17 @@ static ssize_t show_address(struct device *dev, struct device_attribute *attr, | |||
| 117 | read_unlock(&dev_base_lock); | 124 | read_unlock(&dev_base_lock); |
| 118 | return ret; | 125 | return ret; |
| 119 | } | 126 | } |
| 127 | static DEVICE_ATTR_RO(address); | ||
| 120 | 128 | ||
| 121 | static ssize_t show_broadcast(struct device *dev, | 129 | static ssize_t broadcast_show(struct device *dev, |
| 122 | struct device_attribute *attr, char *buf) | 130 | struct device_attribute *attr, char *buf) |
| 123 | { | 131 | { |
| 124 | struct net_device *net = to_net_dev(dev); | 132 | struct net_device *net = to_net_dev(dev); |
| 125 | if (dev_isalive(net)) | 133 | if (dev_isalive(net)) |
| 126 | return sysfs_format_mac(buf, net->broadcast, net->addr_len); | 134 | return sysfs_format_mac(buf, net->broadcast, net->addr_len); |
| 127 | return -EINVAL; | 135 | return -EINVAL; |
| 128 | } | 136 | } |
| 137 | static DEVICE_ATTR_RO(broadcast); | ||
| 129 | 138 | ||
| 130 | static int change_carrier(struct net_device *net, unsigned long new_carrier) | 139 | static int change_carrier(struct net_device *net, unsigned long new_carrier) |
| 131 | { | 140 | { |
| @@ -134,13 +143,13 @@ static int change_carrier(struct net_device *net, unsigned long new_carrier) | |||
| 134 | return dev_change_carrier(net, (bool) new_carrier); | 143 | return dev_change_carrier(net, (bool) new_carrier); |
| 135 | } | 144 | } |
| 136 | 145 | ||
| 137 | static ssize_t store_carrier(struct device *dev, struct device_attribute *attr, | 146 | static ssize_t carrier_store(struct device *dev, struct device_attribute *attr, |
| 138 | const char *buf, size_t len) | 147 | const char *buf, size_t len) |
| 139 | { | 148 | { |
| 140 | return netdev_store(dev, attr, buf, len, change_carrier); | 149 | return netdev_store(dev, attr, buf, len, change_carrier); |
| 141 | } | 150 | } |
| 142 | 151 | ||
| 143 | static ssize_t show_carrier(struct device *dev, | 152 | static ssize_t carrier_show(struct device *dev, |
| 144 | struct device_attribute *attr, char *buf) | 153 | struct device_attribute *attr, char *buf) |
| 145 | { | 154 | { |
| 146 | struct net_device *netdev = to_net_dev(dev); | 155 | struct net_device *netdev = to_net_dev(dev); |
| @@ -149,8 +158,9 @@ static ssize_t show_carrier(struct device *dev, | |||
| 149 | } | 158 | } |
| 150 | return -EINVAL; | 159 | return -EINVAL; |
| 151 | } | 160 | } |
| 161 | static DEVICE_ATTR_RW(carrier); | ||
| 152 | 162 | ||
| 153 | static ssize_t show_speed(struct device *dev, | 163 | static ssize_t speed_show(struct device *dev, |
| 154 | struct device_attribute *attr, char *buf) | 164 | struct device_attribute *attr, char *buf) |
| 155 | { | 165 | { |
| 156 | struct net_device *netdev = to_net_dev(dev); | 166 | struct net_device *netdev = to_net_dev(dev); |
| @@ -167,8 +177,9 @@ static ssize_t show_speed(struct device *dev, | |||
| 167 | rtnl_unlock(); | 177 | rtnl_unlock(); |
| 168 | return ret; | 178 | return ret; |
| 169 | } | 179 | } |
| 180 | static DEVICE_ATTR_RO(speed); | ||
| 170 | 181 | ||
| 171 | static ssize_t show_duplex(struct device *dev, | 182 | static ssize_t duplex_show(struct device *dev, |
| 172 | struct device_attribute *attr, char *buf) | 183 | struct device_attribute *attr, char *buf) |
| 173 | { | 184 | { |
| 174 | struct net_device *netdev = to_net_dev(dev); | 185 | struct net_device *netdev = to_net_dev(dev); |
| @@ -198,8 +209,9 @@ static ssize_t show_duplex(struct device *dev, | |||
| 198 | rtnl_unlock(); | 209 | rtnl_unlock(); |
| 199 | return ret; | 210 | return ret; |
| 200 | } | 211 | } |
| 212 | static DEVICE_ATTR_RO(duplex); | ||
| 201 | 213 | ||
| 202 | static ssize_t show_dormant(struct device *dev, | 214 | static ssize_t dormant_show(struct device *dev, |
| 203 | struct device_attribute *attr, char *buf) | 215 | struct device_attribute *attr, char *buf) |
| 204 | { | 216 | { |
| 205 | struct net_device *netdev = to_net_dev(dev); | 217 | struct net_device *netdev = to_net_dev(dev); |
| @@ -209,6 +221,7 @@ static ssize_t show_dormant(struct device *dev, | |||
| 209 | 221 | ||
| 210 | return -EINVAL; | 222 | return -EINVAL; |
| 211 | } | 223 | } |
| 224 | static DEVICE_ATTR_RO(dormant); | ||
| 212 | 225 | ||
| 213 | static const char *const operstates[] = { | 226 | static const char *const operstates[] = { |
| 214 | "unknown", | 227 | "unknown", |
| @@ -220,7 +233,7 @@ static const char *const operstates[] = { | |||
| 220 | "up" | 233 | "up" |
| 221 | }; | 234 | }; |
| 222 | 235 | ||
| 223 | static ssize_t show_operstate(struct device *dev, | 236 | static ssize_t operstate_show(struct device *dev, |
| 224 | struct device_attribute *attr, char *buf) | 237 | struct device_attribute *attr, char *buf) |
| 225 | { | 238 | { |
| 226 | const struct net_device *netdev = to_net_dev(dev); | 239 | const struct net_device *netdev = to_net_dev(dev); |
| @@ -237,35 +250,33 @@ static ssize_t show_operstate(struct device *dev, | |||
| 237 | 250 | ||
| 238 | return sprintf(buf, "%s\n", operstates[operstate]); | 251 | return sprintf(buf, "%s\n", operstates[operstate]); |
| 239 | } | 252 | } |
| 253 | static DEVICE_ATTR_RO(operstate); | ||
| 240 | 254 | ||
| 241 | /* read-write attributes */ | 255 | /* read-write attributes */ |
| 242 | NETDEVICE_SHOW(mtu, fmt_dec); | ||
| 243 | 256 | ||
| 244 | static int change_mtu(struct net_device *net, unsigned long new_mtu) | 257 | static int change_mtu(struct net_device *net, unsigned long new_mtu) |
| 245 | { | 258 | { |
| 246 | return dev_set_mtu(net, (int) new_mtu); | 259 | return dev_set_mtu(net, (int) new_mtu); |
| 247 | } | 260 | } |
| 248 | 261 | ||
| 249 | static ssize_t store_mtu(struct device *dev, struct device_attribute *attr, | 262 | static ssize_t mtu_store(struct device *dev, struct device_attribute *attr, |
| 250 | const char *buf, size_t len) | 263 | const char *buf, size_t len) |
| 251 | { | 264 | { |
| 252 | return netdev_store(dev, attr, buf, len, change_mtu); | 265 | return netdev_store(dev, attr, buf, len, change_mtu); |
| 253 | } | 266 | } |
| 254 | 267 | NETDEVICE_SHOW_RW(mtu, fmt_dec); | |
| 255 | NETDEVICE_SHOW(flags, fmt_hex); | ||
| 256 | 268 | ||
| 257 | static int change_flags(struct net_device *net, unsigned long new_flags) | 269 | static int change_flags(struct net_device *net, unsigned long new_flags) |
| 258 | { | 270 | { |
| 259 | return dev_change_flags(net, (unsigned int) new_flags); | 271 | return dev_change_flags(net, (unsigned int) new_flags); |
| 260 | } | 272 | } |
| 261 | 273 | ||
| 262 | static ssize_t store_flags(struct device *dev, struct device_attribute *attr, | 274 | static ssize_t flags_store(struct device *dev, struct device_attribute *attr, |
| 263 | const char *buf, size_t len) | 275 | const char *buf, size_t len) |
| 264 | { | 276 | { |
| 265 | return netdev_store(dev, attr, buf, len, change_flags); | 277 | return netdev_store(dev, attr, buf, len, change_flags); |
| 266 | } | 278 | } |
| 267 | 279 | NETDEVICE_SHOW_RW(flags, fmt_hex); | |
| 268 | NETDEVICE_SHOW(tx_queue_len, fmt_ulong); | ||
| 269 | 280 | ||
| 270 | static int change_tx_queue_len(struct net_device *net, unsigned long new_len) | 281 | static int change_tx_queue_len(struct net_device *net, unsigned long new_len) |
| 271 | { | 282 | { |
| @@ -273,7 +284,7 @@ static int change_tx_queue_len(struct net_device *net, unsigned long new_len) | |||
| 273 | return 0; | 284 | return 0; |
| 274 | } | 285 | } |
| 275 | 286 | ||
| 276 | static ssize_t store_tx_queue_len(struct device *dev, | 287 | static ssize_t tx_queue_len_store(struct device *dev, |
| 277 | struct device_attribute *attr, | 288 | struct device_attribute *attr, |
| 278 | const char *buf, size_t len) | 289 | const char *buf, size_t len) |
| 279 | { | 290 | { |
| @@ -282,8 +293,9 @@ static ssize_t store_tx_queue_len(struct device *dev, | |||
| 282 | 293 | ||
| 283 | return netdev_store(dev, attr, buf, len, change_tx_queue_len); | 294 | return netdev_store(dev, attr, buf, len, change_tx_queue_len); |
| 284 | } | 295 | } |
| 296 | NETDEVICE_SHOW_RW(tx_queue_len, fmt_ulong); | ||
| 285 | 297 | ||
| 286 | static ssize_t store_ifalias(struct device *dev, struct device_attribute *attr, | 298 | static ssize_t ifalias_store(struct device *dev, struct device_attribute *attr, |
| 287 | const char *buf, size_t len) | 299 | const char *buf, size_t len) |
| 288 | { | 300 | { |
| 289 | struct net_device *netdev = to_net_dev(dev); | 301 | struct net_device *netdev = to_net_dev(dev); |
| @@ -306,7 +318,7 @@ static ssize_t store_ifalias(struct device *dev, struct device_attribute *attr, | |||
| 306 | return ret < 0 ? ret : len; | 318 | return ret < 0 ? ret : len; |
| 307 | } | 319 | } |
| 308 | 320 | ||
| 309 | static ssize_t show_ifalias(struct device *dev, | 321 | static ssize_t ifalias_show(struct device *dev, |
| 310 | struct device_attribute *attr, char *buf) | 322 | struct device_attribute *attr, char *buf) |
| 311 | { | 323 | { |
| 312 | const struct net_device *netdev = to_net_dev(dev); | 324 | const struct net_device *netdev = to_net_dev(dev); |
| @@ -319,8 +331,7 @@ static ssize_t show_ifalias(struct device *dev, | |||
| 319 | rtnl_unlock(); | 331 | rtnl_unlock(); |
| 320 | return ret; | 332 | return ret; |
| 321 | } | 333 | } |
| 322 | 334 | static DEVICE_ATTR_RW(ifalias); | |
| 323 | NETDEVICE_SHOW(group, fmt_dec); | ||
| 324 | 335 | ||
| 325 | static int change_group(struct net_device *net, unsigned long new_group) | 336 | static int change_group(struct net_device *net, unsigned long new_group) |
| 326 | { | 337 | { |
| @@ -328,35 +339,37 @@ static int change_group(struct net_device *net, unsigned long new_group) | |||
| 328 | return 0; | 339 | return 0; |
| 329 | } | 340 | } |
| 330 | 341 | ||
| 331 | static ssize_t store_group(struct device *dev, struct device_attribute *attr, | 342 | static ssize_t group_store(struct device *dev, struct device_attribute *attr, |
| 332 | const char *buf, size_t len) | 343 | const char *buf, size_t len) |
| 333 | { | 344 | { |
| 334 | return netdev_store(dev, attr, buf, len, change_group); | 345 | return netdev_store(dev, attr, buf, len, change_group); |
| 335 | } | 346 | } |
| 336 | 347 | NETDEVICE_SHOW(group, fmt_dec); | |
| 337 | static struct device_attribute net_class_attributes[] = { | 348 | static DEVICE_ATTR(netdev_group, S_IRUGO | S_IWUSR, group_show, group_store); |
| 338 | __ATTR(addr_assign_type, S_IRUGO, show_addr_assign_type, NULL), | 349 | |
| 339 | __ATTR(addr_len, S_IRUGO, show_addr_len, NULL), | 350 | static struct attribute *net_class_attrs[] = { |
| 340 | __ATTR(dev_id, S_IRUGO, show_dev_id, NULL), | 351 | &dev_attr_netdev_group.attr, |
| 341 | __ATTR(ifalias, S_IRUGO | S_IWUSR, show_ifalias, store_ifalias), | 352 | &dev_attr_type.attr, |
| 342 | __ATTR(iflink, S_IRUGO, show_iflink, NULL), | 353 | &dev_attr_dev_id.attr, |
| 343 | __ATTR(ifindex, S_IRUGO, show_ifindex, NULL), | 354 | &dev_attr_iflink.attr, |
| 344 | __ATTR(type, S_IRUGO, show_type, NULL), | 355 | &dev_attr_ifindex.attr, |
| 345 | __ATTR(link_mode, S_IRUGO, show_link_mode, NULL), | 356 | &dev_attr_addr_assign_type.attr, |
| 346 | __ATTR(address, S_IRUGO, show_address, NULL), | 357 | &dev_attr_addr_len.attr, |
| 347 | __ATTR(broadcast, S_IRUGO, show_broadcast, NULL), | 358 | &dev_attr_link_mode.attr, |
| 348 | __ATTR(carrier, S_IRUGO | S_IWUSR, show_carrier, store_carrier), | 359 | &dev_attr_address.attr, |
| 349 | __ATTR(speed, S_IRUGO, show_speed, NULL), | 360 | &dev_attr_broadcast.attr, |
| 350 | __ATTR(duplex, S_IRUGO, show_duplex, NULL), | 361 | &dev_attr_speed.attr, |
| 351 | __ATTR(dormant, S_IRUGO, show_dormant, NULL), | 362 | &dev_attr_duplex.attr, |
| 352 | __ATTR(operstate, S_IRUGO, show_operstate, NULL), | 363 | &dev_attr_dormant.attr, |
| 353 | __ATTR(mtu, S_IRUGO | S_IWUSR, show_mtu, store_mtu), | 364 | &dev_attr_operstate.attr, |
| 354 | __ATTR(flags, S_IRUGO | S_IWUSR, show_flags, store_flags), | 365 | &dev_attr_ifalias.attr, |
| 355 | __ATTR(tx_queue_len, S_IRUGO | S_IWUSR, show_tx_queue_len, | 366 | &dev_attr_carrier.attr, |
| 356 | store_tx_queue_len), | 367 | &dev_attr_mtu.attr, |
| 357 | __ATTR(netdev_group, S_IRUGO | S_IWUSR, show_group, store_group), | 368 | &dev_attr_flags.attr, |
| 358 | {} | 369 | &dev_attr_tx_queue_len.attr, |
| 370 | NULL, | ||
| 359 | }; | 371 | }; |
| 372 | ATTRIBUTE_GROUPS(net_class); | ||
| 360 | 373 | ||
| 361 | /* Show a given an attribute in the statistics group */ | 374 | /* Show a given an attribute in the statistics group */ |
| 362 | static ssize_t netstat_show(const struct device *d, | 375 | static ssize_t netstat_show(const struct device *d, |
| @@ -382,13 +395,13 @@ static ssize_t netstat_show(const struct device *d, | |||
| 382 | 395 | ||
| 383 | /* generate a read-only statistics attribute */ | 396 | /* generate a read-only statistics attribute */ |
| 384 | #define NETSTAT_ENTRY(name) \ | 397 | #define NETSTAT_ENTRY(name) \ |
| 385 | static ssize_t show_##name(struct device *d, \ | 398 | static ssize_t name##_show(struct device *d, \ |
| 386 | struct device_attribute *attr, char *buf) \ | 399 | struct device_attribute *attr, char *buf) \ |
| 387 | { \ | 400 | { \ |
| 388 | return netstat_show(d, attr, buf, \ | 401 | return netstat_show(d, attr, buf, \ |
| 389 | offsetof(struct rtnl_link_stats64, name)); \ | 402 | offsetof(struct rtnl_link_stats64, name)); \ |
| 390 | } \ | 403 | } \ |
| 391 | static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) | 404 | static DEVICE_ATTR_RO(name) |
| 392 | 405 | ||
| 393 | NETSTAT_ENTRY(rx_packets); | 406 | NETSTAT_ENTRY(rx_packets); |
| 394 | NETSTAT_ENTRY(tx_packets); | 407 | NETSTAT_ENTRY(tx_packets); |
| @@ -457,6 +470,9 @@ static struct attribute_group wireless_group = { | |||
| 457 | .attrs = wireless_attrs, | 470 | .attrs = wireless_attrs, |
| 458 | }; | 471 | }; |
| 459 | #endif | 472 | #endif |
| 473 | |||
| 474 | #else /* CONFIG_SYSFS */ | ||
| 475 | #define net_class_groups NULL | ||
| 460 | #endif /* CONFIG_SYSFS */ | 476 | #endif /* CONFIG_SYSFS */ |
| 461 | 477 | ||
| 462 | #ifdef CONFIG_RPS | 478 | #ifdef CONFIG_RPS |
| @@ -1229,9 +1245,7 @@ static const void *net_namespace(struct device *d) | |||
| 1229 | static struct class net_class = { | 1245 | static struct class net_class = { |
| 1230 | .name = "net", | 1246 | .name = "net", |
| 1231 | .dev_release = netdev_release, | 1247 | .dev_release = netdev_release, |
| 1232 | #ifdef CONFIG_SYSFS | 1248 | .dev_groups = net_class_groups, |
| 1233 | .dev_attrs = net_class_attributes, | ||
| 1234 | #endif /* CONFIG_SYSFS */ | ||
| 1235 | .dev_uevent = netdev_uevent, | 1249 | .dev_uevent = netdev_uevent, |
| 1236 | .ns_type = &net_ns_type_operations, | 1250 | .ns_type = &net_ns_type_operations, |
| 1237 | .namespace = net_namespace, | 1251 | .namespace = net_namespace, |
diff --git a/net/ieee802154/wpan-class.c b/net/ieee802154/wpan-class.c index 13571eae6bae..ef56ab5b35fe 100644 --- a/net/ieee802154/wpan-class.c +++ b/net/ieee802154/wpan-class.c | |||
| @@ -36,7 +36,8 @@ static ssize_t name ## _show(struct device *dev, \ | |||
| 36 | ret = snprintf(buf, PAGE_SIZE, format_string "\n", args); \ | 36 | ret = snprintf(buf, PAGE_SIZE, format_string "\n", args); \ |
| 37 | mutex_unlock(&phy->pib_lock); \ | 37 | mutex_unlock(&phy->pib_lock); \ |
| 38 | return ret; \ | 38 | return ret; \ |
| 39 | } | 39 | } \ |
| 40 | static DEVICE_ATTR_RO(name); | ||
| 40 | 41 | ||
| 41 | #define MASTER_SHOW(field, format_string) \ | 42 | #define MASTER_SHOW(field, format_string) \ |
| 42 | MASTER_SHOW_COMPLEX(field, format_string, phy->field) | 43 | MASTER_SHOW_COMPLEX(field, format_string, phy->field) |
| @@ -66,15 +67,17 @@ static ssize_t channels_supported_show(struct device *dev, | |||
| 66 | mutex_unlock(&phy->pib_lock); | 67 | mutex_unlock(&phy->pib_lock); |
| 67 | return len; | 68 | return len; |
| 68 | } | 69 | } |
| 69 | 70 | static DEVICE_ATTR_RO(channels_supported); | |
| 70 | static struct device_attribute pmib_attrs[] = { | 71 | |
| 71 | __ATTR_RO(current_channel), | 72 | static struct attribute *pmib_attrs[] = { |
| 72 | __ATTR_RO(current_page), | 73 | &dev_attr_current_channel.attr, |
| 73 | __ATTR_RO(channels_supported), | 74 | &dev_attr_current_page.attr, |
| 74 | __ATTR_RO(transmit_power), | 75 | &dev_attr_channels_supported.attr, |
| 75 | __ATTR_RO(cca_mode), | 76 | &dev_attr_transmit_power.attr, |
| 76 | {}, | 77 | &dev_attr_cca_mode.attr, |
| 78 | NULL, | ||
| 77 | }; | 79 | }; |
| 80 | ATTRIBUTE_GROUPS(pmib); | ||
| 78 | 81 | ||
| 79 | static void wpan_phy_release(struct device *d) | 82 | static void wpan_phy_release(struct device *d) |
| 80 | { | 83 | { |
| @@ -85,7 +88,7 @@ static void wpan_phy_release(struct device *d) | |||
| 85 | static struct class wpan_phy_class = { | 88 | static struct class wpan_phy_class = { |
| 86 | .name = "ieee802154", | 89 | .name = "ieee802154", |
| 87 | .dev_release = wpan_phy_release, | 90 | .dev_release = wpan_phy_release, |
| 88 | .dev_attrs = pmib_attrs, | 91 | .dev_groups = pmib_groups, |
| 89 | }; | 92 | }; |
| 90 | 93 | ||
| 91 | static DEFINE_MUTEX(wpan_phy_mutex); | 94 | static DEFINE_MUTEX(wpan_phy_mutex); |
diff --git a/net/rfkill/core.c b/net/rfkill/core.c index 1cec5e4f3a5e..1bacc1079942 100644 --- a/net/rfkill/core.c +++ b/net/rfkill/core.c | |||
| @@ -576,14 +576,14 @@ void rfkill_set_states(struct rfkill *rfkill, bool sw, bool hw) | |||
| 576 | } | 576 | } |
| 577 | EXPORT_SYMBOL(rfkill_set_states); | 577 | EXPORT_SYMBOL(rfkill_set_states); |
| 578 | 578 | ||
| 579 | static ssize_t rfkill_name_show(struct device *dev, | 579 | static ssize_t name_show(struct device *dev, struct device_attribute *attr, |
| 580 | struct device_attribute *attr, | 580 | char *buf) |
| 581 | char *buf) | ||
| 582 | { | 581 | { |
| 583 | struct rfkill *rfkill = to_rfkill(dev); | 582 | struct rfkill *rfkill = to_rfkill(dev); |
| 584 | 583 | ||
| 585 | return sprintf(buf, "%s\n", rfkill->name); | 584 | return sprintf(buf, "%s\n", rfkill->name); |
| 586 | } | 585 | } |
| 586 | static DEVICE_ATTR_RO(name); | ||
| 587 | 587 | ||
| 588 | static const char *rfkill_get_type_str(enum rfkill_type type) | 588 | static const char *rfkill_get_type_str(enum rfkill_type type) |
| 589 | { | 589 | { |
| @@ -611,54 +611,52 @@ static const char *rfkill_get_type_str(enum rfkill_type type) | |||
| 611 | } | 611 | } |
| 612 | } | 612 | } |
| 613 | 613 | ||
| 614 | static ssize_t rfkill_type_show(struct device *dev, | 614 | static ssize_t type_show(struct device *dev, struct device_attribute *attr, |
| 615 | struct device_attribute *attr, | 615 | char *buf) |
| 616 | char *buf) | ||
| 617 | { | 616 | { |
| 618 | struct rfkill *rfkill = to_rfkill(dev); | 617 | struct rfkill *rfkill = to_rfkill(dev); |
| 619 | 618 | ||
| 620 | return sprintf(buf, "%s\n", rfkill_get_type_str(rfkill->type)); | 619 | return sprintf(buf, "%s\n", rfkill_get_type_str(rfkill->type)); |
| 621 | } | 620 | } |
| 621 | static DEVICE_ATTR_RO(type); | ||
| 622 | 622 | ||
| 623 | static ssize_t rfkill_idx_show(struct device *dev, | 623 | static ssize_t index_show(struct device *dev, struct device_attribute *attr, |
| 624 | struct device_attribute *attr, | 624 | char *buf) |
| 625 | char *buf) | ||
| 626 | { | 625 | { |
| 627 | struct rfkill *rfkill = to_rfkill(dev); | 626 | struct rfkill *rfkill = to_rfkill(dev); |
| 628 | 627 | ||
| 629 | return sprintf(buf, "%d\n", rfkill->idx); | 628 | return sprintf(buf, "%d\n", rfkill->idx); |
| 630 | } | 629 | } |
| 630 | static DEVICE_ATTR_RO(index); | ||
| 631 | 631 | ||
| 632 | static ssize_t rfkill_persistent_show(struct device *dev, | 632 | static ssize_t persistent_show(struct device *dev, |
| 633 | struct device_attribute *attr, | 633 | struct device_attribute *attr, char *buf) |
| 634 | char *buf) | ||
| 635 | { | 634 | { |
| 636 | struct rfkill *rfkill = to_rfkill(dev); | 635 | struct rfkill *rfkill = to_rfkill(dev); |
| 637 | 636 | ||
| 638 | return sprintf(buf, "%d\n", rfkill->persistent); | 637 | return sprintf(buf, "%d\n", rfkill->persistent); |
| 639 | } | 638 | } |
| 639 | static DEVICE_ATTR_RO(persistent); | ||
| 640 | 640 | ||
| 641 | static ssize_t rfkill_hard_show(struct device *dev, | 641 | static ssize_t hard_show(struct device *dev, struct device_attribute *attr, |
| 642 | struct device_attribute *attr, | 642 | char *buf) |
| 643 | char *buf) | ||
| 644 | { | 643 | { |
| 645 | struct rfkill *rfkill = to_rfkill(dev); | 644 | struct rfkill *rfkill = to_rfkill(dev); |
| 646 | 645 | ||
| 647 | return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0 ); | 646 | return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_HW) ? 1 : 0 ); |
| 648 | } | 647 | } |
| 648 | static DEVICE_ATTR_RO(hard); | ||
| 649 | 649 | ||
| 650 | static ssize_t rfkill_soft_show(struct device *dev, | 650 | static ssize_t soft_show(struct device *dev, struct device_attribute *attr, |
| 651 | struct device_attribute *attr, | 651 | char *buf) |
| 652 | char *buf) | ||
| 653 | { | 652 | { |
| 654 | struct rfkill *rfkill = to_rfkill(dev); | 653 | struct rfkill *rfkill = to_rfkill(dev); |
| 655 | 654 | ||
| 656 | return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_SW) ? 1 : 0 ); | 655 | return sprintf(buf, "%d\n", (rfkill->state & RFKILL_BLOCK_SW) ? 1 : 0 ); |
| 657 | } | 656 | } |
| 658 | 657 | ||
| 659 | static ssize_t rfkill_soft_store(struct device *dev, | 658 | static ssize_t soft_store(struct device *dev, struct device_attribute *attr, |
| 660 | struct device_attribute *attr, | 659 | const char *buf, size_t count) |
| 661 | const char *buf, size_t count) | ||
| 662 | { | 660 | { |
| 663 | struct rfkill *rfkill = to_rfkill(dev); | 661 | struct rfkill *rfkill = to_rfkill(dev); |
| 664 | unsigned long state; | 662 | unsigned long state; |
| @@ -680,6 +678,7 @@ static ssize_t rfkill_soft_store(struct device *dev, | |||
| 680 | 678 | ||
| 681 | return count; | 679 | return count; |
| 682 | } | 680 | } |
| 681 | static DEVICE_ATTR_RW(soft); | ||
| 683 | 682 | ||
| 684 | static u8 user_state_from_blocked(unsigned long state) | 683 | static u8 user_state_from_blocked(unsigned long state) |
| 685 | { | 684 | { |
| @@ -691,18 +690,16 @@ static u8 user_state_from_blocked(unsigned long state) | |||
| 691 | return RFKILL_USER_STATE_UNBLOCKED; | 690 | return RFKILL_USER_STATE_UNBLOCKED; |
| 692 | } | 691 | } |
| 693 | 692 | ||
| 694 | static ssize_t rfkill_state_show(struct device *dev, | 693 | static ssize_t state_show(struct device *dev, struct device_attribute *attr, |
| 695 | struct device_attribute *attr, | 694 | char *buf) |
| 696 | char *buf) | ||
| 697 | { | 695 | { |
| 698 | struct rfkill *rfkill = to_rfkill(dev); | 696 | struct rfkill *rfkill = to_rfkill(dev); |
| 699 | 697 | ||
| 700 | return sprintf(buf, "%d\n", user_state_from_blocked(rfkill->state)); | 698 | return sprintf(buf, "%d\n", user_state_from_blocked(rfkill->state)); |
| 701 | } | 699 | } |
| 702 | 700 | ||
| 703 | static ssize_t rfkill_state_store(struct device *dev, | 701 | static ssize_t state_store(struct device *dev, struct device_attribute *attr, |
| 704 | struct device_attribute *attr, | 702 | const char *buf, size_t count) |
| 705 | const char *buf, size_t count) | ||
| 706 | { | 703 | { |
| 707 | struct rfkill *rfkill = to_rfkill(dev); | 704 | struct rfkill *rfkill = to_rfkill(dev); |
| 708 | unsigned long state; | 705 | unsigned long state; |
| @@ -725,32 +722,27 @@ static ssize_t rfkill_state_store(struct device *dev, | |||
| 725 | 722 | ||
| 726 | return count; | 723 | return count; |
| 727 | } | 724 | } |
| 725 | static DEVICE_ATTR_RW(state); | ||
| 728 | 726 | ||
| 729 | static ssize_t rfkill_claim_show(struct device *dev, | 727 | static ssize_t claim_show(struct device *dev, struct device_attribute *attr, |
| 730 | struct device_attribute *attr, | 728 | char *buf) |
| 731 | char *buf) | ||
| 732 | { | 729 | { |
| 733 | return sprintf(buf, "%d\n", 0); | 730 | return sprintf(buf, "%d\n", 0); |
| 734 | } | 731 | } |
| 735 | 732 | static DEVICE_ATTR_RO(claim); | |
| 736 | static ssize_t rfkill_claim_store(struct device *dev, | 733 | |
| 737 | struct device_attribute *attr, | 734 | static struct attribute *rfkill_dev_attrs[] = { |
| 738 | const char *buf, size_t count) | 735 | &dev_attr_name.attr, |
| 739 | { | 736 | &dev_attr_type.attr, |
| 740 | return -EOPNOTSUPP; | 737 | &dev_attr_index.attr, |
| 741 | } | 738 | &dev_attr_persistent.attr, |
| 742 | 739 | &dev_attr_state.attr, | |
| 743 | static struct device_attribute rfkill_dev_attrs[] = { | 740 | &dev_attr_claim.attr, |
| 744 | __ATTR(name, S_IRUGO, rfkill_name_show, NULL), | 741 | &dev_attr_soft.attr, |
| 745 | __ATTR(type, S_IRUGO, rfkill_type_show, NULL), | 742 | &dev_attr_hard.attr, |
| 746 | __ATTR(index, S_IRUGO, rfkill_idx_show, NULL), | 743 | NULL, |
| 747 | __ATTR(persistent, S_IRUGO, rfkill_persistent_show, NULL), | ||
| 748 | __ATTR(state, S_IRUGO|S_IWUSR, rfkill_state_show, rfkill_state_store), | ||
| 749 | __ATTR(claim, S_IRUGO|S_IWUSR, rfkill_claim_show, rfkill_claim_store), | ||
| 750 | __ATTR(soft, S_IRUGO|S_IWUSR, rfkill_soft_show, rfkill_soft_store), | ||
| 751 | __ATTR(hard, S_IRUGO, rfkill_hard_show, NULL), | ||
| 752 | __ATTR_NULL | ||
| 753 | }; | 744 | }; |
| 745 | ATTRIBUTE_GROUPS(rfkill_dev); | ||
| 754 | 746 | ||
| 755 | static void rfkill_release(struct device *dev) | 747 | static void rfkill_release(struct device *dev) |
| 756 | { | 748 | { |
| @@ -830,7 +822,7 @@ static int rfkill_resume(struct device *dev) | |||
| 830 | static struct class rfkill_class = { | 822 | static struct class rfkill_class = { |
| 831 | .name = "rfkill", | 823 | .name = "rfkill", |
| 832 | .dev_release = rfkill_release, | 824 | .dev_release = rfkill_release, |
| 833 | .dev_attrs = rfkill_dev_attrs, | 825 | .dev_groups = rfkill_dev_groups, |
| 834 | .dev_uevent = rfkill_dev_uevent, | 826 | .dev_uevent = rfkill_dev_uevent, |
| 835 | .suspend = rfkill_suspend, | 827 | .suspend = rfkill_suspend, |
| 836 | .resume = rfkill_resume, | 828 | .resume = rfkill_resume, |
diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c index a23253e06358..9ee6bc1a7610 100644 --- a/net/wireless/sysfs.c +++ b/net/wireless/sysfs.c | |||
| @@ -30,7 +30,8 @@ static ssize_t name ## _show(struct device *dev, \ | |||
| 30 | char *buf) \ | 30 | char *buf) \ |
| 31 | { \ | 31 | { \ |
| 32 | return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \ | 32 | return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \ |
| 33 | } | 33 | } \ |
| 34 | static DEVICE_ATTR_RO(name) | ||
| 34 | 35 | ||
| 35 | SHOW_FMT(index, "%d", wiphy_idx); | 36 | SHOW_FMT(index, "%d", wiphy_idx); |
| 36 | SHOW_FMT(macaddress, "%pM", wiphy.perm_addr); | 37 | SHOW_FMT(macaddress, "%pM", wiphy.perm_addr); |
| @@ -42,7 +43,7 @@ static ssize_t name_show(struct device *dev, | |||
| 42 | struct wiphy *wiphy = &dev_to_rdev(dev)->wiphy; | 43 | struct wiphy *wiphy = &dev_to_rdev(dev)->wiphy; |
| 43 | return sprintf(buf, "%s\n", dev_name(&wiphy->dev)); | 44 | return sprintf(buf, "%s\n", dev_name(&wiphy->dev)); |
| 44 | } | 45 | } |
| 45 | 46 | static DEVICE_ATTR_RO(name); | |
| 46 | 47 | ||
| 47 | static ssize_t addresses_show(struct device *dev, | 48 | static ssize_t addresses_show(struct device *dev, |
| 48 | struct device_attribute *attr, | 49 | struct device_attribute *attr, |
| @@ -60,15 +61,17 @@ static ssize_t addresses_show(struct device *dev, | |||
| 60 | 61 | ||
| 61 | return buf - start; | 62 | return buf - start; |
| 62 | } | 63 | } |
| 63 | 64 | static DEVICE_ATTR_RO(addresses); | |
| 64 | static struct device_attribute ieee80211_dev_attrs[] = { | 65 | |
| 65 | __ATTR_RO(index), | 66 | static struct attribute *ieee80211_attrs[] = { |
| 66 | __ATTR_RO(macaddress), | 67 | &dev_attr_index.attr, |
| 67 | __ATTR_RO(address_mask), | 68 | &dev_attr_macaddress.attr, |
| 68 | __ATTR_RO(addresses), | 69 | &dev_attr_address_mask.attr, |
| 69 | __ATTR_RO(name), | 70 | &dev_attr_addresses.attr, |
| 70 | {} | 71 | &dev_attr_name.attr, |
| 72 | NULL, | ||
| 71 | }; | 73 | }; |
| 74 | ATTRIBUTE_GROUPS(ieee80211); | ||
| 72 | 75 | ||
| 73 | static void wiphy_dev_release(struct device *dev) | 76 | static void wiphy_dev_release(struct device *dev) |
| 74 | { | 77 | { |
| @@ -146,7 +149,7 @@ struct class ieee80211_class = { | |||
| 146 | .name = "ieee80211", | 149 | .name = "ieee80211", |
| 147 | .owner = THIS_MODULE, | 150 | .owner = THIS_MODULE, |
| 148 | .dev_release = wiphy_dev_release, | 151 | .dev_release = wiphy_dev_release, |
| 149 | .dev_attrs = ieee80211_dev_attrs, | 152 | .dev_groups = ieee80211_groups, |
| 150 | .dev_uevent = wiphy_uevent, | 153 | .dev_uevent = wiphy_uevent, |
| 151 | #ifdef CONFIG_PM | 154 | #ifdef CONFIG_PM |
| 152 | .suspend = wiphy_suspend, | 155 | .suspend = wiphy_suspend, |
