master/module.c
changeset 251 c1d0b63a9302
parent 249 ee1d766dbc6b
child 286 f3352378b4d4
equal deleted inserted replaced
250:440ae5f6d2c3 251:c1d0b63a9302
    65                      " at " __DATE__ " " __TIME__
    65                      " at " __DATE__ " " __TIME__
    66 
    66 
    67 /*****************************************************************************/
    67 /*****************************************************************************/
    68 
    68 
    69 static int ec_master_count = 1;
    69 static int ec_master_count = 1;
       
    70 static int ec_eoe_devices = 0;
    70 static struct list_head ec_masters;
    71 static struct list_head ec_masters;
    71 
    72 
    72 /*****************************************************************************/
    73 /*****************************************************************************/
    73 
    74 
    74 /** \cond */
    75 /** \cond */
    75 
    76 
    76 MODULE_AUTHOR ("Florian Pose <fp@igh-essen.com>");
    77 module_param(ec_master_count, int, S_IRUGO);
    77 MODULE_DESCRIPTION ("EtherCAT master driver module");
    78 module_param(ec_eoe_devices, int, S_IRUGO);
       
    79 
       
    80 MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
       
    81 MODULE_DESCRIPTION("EtherCAT master driver module");
    78 MODULE_LICENSE("GPL");
    82 MODULE_LICENSE("GPL");
    79 MODULE_VERSION(COMPILE_INFO);
    83 MODULE_VERSION(COMPILE_INFO);
    80 
       
    81 module_param(ec_master_count, int, 1);
       
    82 MODULE_PARM_DESC(ec_master_count, "number of EtherCAT masters to initialize");
    84 MODULE_PARM_DESC(ec_master_count, "number of EtherCAT masters to initialize");
       
    85 MODULE_PARM_DESC(ec_eoe_devices, "number of EoE devices per master");
    83 
    86 
    84 /** \endcond */
    87 /** \endcond */
    85 
    88 
    86 /*****************************************************************************/
    89 /*****************************************************************************/
    87 
    90 
   112               (ec_master_t *) kmalloc(sizeof(ec_master_t), GFP_KERNEL))) {
   115               (ec_master_t *) kmalloc(sizeof(ec_master_t), GFP_KERNEL))) {
   113             EC_ERR("Failed to allocate memory for EtherCAT master %i.\n", i);
   116             EC_ERR("Failed to allocate memory for EtherCAT master %i.\n", i);
   114             goto out_free;
   117             goto out_free;
   115         }
   118         }
   116 
   119 
   117         if (ec_master_init(master, i)) // kobject_put is done inside...
   120         if (ec_master_init(master, i, ec_eoe_devices))
   118             goto out_free;
   121             goto out_free;
   119 
   122 
   120         if (kobject_add(&master->kobj)) {
   123         if (kobject_add(&master->kobj)) {
   121             EC_ERR("Failed to add kobj.\n");
   124             EC_ERR("Failed to add kobj.\n");
   122             kobject_put(&master->kobj); // free master
   125             kobject_put(&master->kobj); // free master
   224             printk("\n");
   227             printk("\n");
   225             EC_DBG("");
   228             EC_DBG("");
   226         }
   229         }
   227     }
   230     }
   228     printk("\n");
   231     printk("\n");
       
   232 }
       
   233 
       
   234 /*****************************************************************************/
       
   235 
       
   236 /**
       
   237    Prints slave states in clear text.
       
   238 */
       
   239 
       
   240 void ec_print_states(const uint8_t states /**< slave states */)
       
   241 {
       
   242     unsigned int first = 1;
       
   243 
       
   244     if (!states) {
       
   245         printk("(unknown)");
       
   246         return;
       
   247     }
       
   248 
       
   249     if (states & EC_SLAVE_STATE_INIT) {
       
   250         printk("INIT");
       
   251         first = 0;
       
   252     }
       
   253     if (states & EC_SLAVE_STATE_PREOP) {
       
   254         if (!first) printk(", ");
       
   255         printk("PREOP");
       
   256         first = 0;
       
   257     }
       
   258     if (states & EC_SLAVE_STATE_SAVEOP) {
       
   259         if (!first) printk(", ");
       
   260         printk("SAVEOP");
       
   261         first = 0;
       
   262     }
       
   263     if (states & EC_SLAVE_STATE_OP) {
       
   264         if (!first) printk(", ");
       
   265         printk("OP");
       
   266     }
   229 }
   267 }
   230 
   268 
   231 /******************************************************************************
   269 /******************************************************************************
   232  *  Device interface
   270  *  Device interface
   233  *****************************************************************************/
   271  *****************************************************************************/