Skip to content

Commit fcf07d2

Browse files
Lai Jiangshantorvalds
authored andcommitted
drivers/base/node.c: cleanup node_state_attr[]
use [index] = init_value use N_xxxxx instead of hardcode. Make it more readability and easier to add new state. Signed-off-by: Lai Jiangshan <[email protected]> Signed-off-by: Wen Congyang <[email protected]> Acked-by: David Rientjes <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 81df9bf commit fcf07d2

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/base/node.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -638,23 +638,23 @@ static ssize_t show_node_state(struct device *dev,
638638
{ __ATTR(name, 0444, show_node_state, NULL), state }
639639

640640
static struct node_attr node_state_attr[] = {
641-
_NODE_ATTR(possible, N_POSSIBLE),
642-
_NODE_ATTR(online, N_ONLINE),
643-
_NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY),
644-
_NODE_ATTR(has_cpu, N_CPU),
641+
[N_POSSIBLE] = _NODE_ATTR(possible, N_POSSIBLE),
642+
[N_ONLINE] = _NODE_ATTR(online, N_ONLINE),
643+
[N_NORMAL_MEMORY] = _NODE_ATTR(has_normal_memory, N_NORMAL_MEMORY),
645644
#ifdef CONFIG_HIGHMEM
646-
_NODE_ATTR(has_high_memory, N_HIGH_MEMORY),
645+
[N_HIGH_MEMORY] = _NODE_ATTR(has_high_memory, N_HIGH_MEMORY),
647646
#endif
647+
[N_CPU] = _NODE_ATTR(has_cpu, N_CPU),
648648
};
649649

650650
static struct attribute *node_state_attrs[] = {
651-
&node_state_attr[0].attr.attr,
652-
&node_state_attr[1].attr.attr,
653-
&node_state_attr[2].attr.attr,
654-
&node_state_attr[3].attr.attr,
651+
&node_state_attr[N_POSSIBLE].attr.attr,
652+
&node_state_attr[N_ONLINE].attr.attr,
653+
&node_state_attr[N_NORMAL_MEMORY].attr.attr,
655654
#ifdef CONFIG_HIGHMEM
656-
&node_state_attr[4].attr.attr,
655+
&node_state_attr[N_HIGH_MEMORY].attr.attr,
657656
#endif
657+
&node_state_attr[N_CPU].attr.attr,
658658
NULL
659659
};
660660

0 commit comments

Comments
 (0)