equal
deleted
inserted
replaced
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_pdo_t *pdo, *next_pdo; |
244 ec_pdo_t *pdo, *next_pdo; |
245 ec_pdo_entry_t *entry, *next_ent; |
|
246 ec_sdo_data_t *sdodata, *next_sdodata; |
245 ec_sdo_data_t *sdodata, *next_sdodata; |
247 unsigned int i; |
246 unsigned int i; |
248 |
247 |
249 slave = container_of(kobj, ec_slave_t, kobj); |
248 slave = container_of(kobj, ec_slave_t, kobj); |
250 |
249 |
259 if (slave->sii_syncs) kfree(slave->sii_syncs); |
258 if (slave->sii_syncs) kfree(slave->sii_syncs); |
260 |
259 |
261 // free all PDOs |
260 // free all PDOs |
262 list_for_each_entry_safe(pdo, next_pdo, &slave->sii_pdos, list) { |
261 list_for_each_entry_safe(pdo, next_pdo, &slave->sii_pdos, list) { |
263 list_del(&pdo->list); |
262 list_del(&pdo->list); |
264 |
263 ec_pdo_clear(pdo); |
265 // free all PDO entries |
|
266 list_for_each_entry_safe(entry, next_ent, &pdo->entries, list) { |
|
267 list_del(&entry->list); |
|
268 kfree(entry); |
|
269 } |
|
270 |
|
271 kfree(pdo); |
264 kfree(pdo); |
272 } |
265 } |
273 |
266 |
274 // free all SDO configurations |
267 // free all SDO configurations |
275 list_for_each_entry_safe(sdodata, next_sdodata, &slave->sdo_confs, list) { |
268 list_for_each_entry_safe(sdodata, next_sdodata, &slave->sdo_confs, list) { |
530 if (!(pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) { |
523 if (!(pdo = kmalloc(sizeof(ec_pdo_t), GFP_KERNEL))) { |
531 EC_ERR("Failed to allocate PDO memory.\n"); |
524 EC_ERR("Failed to allocate PDO memory.\n"); |
532 return -1; |
525 return -1; |
533 } |
526 } |
534 |
527 |
535 INIT_LIST_HEAD(&pdo->entries); |
528 ec_pdo_init(pdo); |
536 pdo->type = pdo_type; |
529 pdo->type = pdo_type; |
537 |
|
538 pdo->index = EC_READ_U16(data); |
530 pdo->index = EC_READ_U16(data); |
539 entry_count = EC_READ_U8(data + 2); |
531 entry_count = EC_READ_U8(data + 2); |
540 pdo->sync_index = EC_READ_U8(data + 3); |
532 pdo->sync_index = EC_READ_U8(data + 3); |
541 pdo->name = ec_slave_sii_string(slave, EC_READ_U8(data + 5)); |
533 pdo->name = ec_slave_sii_string(slave, EC_READ_U8(data + 5)); |
542 |
|
543 list_add_tail(&pdo->list, &slave->sii_pdos); |
534 list_add_tail(&pdo->list, &slave->sii_pdos); |
544 |
535 |
545 word_count -= 4; |
536 word_count -= 4; |
546 data += 8; |
537 data += 8; |
547 |
538 |
553 |
544 |
554 entry->index = EC_READ_U16(data); |
545 entry->index = EC_READ_U16(data); |
555 entry->subindex = EC_READ_U8(data + 2); |
546 entry->subindex = EC_READ_U8(data + 2); |
556 entry->name = ec_slave_sii_string(slave, EC_READ_U8(data + 3)); |
547 entry->name = ec_slave_sii_string(slave, EC_READ_U8(data + 3)); |
557 entry->bit_length = EC_READ_U8(data + 5); |
548 entry->bit_length = EC_READ_U8(data + 5); |
558 |
|
559 list_add_tail(&entry->list, &pdo->entries); |
549 list_add_tail(&entry->list, &pdo->entries); |
560 |
550 |
561 word_count -= 4; |
551 word_count -= 4; |
562 data += 8; |
552 data += 8; |
563 } |
553 } |
1069 /**< EtherCAT slave */ |
1059 /**< EtherCAT slave */ |
1070 const ec_sync_t *sync |
1060 const ec_sync_t *sync |
1071 /**< sync manager */ |
1061 /**< sync manager */ |
1072 ) |
1062 ) |
1073 { |
1063 { |
1074 ec_pdo_t *pdo; |
1064 const ec_pdo_t *pdo; |
1075 ec_pdo_entry_t *pdo_entry; |
1065 const ec_pdo_entry_t *pdo_entry; |
1076 unsigned int bit_size, byte_size; |
1066 unsigned int bit_size, byte_size; |
1077 |
1067 |
1078 if (sync->length) return sync->length; |
1068 if (sync->length) return sync->length; |
1079 if (sync->est_length) return sync->est_length; |
1069 if (sync->est_length) return sync->est_length; |
1080 |
1070 |