master/device.c
changeset 191 ca805255a935
parent 152 9654f3cf588d
child 195 674071846ee3
equal deleted inserted replaced
190:4e32bcc6b361 191:ca805255a935
   195  * Treiberschnittstelle
   195  * Treiberschnittstelle
   196  *
   196  *
   197  *****************************************************************************/
   197  *****************************************************************************/
   198 
   198 
   199 /**
   199 /**
   200    Prüft, ob das Net-Device \a dev zum registrierten EtherCAT-Gerät gehört.
       
   201 
       
   202    \return 0 wenn nein, nicht-null wenn ja.
       
   203 */
       
   204 
       
   205 inline int ecdev_is_ec(const ec_device_t *device,  /**< EtherCAT-Gerät */
       
   206                 const struct net_device *dev /**< Net-Device */
       
   207                 )
       
   208 {
       
   209     return device && device->dev == dev;
       
   210 }
       
   211 
       
   212 /*****************************************************************************/
       
   213 
       
   214 /**
       
   215    Nimmt einen Empfangenen Rahmen entgegen.
   200    Nimmt einen Empfangenen Rahmen entgegen.
   216 
   201 
   217    Kopiert die empfangenen Daten in den Receive-Buffer.
   202    Kopiert die empfangenen Daten in den Receive-Buffer.
   218 */
   203 */
   219 
   204 
   238 
   223 
   239 void ecdev_link_state(ec_device_t *device, /**< EtherCAT-Gerät */
   224 void ecdev_link_state(ec_device_t *device, /**< EtherCAT-Gerät */
   240                       uint8_t state /**< Verbindungszustand */
   225                       uint8_t state /**< Verbindungszustand */
   241                       )
   226                       )
   242 {
   227 {
       
   228     if (unlikely(!device)) {
       
   229         EC_WARN("ecdev_link_state: no device!\n");
       
   230         return;
       
   231     }
       
   232 
   243     if (likely(state != device->link_state)) {
   233     if (likely(state != device->link_state)) {
   244         device->link_state = state;
   234         device->link_state = state;
   245         EC_INFO("Link state changed to %s.\n", (state ? "UP" : "DOWN"));
   235         EC_INFO("Link state changed to %s.\n", (state ? "UP" : "DOWN"));
   246     }
   236     }
   247 }
   237 }
   248 
   238 
   249 /*****************************************************************************/
   239 /*****************************************************************************/
   250 
   240 
   251 EXPORT_SYMBOL(ecdev_is_ec);
       
   252 EXPORT_SYMBOL(ecdev_receive);
   241 EXPORT_SYMBOL(ecdev_receive);
   253 EXPORT_SYMBOL(ecdev_link_state);
   242 EXPORT_SYMBOL(ecdev_link_state);
   254 
   243 
   255 /*****************************************************************************/
   244 /*****************************************************************************/
   256 
   245