aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAndi Kleen <andi@firstfloor.org>2010-01-05 06:48:04 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-07 20:04:47 -0500
commit3701cde6e35245e26f63252f46c62e8a790fa996 (patch)
treef4fde55198c52db97f46286a41275d66c081e29c /drivers
parente1a7e29a266ba3313a873d302b352521403bd155 (diff)
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: Andi Kleen <ak@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/base/node.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/base/node.c b/drivers/base/node.c
index aa8bc4bff4f6..ad43185ec15a 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -16,8 +16,11 @@
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/swap.h> 17#include <linux/swap.h>
18 18
19static struct sysdev_class_attribute *node_state_attrs[];
20
19static struct sysdev_class node_class = { 21static struct sysdev_class node_class = {
20 .name = "node", 22 .name = "node",
23 .attrs = node_state_attrs,
21}; 24};
22 25
23 26
@@ -569,29 +572,27 @@ static struct node_attr node_state_attr[] = {
569#endif 572#endif
570}; 573};
571 574
572static int node_states_init(void) 575static struct sysdev_class_attribute *node_state_attrs[] = {
573{ 576 &node_state_attr[0].attr,
574 int i; 577 &node_state_attr[1].attr,
575 int err = 0; 578 &node_state_attr[2].attr,
576 579 &node_state_attr[3].attr,
577 BUILD_BUG_ON(ARRAY_SIZE(node_state_attr) != NR_NODE_STATES); 580#ifdef CONFIG_HIGHMEM
578 for (i = 0; i < NR_NODE_STATES; i++) { 581 &node_state_attr[4].attr,
579 int ret; 582#endif
580 ret = sysdev_class_create_file(&node_class, &node_state_attr[i].attr); 583 NULL
581 if (!err) 584};
582 err = ret;
583 }
584 return err;
585}
586 585
587#define NODE_CALLBACK_PRI 2 /* lower than SLAB */ 586#define NODE_CALLBACK_PRI 2 /* lower than SLAB */
588static int __init register_node_type(void) 587static int __init register_node_type(void)
589{ 588{
590 int ret; 589 int ret;
591 590
591 BUILD_BUG_ON(ARRAY_SIZE(node_state_attr) != NR_NODE_STATES);
592 BUILD_BUG_ON(ARRAY_SIZE(node_state_attrs)-1 != NR_NODE_STATES);
593
592 ret = sysdev_class_register(&node_class); 594 ret = sysdev_class_register(&node_class);
593 if (!ret) { 595 if (!ret) {
594 ret = node_states_init();
595 hotplug_memory_notifier(node_memory_callback, 596 hotplug_memory_notifier(node_memory_callback,
596 NODE_CALLBACK_PRI); 597 NODE_CALLBACK_PRI);
597 } 598 }