equal
deleted
inserted
replaced
33 * |
33 * |
34 *****************************************************************************/ |
34 *****************************************************************************/ |
35 |
35 |
36 // Linux |
36 // Linux |
37 #include <linux/module.h> |
37 #include <linux/module.h> |
|
38 #include <linux/err.h> |
38 |
39 |
39 // RTAI |
40 // RTAI |
40 #include <rtai_sched.h> |
41 #include <rtai_sched.h> |
41 #include <rtai_sem.h> |
42 #include <rtai_sem.h> |
42 |
43 |
266 |
267 |
267 /*****************************************************************************/ |
268 /*****************************************************************************/ |
268 |
269 |
269 int __init init_mod(void) |
270 int __init init_mod(void) |
270 { |
271 { |
|
272 int ret = -1; |
271 RTIME tick_period, requested_ticks, now; |
273 RTIME tick_period, requested_ticks, now; |
272 #ifdef CONFIGURE_PDOS |
274 #ifdef CONFIGURE_PDOS |
273 ec_slave_config_t *sc; |
275 ec_slave_config_t *sc; |
274 #endif |
276 #endif |
275 |
277 |
277 |
279 |
278 rt_sem_init(&master_sem, 1); |
280 rt_sem_init(&master_sem, 1); |
279 |
281 |
280 t_critical = cpu_khz * 1000 / FREQUENCY - cpu_khz * INHIBIT_TIME / 1000; |
282 t_critical = cpu_khz * 1000 / FREQUENCY - cpu_khz * INHIBIT_TIME / 1000; |
281 |
283 |
282 if (!(master = ecrt_request_master(0))) { |
284 |
|
285 master = ecrt_request_master(0); |
|
286 if (IS_ERR(master)) { |
|
287 ret = PTR_ERR(master); |
283 printk(KERN_ERR PFX "Requesting master 0 failed!\n"); |
288 printk(KERN_ERR PFX "Requesting master 0 failed!\n"); |
284 goto out_return; |
289 goto out_return; |
285 } |
290 } |
286 |
291 |
287 ecrt_master_callbacks(master, request_lock, release_lock, NULL); |
292 ecrt_master_callbacks(master, request_lock, release_lock, NULL); |
359 printk(KERN_ERR PFX "Releasing master...\n"); |
364 printk(KERN_ERR PFX "Releasing master...\n"); |
360 ecrt_release_master(master); |
365 ecrt_release_master(master); |
361 out_return: |
366 out_return: |
362 rt_sem_delete(&master_sem); |
367 rt_sem_delete(&master_sem); |
363 printk(KERN_ERR PFX "Failed to load. Aborting.\n"); |
368 printk(KERN_ERR PFX "Failed to load. Aborting.\n"); |
364 return -1; |
369 return ret; |
365 } |
370 } |
366 |
371 |
367 /*****************************************************************************/ |
372 /*****************************************************************************/ |
368 |
373 |
369 void __exit cleanup_mod(void) |
374 void __exit cleanup_mod(void) |