]> granicus.if.org Git - spl/commitdiff
Two fixes to the module interface. Could be worse!
authorbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Fri, 21 Mar 2008 19:16:25 +0000 (19:16 +0000)
committerbehlendo <behlendo@7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c>
Fri, 21 Mar 2008 19:16:25 +0000 (19:16 +0000)
git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@53 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c

include/sys/types32.h
modules/spl/spl-module.c

index 6df64e713924614484cc9b7f1cedebd6abadf1af..5b5085659bfeab1b03619231c1bf36ed91a53049 100644 (file)
@@ -26,9 +26,8 @@
 #ifndef _SYS_TYPES32_H
 #define        _SYS_TYPES32_H
 
-
-
 #include <sys/int_types.h>
+#include <sys/types.h>
 
 #ifdef __cplusplus
 extern "C" {
index efe516adb91a326122866d16a8b50714d2015987..309188ce56ce3e4ca413024845aa7b5d22dfa355 100644 (file)
@@ -52,7 +52,7 @@ __ddi_create_minor_node(dev_info_t *di, char *name, int spec_type,
        int rc;
 
        BUG_ON(spec_type != S_IFCHR);
-       BUG_ON(minor_num < di->di_minors);
+       BUG_ON(minor_num >= di->di_minors);
        BUG_ON(strcmp(node_type, DDI_PSEUDO));
        BUG_ON(flag != 0);
 
@@ -131,8 +131,14 @@ __ddi_create_minor_node(dev_info_t *di, char *name, int spec_type,
                return DDI_FAILURE;
        }
 
-        class_device_create(di->di_class, NULL, di->di_dev,
-                           NULL, "%s%d", name, di->di_minor);
+       /* Do not append a 0 to devices with minor nums of 0 */
+       if (di->di_minor == 0) {
+               class_device_create(di->di_class, NULL, di->di_dev,
+                                   NULL, "%s", name);
+       } else {
+               class_device_create(di->di_class, NULL, di->di_dev,
+                                   NULL, "%s%d", name, di->di_minor);
+       }
 
        di->di_cdev = cdev;
 
@@ -147,14 +153,23 @@ __ddi_create_minor_node(dev_info_t *di, char *name, int spec_type,
 EXPORT_SYMBOL(__ddi_create_minor_node);
 
 static void
-___ddi_remove_minor_node(dev_info_t *di, char *name)
+__ddi_remove_minor_node_locked(dev_info_t *di, char *name)
 {
-       class_device_destroy(di->di_class, di->di_dev);
-       class_destroy(di->di_class);
-       cdev_del(di->di_cdev);
+       if (di->di_class) {
+               class_device_destroy(di->di_class, di->di_dev);
+               class_destroy(di->di_class);
+
+               di->di_class = NULL;
+               di->di_dev = 0;
+       }
+
+       if (di->di_cdev) {
+               cdev_del(di->di_cdev);
+               di->di_cdev = NULL;
+       }
 
        spin_lock(&dev_info_lock);
-        list_del(&di->di_list);
+        list_del_init(&di->di_list);
        spin_unlock(&dev_info_lock);
 }
 
@@ -162,7 +177,7 @@ void
 __ddi_remove_minor_node(dev_info_t *di, char *name)
 {
        mutex_enter(&di->di_lock);
-       ___ddi_remove_minor_node(di, name);
+       __ddi_remove_minor_node_locked(di, name);
        mutex_exit(&di->di_lock);
 }
 EXPORT_SYMBOL(ddi_remove_minor_node);
@@ -218,7 +233,7 @@ static void
 dev_info_free(struct dev_info *di)
 {
        mutex_enter(&di->di_lock);
-       __ddi_remove_minor_node(di, NULL);
+       __ddi_remove_minor_node_locked(di, NULL);
        mutex_exit(&di->di_lock);
        mutex_destroy(&di->di_lock);
        kfree(di);