master/globals.h
changeset 259 87b20532872b
parent 256 dc71aee17f8a
child 293 14aeb79aa992
equal deleted inserted replaced
258:7d46b83e3175 259:87b20532872b
    88 #define EC_MAX_DATA_SIZE (ETH_DATA_LEN - EC_FRAME_HEADER_SIZE \
    88 #define EC_MAX_DATA_SIZE (ETH_DATA_LEN - EC_FRAME_HEADER_SIZE \
    89                           - EC_COMMAND_HEADER_SIZE - EC_COMMAND_FOOTER_SIZE)
    89                           - EC_COMMAND_HEADER_SIZE - EC_COMMAND_FOOTER_SIZE)
    90 
    90 
    91 /*****************************************************************************/
    91 /*****************************************************************************/
    92 
    92 
       
    93 /**
       
    94    Convenience macro for printing EtherCAT-specific information to syslog.
       
    95    This will print the message in \a fmt with a prefixed "EtherCAT: ".
       
    96    \param fmt format string (like in printf())
       
    97    \param args arguments (optional)
       
    98 */
       
    99 
    93 #define EC_INFO(fmt, args...) \
   100 #define EC_INFO(fmt, args...) \
    94     printk(KERN_INFO "EtherCAT: " fmt, ##args)
   101     printk(KERN_INFO "EtherCAT: " fmt, ##args)
       
   102 
       
   103 /**
       
   104    Convenience macro for printing EtherCAT-specific errors to syslog.
       
   105    This will print the message in \a fmt with a prefixed "EtherCAT ERROR: ".
       
   106    \param fmt format string (like in printf())
       
   107    \param args arguments (optional)
       
   108 */
       
   109 
    95 #define EC_ERR(fmt, args...) \
   110 #define EC_ERR(fmt, args...) \
    96     printk(KERN_ERR "EtherCAT ERROR: " fmt, ##args)
   111     printk(KERN_ERR "EtherCAT ERROR: " fmt, ##args)
       
   112 
       
   113 /**
       
   114    Convenience macro for printing EtherCAT-specific warnings to syslog.
       
   115    This will print the message in \a fmt with a prefixed "EtherCAT WARNING: ".
       
   116    \param fmt format string (like in printf())
       
   117    \param args arguments (optional)
       
   118 */
       
   119 
    97 #define EC_WARN(fmt, args...) \
   120 #define EC_WARN(fmt, args...) \
    98     printk(KERN_WARNING "EtherCAT WARNING: " fmt, ##args)
   121     printk(KERN_WARNING "EtherCAT WARNING: " fmt, ##args)
       
   122 
       
   123 /**
       
   124    Convenience macro for printing EtherCAT debug messages to syslog.
       
   125    This will print the message in \a fmt with a prefixed "EtherCAT DEBUG: ".
       
   126    \param fmt format string (like in printf())
       
   127    \param args arguments (optional)
       
   128 */
       
   129 
    99 #define EC_DBG(fmt, args...) \
   130 #define EC_DBG(fmt, args...) \
   100     printk(KERN_DEBUG "EtherCAT DEBUG: " fmt, ##args)
   131     printk(KERN_DEBUG "EtherCAT DEBUG: " fmt, ##args)
   101 
   132 
       
   133 /**
       
   134    Helper macro for EC_STR(), literates a macro argument.
       
   135    \param X argument to literate.
       
   136 */
       
   137 
   102 #define EC_LIT(X) #X
   138 #define EC_LIT(X) #X
       
   139 
       
   140 /**
       
   141    Converts a macro argument to a string.
       
   142    \param X argument to stringify.
       
   143 */
       
   144 
   103 #define EC_STR(X) EC_LIT(X)
   145 #define EC_STR(X) EC_LIT(X)
   104 
   146 
   105 /**
   147 /**
   106    Convenience macro for defining SysFS attributes.
   148    Convenience macro for defining read-only SysFS attributes.
       
   149    This results in creating a static variable called attr_\a NAME. The SysFS
       
   150    file will be world-readable.
       
   151    \param NAME name of the attribute to create.
   107 */
   152 */
   108 
   153 
   109 #define EC_SYSFS_READ_ATTR(NAME) \
   154 #define EC_SYSFS_READ_ATTR(NAME) \
   110     static struct attribute attr_##NAME = { \
   155     static struct attribute attr_##NAME = { \
   111         .name = EC_STR(NAME), .owner = THIS_MODULE, .mode = S_IRUGO \
   156         .name = EC_STR(NAME), .owner = THIS_MODULE, .mode = S_IRUGO \
   112     }
   157     }
       
   158 
       
   159 /**
       
   160    Convenience macro for defining read-write SysFS attributes.
       
   161    This results in creating a static variable called attr_\a NAME. The SysFS
       
   162    file will be word-readable plus owner-writable.
       
   163    \param NAME name of the attribute to create.
       
   164 */
   113 
   165 
   114 #define EC_SYSFS_READ_WRITE_ATTR(NAME) \
   166 #define EC_SYSFS_READ_WRITE_ATTR(NAME) \
   115     static struct attribute attr_##NAME = { \
   167     static struct attribute attr_##NAME = { \
   116         .name = EC_STR(NAME), .owner = THIS_MODULE, .mode = S_IRUGO | S_IWUSR \
   168         .name = EC_STR(NAME), .owner = THIS_MODULE, .mode = S_IRUGO | S_IWUSR \
   117     }
   169     }