Commit f7bb3f9b authored by Patrick Mochel's avatar Patrick Mochel

driver model: Fix error handling in sysfs registration

From Matt Dobson:

The cpu, memblk, and node driver/device registration should be a little 
more clean in the way it handles registration failures.  Or at least 
*consistent* amongst the topology elements.  Right now, failures are 
either silent, obscure, or leave things in an inconsistent state.
parent ec451dbb
......@@ -48,6 +48,9 @@ int __init register_cpu(struct cpu *cpu, int num, struct node *root)
int __init cpu_dev_init(void)
{
devclass_register(&cpu_devclass);
return driver_register(&cpu_driver);
int error;
if (!(error = devclass_register(&cpu_devclass)))
if (error = driver_register(&cpu_driver))
devclass_unregister(&cpu_devclass);
return error;
}
......@@ -47,9 +47,12 @@ int __init register_memblk(struct memblk *memblk, int num, struct node *root)
}
static int __init register_memblk_type(void)
int __init register_memblk_type(void)
{
int error = devclass_register(&memblk_devclass);
return error ? error : driver_register(&memblk_driver);
int error;
if (!(error = devclass_register(&memblk_devclass)))
if (error = driver_register(&memblk_driver))
devclass_unregister(&memblk_devclass);
return error;
}
postcore_initcall(register_memblk_type);
......@@ -89,9 +89,12 @@ int __init register_node(struct node *node, int num, struct node *parent)
}
static int __init register_node_type(void)
int __init register_node_type(void)
{
int error = devclass_register(&node_devclass);
return error ? error : driver_register(&node_driver);
int error;
if (!(error = devclass_register(&node_devclass)))
if (error = driver_register(&node_driver))
devclass_unregister(&node_devclass);
return error;
}
postcore_initcall(register_node_type);
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