equal
deleted
inserted
replaced
100 \return 0 in case of success, else < 0 |
100 \return 0 in case of success, else < 0 |
101 */ |
101 */ |
102 |
102 |
103 int ec_master_init(ec_master_t *master, /**< EtherCAT master */ |
103 int ec_master_init(ec_master_t *master, /**< EtherCAT master */ |
104 unsigned int index, /**< master index */ |
104 unsigned int index, /**< master index */ |
105 unsigned int eoeif_count, /**< number of EoE interfaces */ |
105 unsigned int eoeif_count /**< number of EoE interfaces */ |
106 dev_t dev_num /**< number for XML cdev's */ |
|
107 ) |
106 ) |
108 { |
107 { |
109 ec_eoe_t *eoe, *next_eoe; |
108 ec_eoe_t *eoe, *next_eoe; |
110 unsigned int i; |
109 unsigned int i; |
111 |
110 |
162 init_timer(&master->sdo_timer); |
161 init_timer(&master->sdo_timer); |
163 master->sdo_timer.function = ec_master_check_sdo; |
162 master->sdo_timer.function = ec_master_check_sdo; |
164 master->sdo_timer.data = (unsigned long) master; |
163 master->sdo_timer.data = (unsigned long) master; |
165 init_completion(&master->sdo_complete); |
164 init_completion(&master->sdo_complete); |
166 |
165 |
167 // init XML character device |
|
168 if (ec_xmldev_init(&master->xmldev, master, dev_num)) { |
|
169 EC_ERR("Failed to init XML character device.\n"); |
|
170 goto out_return; |
|
171 } |
|
172 |
|
173 // create EoE handlers |
166 // create EoE handlers |
174 for (i = 0; i < eoeif_count; i++) { |
167 for (i = 0; i < eoeif_count; i++) { |
175 if (!(eoe = (ec_eoe_t *) kmalloc(sizeof(ec_eoe_t), GFP_KERNEL))) { |
168 if (!(eoe = (ec_eoe_t *) kmalloc(sizeof(ec_eoe_t), GFP_KERNEL))) { |
176 EC_ERR("Failed to allocate EoE-Object.\n"); |
169 EC_ERR("Failed to allocate EoE-Object.\n"); |
177 goto out_clear_eoe; |
170 goto out_clear_eoe; |
214 list_for_each_entry_safe(eoe, next_eoe, &master->eoe_handlers, list) { |
207 list_for_each_entry_safe(eoe, next_eoe, &master->eoe_handlers, list) { |
215 list_del(&eoe->list); |
208 list_del(&eoe->list); |
216 ec_eoe_clear(eoe); |
209 ec_eoe_clear(eoe); |
217 kfree(eoe); |
210 kfree(eoe); |
218 } |
211 } |
219 ec_xmldev_clear(&master->xmldev); |
|
220 out_return: |
|
221 return -1; |
212 return -1; |
222 } |
213 } |
223 |
214 |
224 /*****************************************************************************/ |
215 /*****************************************************************************/ |
225 |
216 |
259 list_del_init(&datagram->queue); |
250 list_del_init(&datagram->queue); |
260 } |
251 } |
261 |
252 |
262 ec_fsm_master_clear(&master->fsm); |
253 ec_fsm_master_clear(&master->fsm); |
263 ec_datagram_clear(&master->fsm_datagram); |
254 ec_datagram_clear(&master->fsm_datagram); |
264 ec_xmldev_clear(&master->xmldev); |
|
265 |
255 |
266 // clear EoE objects |
256 // clear EoE objects |
267 list_for_each_entry_safe(eoe, next_eoe, &master->eoe_handlers, list) { |
257 list_for_each_entry_safe(eoe, next_eoe, &master->eoe_handlers, list) { |
268 list_del(&eoe->list); |
258 list_del(&eoe->list); |
269 ec_eoe_clear(eoe); |
259 ec_eoe_clear(eoe); |