Commit 3701cde6 authored by Andi Kleen's avatar Andi Kleen Committed by Greg Kroah-Hartman

sysdev: Use sysdev_class attribute arrays in node driver

Convert the node driver to sysdev_class attribute arrays. This
greatly cleans up the code and remove a lot of code.

Saves ~150 bytes of code on x86-64.
Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e1a7e29a
...@@ -16,8 +16,11 @@ ...@@ -16,8 +16,11 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/swap.h> #include <linux/swap.h>
static struct sysdev_class_attribute *node_state_attrs[];
static struct sysdev_class node_class = { static struct sysdev_class node_class = {
.name = "node", .name = "node",
.attrs = node_state_attrs,
}; };
...@@ -569,29 +572,27 @@ static struct node_attr node_state_attr[] = { ...@@ -569,29 +572,27 @@ static struct node_attr node_state_attr[] = {
#endif #endif
}; };
static int node_states_init(void) static struct sysdev_class_attribute *node_state_attrs[] = {
{ &node_state_attr[0].attr,
int i; &node_state_attr[1].attr,
int err = 0; &node_state_attr[2].attr,
&node_state_attr[3].attr,
BUILD_BUG_ON(ARRAY_SIZE(node_state_attr) != NR_NODE_STATES); #ifdef CONFIG_HIGHMEM
for (i = 0; i < NR_NODE_STATES; i++) { &node_state_attr[4].attr,
int ret; #endif
ret = sysdev_class_create_file(&node_class, &node_state_attr[i].attr); NULL
if (!err) };
err = ret;
}
return err;
}
#define NODE_CALLBACK_PRI 2 /* lower than SLAB */ #define NODE_CALLBACK_PRI 2 /* lower than SLAB */
static int __init register_node_type(void) static int __init register_node_type(void)
{ {
int ret; int ret;
BUILD_BUG_ON(ARRAY_SIZE(node_state_attr) != NR_NODE_STATES);
BUILD_BUG_ON(ARRAY_SIZE(node_state_attrs)-1 != NR_NODE_STATES);
ret = sysdev_class_register(&node_class); ret = sysdev_class_register(&node_class);
if (!ret) { if (!ret) {
ret = node_states_init();
hotplug_memory_notifier(node_memory_callback, hotplug_memory_notifier(node_memory_callback,
NODE_CALLBACK_PRI); NODE_CALLBACK_PRI);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment