[svn-commits] tzafrir: branch linux/tzafrir/sysfs r8584 - /linux/team/tzafrir/sysfs/drivers...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon May 3 02:45:14 CDT 2010
Author: tzafrir
Date: Mon May 3 02:45:11 2010
New Revision: 8584
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8584
Log:
Better error handling. procfs entries mostly
Improve hadling of errors in dahdi_init()
Modified:
linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c?view=diff&rev=8584&r1=8583&r2=8584
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c Mon May 3 02:45:11 2010
@@ -5841,6 +5841,25 @@
}
#endif
+#ifdef CONFIG_PROC_FS
+static void cleanup_proc(void)
+{
+ int i;
+
+ if (proc_entries[0]) {
+ for (i = 1; i < ARRAY_SIZE(proc_entries); i++) {
+ if (proc_entries[i]) {
+ remove_proc_entry(proc_entries[i]->name,
+ proc_entries[0]);
+ proc_entries[i] = NULL;
+ }
+ }
+ remove_proc_entry(proc_entries[0]->name, NULL);
+ proc_entries[0] = NULL;
+ }
+}
+#endif
+
/**
* dahdi_register() - unregister a new DAHDI span
* @span: the DAHDI span
@@ -5971,10 +5990,6 @@
int new_maxspans;
static struct dahdi_span *new_master;
-#ifdef CONFIG_PROC_FS
- char tempfile[17];
-#endif /* CONFIG_PROC_FS */
-
if (!test_bit(DAHDI_FLAGBIT_REGISTERED, &span->flags)) {
module_printk(KERN_ERR, "Span %s does not appear to be registered\n", span->name);
return -1;
@@ -5991,8 +6006,11 @@
if (debug)
module_printk(KERN_NOTICE, "Unregistering Span '%s' with %d channels\n", span->name, span->channels);
#ifdef CONFIG_PROC_FS
- snprintf(tempfile, sizeof(tempfile)-1, "dahdi/%d", span->spanno);
- remove_proc_entry(tempfile, NULL);
+ if (proc_entries[span->spanno] && proc_entries[0]) {
+ remove_proc_entry(proc_entries[span->spanno]->name,
+ proc_entries[0]);
+ proc_entries[span->spanno] = NULL;
+ }
#endif /* CONFIG_PROC_FS */
spans[span->spanno] = NULL;
@@ -8607,11 +8625,16 @@
#ifdef CONFIG_PROC_FS
proc_entries[0] = proc_mkdir("dahdi", NULL);
+ if (proc_entries[0] == NULL) {
+ module_printk(KERN_ERR, "Failed creating /proc/dahdi\n");
+ res = -ENOENT;
+ goto fail_proc;
+ }
#endif
if ((res = register_chrdev(DAHDI_MAJOR, "dahdi", &dahdi_fops))) {
module_printk(KERN_ERR, "Unable to register DAHDI character device handler on %d\n", DAHDI_MAJOR);
- return res;
+ goto fail_chrdev;
}
res = dahdi_driver_init(&dahdi_fops);
@@ -8619,7 +8642,7 @@
// TODO: Remove this. dahdi_driver_init should report
// errors.
module_printk(KERN_ERR, "Error starting sysfs: %d\n", res);
- return res;
+ goto fail_driverinit;
}
module_printk(KERN_INFO, "Telephony Interface Registered on major %d\n", DAHDI_MAJOR);
@@ -8632,6 +8655,12 @@
#endif
coretimer_init();
return res;
+fail_driverinit:
+ unregister_chrdev(DAHDI_MAJOR, "dahdi");
+fail_chrdev:
+ cleanup_proc();
+fail_proc:
+ return res;
}
static void __exit dahdi_cleanup(void)
@@ -8643,7 +8672,7 @@
unregister_chrdev(DAHDI_MAJOR, "dahdi");
#ifdef CONFIG_PROC_FS
- remove_proc_entry("dahdi", NULL);
+ cleanup_proc();
#endif
module_printk(KERN_INFO, "Telephony Interface Unloaded\n");
More information about the svn-commits
mailing list