master/slave.c
changeset 625 ec69acbbd156
parent 624 11332ad89f47
child 626 a5e838c30733
equal deleted inserted replaced
624:11332ad89f47 625:ec69acbbd156
   239 */
   239 */
   240 
   240 
   241 void ec_slave_clear(struct kobject *kobj /**< kobject of the slave */)
   241 void ec_slave_clear(struct kobject *kobj /**< kobject of the slave */)
   242 {
   242 {
   243     ec_slave_t *slave;
   243     ec_slave_t *slave;
   244     ec_sii_pdo_t *pdo, *next_pdo;
   244     ec_pdo_t *pdo, *next_pdo;
   245     ec_sii_pdo_entry_t *entry, *next_ent;
   245     ec_pdo_entry_t *entry, *next_ent;
   246     ec_sdo_data_t *sdodata, *next_sdodata;
   246     ec_sdo_data_t *sdodata, *next_sdodata;
   247     unsigned int i;
   247     unsigned int i;
   248 
   248 
   249     slave = container_of(kobj, ec_slave_t, kobj);
   249     slave = container_of(kobj, ec_slave_t, kobj);
   250 
   250 
   517 
   517 
   518 int ec_slave_fetch_sii_pdos(
   518 int ec_slave_fetch_sii_pdos(
   519         ec_slave_t *slave, /**< EtherCAT slave */
   519         ec_slave_t *slave, /**< EtherCAT slave */
   520         const uint8_t *data, /**< category data */
   520         const uint8_t *data, /**< category data */
   521         size_t word_count, /**< number of words */
   521         size_t word_count, /**< number of words */
   522         ec_sii_pdo_type_t pdo_type /**< PDO type */
   522         ec_pdo_type_t pdo_type /**< PDO type */
   523         )
   523         )
   524 {
   524 {
   525     ec_sii_pdo_t *pdo;
   525     ec_pdo_t *pdo;
   526     ec_sii_pdo_entry_t *entry;
   526     ec_pdo_entry_t *entry;
   527     unsigned int entry_count, i;
   527     unsigned int entry_count, i;
   528 
   528 
   529     while (word_count >= 4) {
   529     while (word_count >= 4) {
   530         if (!(pdo = (ec_sii_pdo_t *)
   530         if (!(pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) {
   531               kmalloc(sizeof(ec_sii_pdo_t), GFP_ATOMIC))) {
       
   532             EC_ERR("Failed to allocate PDO memory.\n");
   531             EC_ERR("Failed to allocate PDO memory.\n");
   533             return -1;
   532             return -1;
   534         }
   533         }
   535 
   534 
   536         INIT_LIST_HEAD(&pdo->entries);
   535         INIT_LIST_HEAD(&pdo->entries);
   545 
   544 
   546         word_count -= 4;
   545         word_count -= 4;
   547         data += 8;
   546         data += 8;
   548 
   547 
   549         for (i = 0; i < entry_count; i++) {
   548         for (i = 0; i < entry_count; i++) {
   550             if (!(entry = (ec_sii_pdo_entry_t *)
   549             if (!(entry = kmalloc(sizeof(ec_pdo_entry_t), GFP_KERNEL))) {
   551                   kmalloc(sizeof(ec_sii_pdo_entry_t), GFP_ATOMIC))) {
       
   552                 EC_ERR("Failed to allocate PDO entry memory.\n");
   550                 EC_ERR("Failed to allocate PDO entry memory.\n");
   553                 return -1;
   551                 return -1;
   554             }
   552             }
   555 
   553 
   556             entry->index = EC_READ_U16(data);
   554             entry->index = EC_READ_U16(data);
   655                      char *buffer /**< Output buffer */
   653                      char *buffer /**< Output buffer */
   656                      )
   654                      )
   657 {
   655 {
   658     off_t off = 0;
   656     off_t off = 0;
   659     ec_sii_sync_t *sync;
   657     ec_sii_sync_t *sync;
   660     ec_sii_pdo_t *pdo;
   658     ec_pdo_t *pdo;
   661     ec_sii_pdo_entry_t *pdo_entry;
   659     ec_pdo_entry_t *pdo_entry;
   662     int first, i;
   660     int first, i;
   663     ec_sdo_data_t *sdodata;
   661     ec_sdo_data_t *sdodata;
   664     char str[20];
   662     char str[20];
   665 
   663 
   666     off += sprintf(buffer + off, "\nName: ");
   664     off += sprintf(buffer + off, "\nName: ");
  1071                                  /**< EtherCAT slave */
  1069                                  /**< EtherCAT slave */
  1072                                  const ec_sii_sync_t *sync
  1070                                  const ec_sii_sync_t *sync
  1073                                  /**< sync manager */
  1071                                  /**< sync manager */
  1074                                  )
  1072                                  )
  1075 {
  1073 {
  1076     ec_sii_pdo_t *pdo;
  1074     ec_pdo_t *pdo;
  1077     ec_sii_pdo_entry_t *pdo_entry;
  1075     ec_pdo_entry_t *pdo_entry;
  1078     unsigned int bit_size, byte_size;
  1076     unsigned int bit_size, byte_size;
  1079 
  1077 
  1080     if (sync->length) return sync->length;
  1078     if (sync->length) return sync->length;
  1081     if (sync->est_length) return sync->est_length;
  1079     if (sync->est_length) return sync->est_length;
  1082 
  1080