master/master.c
branchstable-1.5
changeset 2433 3bdd7a747fae
parent 2421 bc2d4bf9cbe5
child 2434 fa52128477f6
equal deleted inserted replaced
2432:f4313f5aba88 2433:3bdd7a747fae
     1 /******************************************************************************
     1 /******************************************************************************
     2  *
     2  *
     3  *  $Id$
     3  *  $Id$
     4  *
     4  *
     5  *  Copyright (C) 2006-2008  Florian Pose, Ingenieurgemeinschaft IgH
     5  *  Copyright (C) 2006-2012  Florian Pose, Ingenieurgemeinschaft IgH
     6  *
     6  *
     7  *  This file is part of the IgH EtherCAT Master.
     7  *  This file is part of the IgH EtherCAT Master.
     8  *
     8  *
     9  *  The IgH EtherCAT Master is free software; you can redistribute it and/or
     9  *  The IgH EtherCAT Master is free software; you can redistribute it and/or
    10  *  modify it under the terms of the GNU General Public License version 2, as
    10  *  modify it under the terms of the GNU General Public License version 2, as
   296         EC_MASTER_ERR(master, "Failed to create class device!\n");
   296         EC_MASTER_ERR(master, "Failed to create class device!\n");
   297         ret = PTR_ERR(master->class_device);
   297         ret = PTR_ERR(master->class_device);
   298         goto out_clear_cdev;
   298         goto out_clear_cdev;
   299     }
   299     }
   300 
   300 
       
   301 #ifdef EC_RTDM
       
   302     // init RTDM device
       
   303     ret = ec_rtdm_dev_init(&master->rtdm_dev, master);
       
   304     if (ret) {
       
   305         goto out_unregister_class_device;
       
   306     }
       
   307 #endif
       
   308 
   301     return 0;
   309     return 0;
   302 
   310 
       
   311 #ifdef EC_RTDM
       
   312 out_unregister_class_device:
       
   313 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
       
   314     device_unregister(master->class_device);
       
   315 #else
       
   316     class_device_unregister(master->class_device);
       
   317 #endif
       
   318 #endif
   303 out_clear_cdev:
   319 out_clear_cdev:
   304     ec_cdev_clear(&master->cdev);
   320     ec_cdev_clear(&master->cdev);
   305 out_clear_sync_mon:
   321 out_clear_sync_mon:
   306     ec_datagram_clear(&master->sync_mon_datagram);
   322     ec_datagram_clear(&master->sync_mon_datagram);
   307 out_clear_sync:
   323 out_clear_sync:
   325 */
   341 */
   326 void ec_master_clear(
   342 void ec_master_clear(
   327         ec_master_t *master /**< EtherCAT master */
   343         ec_master_t *master /**< EtherCAT master */
   328         )
   344         )
   329 {
   345 {
       
   346 #ifdef EC_RTDM
       
   347     ec_rtdm_dev_clear(&master->rtdm_dev);
       
   348 #endif
       
   349 
   330 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
   350 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
   331     device_unregister(master->class_device);
   351     device_unregister(master->class_device);
   332 #else
   352 #else
   333     class_device_unregister(master->class_device);
   353     class_device_unregister(master->class_device);
   334 #endif
   354 #endif