lkml.org 
[lkml]   [2003]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] Fix error handling in sysfs registration
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.

Cheers!

-Matt
diff -Nur --exclude-from=/usr/src/.dontdiff linux-2.5.64-vanilla/drivers/base/cpu.c linux-2.5.64-sysfs_cleanup/drivers/base/cpu.c
--- linux-2.5.64-vanilla/drivers/base/cpu.c Tue Mar 4 19:29:15 2003
+++ linux-2.5.64-sysfs_cleanup/drivers/base/cpu.c Mon Mar 17 14:08:59 2003
@@ -48,6 +48,9 @@

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;
}
diff -Nur --exclude-from=/usr/src/.dontdiff linux-2.5.64-vanilla/drivers/base/memblk.c linux-2.5.64-sysfs_cleanup/drivers/base/memblk.c
--- linux-2.5.64-vanilla/drivers/base/memblk.c Tue Mar 4 19:29:54 2003
+++ linux-2.5.64-sysfs_cleanup/drivers/base/memblk.c Mon Mar 17 14:09:42 2003
@@ -47,9 +47,12 @@
}


-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);
diff -Nur --exclude-from=/usr/src/.dontdiff linux-2.5.64-vanilla/drivers/base/node.c linux-2.5.64-sysfs_cleanup/drivers/base/node.c
--- linux-2.5.64-vanilla/drivers/base/node.c Tue Mar 4 19:29:00 2003
+++ linux-2.5.64-sysfs_cleanup/drivers/base/node.c Mon Mar 17 14:09:52 2003
@@ -89,9 +89,12 @@
}


-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);
\
 
 \ /
  Last update: 2005-03-22 13:34    [W:0.041 / U:8.632 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site