master/module.c
changeset 361 29af81543ce1
parent 356 4bdc4f2e1a93
child 377 ecac8252f114
--- a/master/module.c	Tue Sep 19 13:09:39 2006 +0000
+++ b/master/module.c	Tue Sep 19 13:28:40 2006 +0000
@@ -56,6 +56,7 @@
 static int ec_master_count = 1; /**< parameter value, number of masters */
 static int ec_eoeif_count = 0; /**< parameter value, number of EoE interf. */
 static struct list_head ec_masters; /**< list of masters */
+static dev_t device_number;
 
 /*****************************************************************************/
 
@@ -89,7 +90,12 @@
     EC_INFO("Master driver, %s\n", EC_COMPILE_INFO);
 
     if (ec_master_count < 1) {
-        EC_ERR("Error - Invalid ec_master_count: %i\n", ec_master_count);
+        EC_ERR("Invalid ec_master_count: %i\n", ec_master_count);
+        goto out_return;
+    }
+
+    if (alloc_chrdev_region(&device_number, 0, ec_master_count, "EtherCAT")) {
+        EC_ERR("Failed to allocate device number!\n");
         goto out_return;
     }
 
@@ -104,7 +110,7 @@
             goto out_free;
         }
 
-        if (ec_master_init(master, i, ec_eoeif_count))
+        if (ec_master_init(master, i, ec_eoeif_count, device_number))
             goto out_free;
 
         if (kobject_add(&master->kobj)) {
@@ -148,6 +154,8 @@
         kobject_put(&master->kobj); // free master
     }
 
+    unregister_chrdev_region(device_number, ec_master_count);
+
     EC_INFO("Master driver cleaned up.\n");
 }