master/slave.h
changeset 2037 ea0319750e13
parent 1921 d9cf40facbc4
child 2045 ff2a13a4603c
equal deleted inserted replaced
2036:7fbc7bb7b95a 2037:ea0319750e13
    57  *
    57  *
    58  * \param slave EtherCAT slave
    58  * \param slave EtherCAT slave
    59  * \param fmt format string (like in printf())
    59  * \param fmt format string (like in printf())
    60  * \param args arguments (optional)
    60  * \param args arguments (optional)
    61  */
    61  */
       
    62 #ifdef USE_TRACE_PRINTK
       
    63 #define EC_SLAVE_INFO(slave, fmt, args...) \
       
    64     do { \
       
    65         __trace_printk(_THIS_IP_,"EtherCAT %u-%u: " fmt, slave->master->index, \
       
    66                 slave->ring_position, ##args); \
       
    67         printk(KERN_INFO "EtherCAT %u-%u: " fmt, slave->master->index, \
       
    68                 slave->ring_position, ##args);  \
       
    69     } while (0)
       
    70 #else
    62 #define EC_SLAVE_INFO(slave, fmt, args...) \
    71 #define EC_SLAVE_INFO(slave, fmt, args...) \
    63     printk(KERN_INFO "EtherCAT %u-%u: " fmt, slave->master->index, \
    72     printk(KERN_INFO "EtherCAT %u-%u: " fmt, slave->master->index, \
    64             slave->ring_position, ##args)
    73             slave->ring_position, ##args)
       
    74 #endif
    65 
    75 
    66 /** Convenience macro for printing slave-specific errors to syslog.
    76 /** Convenience macro for printing slave-specific errors to syslog.
    67  *
    77  *
    68  * This will print the message in \a fmt with a prefixed
    78  * This will print the message in \a fmt with a prefixed
    69  * "EtherCAT <INDEX>-<POSITION>: ", where INDEX is the master index and
    79  * "EtherCAT <INDEX>-<POSITION>: ", where INDEX is the master index and
    71  *
    81  *
    72  * \param slave EtherCAT slave
    82  * \param slave EtherCAT slave
    73  * \param fmt format string (like in printf())
    83  * \param fmt format string (like in printf())
    74  * \param args arguments (optional)
    84  * \param args arguments (optional)
    75  */
    85  */
       
    86 #ifdef USE_TRACE_PRINTK
       
    87 #define EC_SLAVE_ERR(slave, fmt, args...) \
       
    88     do { \
       
    89         __trace_printk(_THIS_IP_,"EtherCAT ERROR %u-%u: " fmt, slave->master->index, \
       
    90                 slave->ring_position, ##args); \
       
    91         printk(KERN_ERR "EtherCAT ERROR %u-%u: " fmt, slave->master->index, \
       
    92                 slave->ring_position, ##args);  \
       
    93     } while (0)
       
    94 #else
    76 #define EC_SLAVE_ERR(slave, fmt, args...) \
    95 #define EC_SLAVE_ERR(slave, fmt, args...) \
    77     printk(KERN_ERR "EtherCAT ERROR %u-%u: " fmt, slave->master->index, \
    96     printk(KERN_ERR "EtherCAT ERROR %u-%u: " fmt, slave->master->index, \
    78             slave->ring_position, ##args)
    97             slave->ring_position, ##args)
       
    98 #endif
    79 
    99 
    80 /** Convenience macro for printing slave-specific warnings to syslog.
   100 /** Convenience macro for printing slave-specific warnings to syslog.
    81  *
   101  *
    82  * This will print the message in \a fmt with a prefixed
   102  * This will print the message in \a fmt with a prefixed
    83  * "EtherCAT <INDEX>-<POSITION>: ", where INDEX is the master index and
   103  * "EtherCAT <INDEX>-<POSITION>: ", where INDEX is the master index and
    85  *
   105  *
    86  * \param slave EtherCAT slave
   106  * \param slave EtherCAT slave
    87  * \param fmt format string (like in printf())
   107  * \param fmt format string (like in printf())
    88  * \param args arguments (optional)
   108  * \param args arguments (optional)
    89  */
   109  */
       
   110 #ifdef USE_TRACE_PRINTK
       
   111 #define EC_SLAVE_WARN(slave, fmt, args...) \
       
   112     do { \
       
   113         __trace_printk(_THIS_IP_,"EtherCAT WARNING %u-%u: " fmt, \
       
   114                 slave->master->index, slave->ring_position, ##args); \
       
   115         printk(KERN_WARNING "EtherCAT WARNING %u-%u: " fmt, \
       
   116                 slave->master->index, slave->ring_position, ##args);    \
       
   117     } while (0)
       
   118 #else
    90 #define EC_SLAVE_WARN(slave, fmt, args...) \
   119 #define EC_SLAVE_WARN(slave, fmt, args...) \
    91     printk(KERN_WARNING "EtherCAT WARNING %u-%u: " fmt, \
   120     printk(KERN_WARNING "EtherCAT WARNING %u-%u: " fmt, \
    92             slave->master->index, slave->ring_position, ##args)
   121             slave->master->index, slave->ring_position, ##args)
       
   122 #endif
    93 
   123 
    94 /** Convenience macro for printing slave-specific debug messages to syslog.
   124 /** Convenience macro for printing slave-specific debug messages to syslog.
    95  *
   125  *
    96  * This will print the message in \a fmt with a prefixed
   126  * This will print the message in \a fmt with a prefixed
    97  * "EtherCAT <INDEX>-<POSITION>: ", where INDEX is the master index and
   127  * "EtherCAT <INDEX>-<POSITION>: ", where INDEX is the master index and
    99  *
   129  *
   100  * \param slave EtherCAT slave
   130  * \param slave EtherCAT slave
   101  * \param fmt format string (like in printf())
   131  * \param fmt format string (like in printf())
   102  * \param args arguments (optional)
   132  * \param args arguments (optional)
   103  */
   133  */
       
   134 #ifdef USE_TRACE_PRINTK
   104 #define EC_SLAVE_DBG(slave, level, fmt, args...) \
   135 #define EC_SLAVE_DBG(slave, level, fmt, args...) \
   105     do { \
   136     do { \
       
   137         __trace_printk(_THIS_IP_,"EtherCAT DEBUG%u %u-%u: " fmt, \
       
   138             level,slave->master->index, slave->ring_position, ##args); \
   106         if (slave->master->debug_level >= level) { \
   139         if (slave->master->debug_level >= level) { \
   107             printk(KERN_DEBUG "EtherCAT DEBUG %u-%u: " fmt, \
   140             printk(KERN_DEBUG "EtherCAT DEBUG %u-%u: " fmt, \
   108                     slave->master->index, slave->ring_position, ##args); \
   141                     slave->master->index, slave->ring_position, ##args); \
   109         } \
   142         } \
   110     } while (0)
   143     } while (0)
       
   144 #else
       
   145 #define EC_SLAVE_DBG(slave, level, fmt, args...) \
       
   146     do { \
       
   147         if (slave->master->debug_level >= level) { \
       
   148             printk(KERN_DEBUG "EtherCAT DEBUG %u-%u: " fmt, \
       
   149                     slave->master->index, slave->ring_position, ##args); \
       
   150         } \
       
   151     } while (0)
       
   152 #endif
   111 
   153 
   112 /*****************************************************************************/
   154 /*****************************************************************************/
   113 
   155 
   114 /** Slave port.
   156 /** Slave port.
   115  */
   157  */