Commit 60cd84fd authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] driverfs topology cleanup

From Matthew Dobson.

This final patch from Matthew cleans up a few leftovers which were noted
after the code had been reviewed and tested a bit in the -mm patchsets.

1) Update register_XXX and arch_register_XXX functions to return int
   instead of void.  Functions calling these functions should know if
   they completed successfully to take appropriate further registration
   action, or not bother.

2) Drop some pointless error checking in the arch_register_XXX
   functions.
parent 7c265fe6
...@@ -33,7 +33,7 @@ struct device_driver cpu_driver = { ...@@ -33,7 +33,7 @@ struct device_driver cpu_driver = {
* *
* Initialize and register the CPU device. * Initialize and register the CPU device.
*/ */
void __init register_cpu(struct cpu *cpu, int num, struct node *root) int __init register_cpu(struct cpu *cpu, int num, struct node *root)
{ {
cpu->node_id = __cpu_to_node(num); cpu->node_id = __cpu_to_node(num);
cpu->sysdev.name = "cpu"; cpu->sysdev.name = "cpu";
...@@ -42,7 +42,7 @@ void __init register_cpu(struct cpu *cpu, int num, struct node *root) ...@@ -42,7 +42,7 @@ void __init register_cpu(struct cpu *cpu, int num, struct node *root)
cpu->sysdev.root = &root->sysroot; cpu->sysdev.root = &root->sysroot;
snprintf(cpu->sysdev.dev.name, DEVICE_NAME_SIZE, "CPU %u", num); snprintf(cpu->sysdev.dev.name, DEVICE_NAME_SIZE, "CPU %u", num);
cpu->sysdev.dev.driver = &cpu_driver; cpu->sysdev.dev.driver = &cpu_driver;
sys_device_register(&cpu->sysdev); return sys_device_register(&cpu->sysdev);
} }
......
...@@ -34,7 +34,7 @@ struct device_driver memblk_driver = { ...@@ -34,7 +34,7 @@ struct device_driver memblk_driver = {
* *
* Initialize and register the MemBlk device. * Initialize and register the MemBlk device.
*/ */
void __init register_memblk(struct memblk *memblk, int num, struct node *root) int __init register_memblk(struct memblk *memblk, int num, struct node *root)
{ {
memblk->node_id = __memblk_to_node(num); memblk->node_id = __memblk_to_node(num);
memblk->sysdev.name = "memblk"; memblk->sysdev.name = "memblk";
...@@ -43,7 +43,7 @@ void __init register_memblk(struct memblk *memblk, int num, struct node *root) ...@@ -43,7 +43,7 @@ void __init register_memblk(struct memblk *memblk, int num, struct node *root)
memblk->sysdev.root = &root->sysroot; memblk->sysdev.root = &root->sysroot;
snprintf(memblk->sysdev.dev.name, DEVICE_NAME_SIZE, "Memory Block %u", num); snprintf(memblk->sysdev.dev.name, DEVICE_NAME_SIZE, "Memory Block %u", num);
memblk->sysdev.dev.driver = &memblk_driver; memblk->sysdev.dev.driver = &memblk_driver;
sys_device_register(&memblk->sysdev); return sys_device_register(&memblk->sysdev);
} }
......
...@@ -70,8 +70,10 @@ static DEVICE_ATTR(meminfo,S_IRUGO,node_read_meminfo,NULL); ...@@ -70,8 +70,10 @@ static DEVICE_ATTR(meminfo,S_IRUGO,node_read_meminfo,NULL);
* *
* Initialize and register the node device. * Initialize and register the node device.
*/ */
void __init register_node(struct node *node, int num, struct node *parent) int __init register_node(struct node *node, int num, struct node *parent)
{ {
int error;
node->cpumap = __node_to_cpu_mask(num); node->cpumap = __node_to_cpu_mask(num);
node->sysroot.id = num; node->sysroot.id = num;
if (parent) if (parent)
...@@ -80,10 +82,12 @@ void __init register_node(struct node *node, int num, struct node *parent) ...@@ -80,10 +82,12 @@ void __init register_node(struct node *node, int num, struct node *parent)
snprintf(node->sysroot.dev.bus_id, BUS_ID_SIZE, "node%u", num); snprintf(node->sysroot.dev.bus_id, BUS_ID_SIZE, "node%u", num);
node->sysroot.dev.driver = &node_driver; node->sysroot.dev.driver = &node_driver;
node->sysroot.dev.bus = &system_bus_type; node->sysroot.dev.bus = &system_bus_type;
if (!sys_register_root(&node->sysroot)){ error = sys_register_root(&node->sysroot);
if (!error){
device_create_file(&node->sysroot.dev, &dev_attr_cpumap); device_create_file(&node->sysroot.dev, &dev_attr_cpumap);
device_create_file(&node->sysroot.dev, &dev_attr_meminfo); device_create_file(&node->sysroot.dev, &dev_attr_meminfo);
} }
return error;
} }
......
...@@ -13,18 +13,14 @@ struct i386_cpu { ...@@ -13,18 +13,14 @@ struct i386_cpu {
extern struct i386_cpu cpu_devices[NR_CPUS]; extern struct i386_cpu cpu_devices[NR_CPUS];
static inline int arch_register_cpu(int num){
struct node *parent = NULL;
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
static inline void arch_register_cpu(int num){ parent = &node_devices[__cpu_to_node(num)].node;
int p_node = __cpu_to_node(num); #endif /* CONFIG_NUMA */
if (p_node >= 0 && p_node < NR_CPUS) return register_cpu(&cpu_devices[num].cpu, num, parent);
register_cpu(&cpu_devices[num].cpu, num,
&node_devices[p_node].node);
} }
#else /* !CONFIG_NUMA */
static inline void arch_register_cpu(int num){
register_cpu(&cpu_devices[num].cpu, num, (struct node *) NULL);
}
#endif /* CONFIG_NUMA */
#endif /* _ASM_I386_CPU_H_ */ #endif /* _ASM_I386_CPU_H_ */
...@@ -13,11 +13,10 @@ struct i386_memblk { ...@@ -13,11 +13,10 @@ struct i386_memblk {
}; };
extern struct i386_memblk memblk_devices[MAX_NR_MEMBLKS]; extern struct i386_memblk memblk_devices[MAX_NR_MEMBLKS];
static inline void arch_register_memblk(int num){ static inline int arch_register_memblk(int num){
int p_node = __memblk_to_node(num); int p_node = __memblk_to_node(num);
if (p_node >= 0 && p_node < MAX_NR_MEMBLKS) return register_memblk(&memblk_devices[num].memblk, num,
register_memblk(&memblk_devices[num].memblk, num,
&node_devices[p_node].node); &node_devices[p_node].node);
} }
......
...@@ -12,15 +12,14 @@ struct i386_node { ...@@ -12,15 +12,14 @@ struct i386_node {
}; };
extern struct i386_node node_devices[MAX_NUMNODES]; extern struct i386_node node_devices[MAX_NUMNODES];
static inline void arch_register_node(int num){ static inline int arch_register_node(int num){
int p_node = __parent_node(num); int p_node = __parent_node(num);
struct node *parent = NULL;
if (p_node != num) if (p_node != num)
register_node(&node_devices[num].node, num, parent = &node_devices[p_node].node;
&node_devices[p_node].node);
else return register_node(&node_devices[num].node, num, parent);
register_node(&node_devices[num].node, num,
(struct node *) NULL);
} }
#endif /* _ASM_I386_NODE_H_ */ #endif /* _ASM_I386_NODE_H_ */
...@@ -27,6 +27,6 @@ struct cpu { ...@@ -27,6 +27,6 @@ struct cpu {
struct sys_device sysdev; struct sys_device sysdev;
}; };
extern void register_cpu(struct cpu *, int, struct node *); extern int register_cpu(struct cpu *, int, struct node *);
#endif /* _LINUX_CPU_H_ */ #endif /* _LINUX_CPU_H_ */
...@@ -27,6 +27,6 @@ struct memblk { ...@@ -27,6 +27,6 @@ struct memblk {
struct sys_device sysdev; struct sys_device sysdev;
}; };
extern void register_memblk(struct memblk *, int, struct node *); extern int register_memblk(struct memblk *, int, struct node *);
#endif /* _LINUX_MEMBLK_H_ */ #endif /* _LINUX_MEMBLK_H_ */
...@@ -26,7 +26,7 @@ struct node { ...@@ -26,7 +26,7 @@ struct node {
struct sys_root sysroot; struct sys_root sysroot;
}; };
extern void register_node(struct node *, int, struct node *); extern int register_node(struct node *, int, struct node *);
#define to_node(_root) container_of(_root, struct node, sysroot) #define to_node(_root) container_of(_root, struct node, sysroot)
#define to_root(_dev) container_of(_dev, struct sys_root, dev) #define to_root(_dev) container_of(_dev, struct sys_root, dev)
......
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