266 return 0; |
266 return 0; |
267 } |
267 } |
268 |
268 |
269 /*****************************************************************************/ |
269 /*****************************************************************************/ |
270 |
270 |
271 /** Get slave sync manager Pdo information. |
271 /** Get slave sync manager PDO information. |
272 */ |
272 */ |
273 int ec_cdev_ioctl_slave_sync_pdo( |
273 int ec_cdev_ioctl_slave_sync_pdo( |
274 ec_master_t *master, /**< EtherCAT master. */ |
274 ec_master_t *master, /**< EtherCAT master. */ |
275 unsigned long arg /**< Userspace address to store the results. */ |
275 unsigned long arg /**< Userspace address to store the results. */ |
276 ) |
276 ) |
303 |
303 |
304 sync = &slave->sii.syncs[data.sync_index]; |
304 sync = &slave->sii.syncs[data.sync_index]; |
305 if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
305 if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
306 &sync->pdos, data.pdo_pos))) { |
306 &sync->pdos, data.pdo_pos))) { |
307 up(&master->master_sem); |
307 up(&master->master_sem); |
308 EC_ERR("Sync manager %u does not contain a Pdo with " |
308 EC_ERR("Sync manager %u does not contain a PDO with " |
309 "position %u in slave %u!\n", data.sync_index, |
309 "position %u in slave %u!\n", data.sync_index, |
310 data.pdo_pos, data.slave_position); |
310 data.pdo_pos, data.slave_position); |
311 return -EINVAL; |
311 return -EINVAL; |
312 } |
312 } |
313 |
313 |
323 return 0; |
323 return 0; |
324 } |
324 } |
325 |
325 |
326 /*****************************************************************************/ |
326 /*****************************************************************************/ |
327 |
327 |
328 /** Get slave sync manager Pdo entry information. |
328 /** Get slave sync manager PDO entry information. |
329 */ |
329 */ |
330 int ec_cdev_ioctl_slave_sync_pdo_entry( |
330 int ec_cdev_ioctl_slave_sync_pdo_entry( |
331 ec_master_t *master, /**< EtherCAT master. */ |
331 ec_master_t *master, /**< EtherCAT master. */ |
332 unsigned long arg /**< Userspace address to store the results. */ |
332 unsigned long arg /**< Userspace address to store the results. */ |
333 ) |
333 ) |
361 |
361 |
362 sync = &slave->sii.syncs[data.sync_index]; |
362 sync = &slave->sii.syncs[data.sync_index]; |
363 if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
363 if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
364 &sync->pdos, data.pdo_pos))) { |
364 &sync->pdos, data.pdo_pos))) { |
365 up(&master->master_sem); |
365 up(&master->master_sem); |
366 EC_ERR("Sync manager %u does not contain a Pdo with " |
366 EC_ERR("Sync manager %u does not contain a PDO with " |
367 "position %u in slave %u!\n", data.sync_index, |
367 "position %u in slave %u!\n", data.sync_index, |
368 data.pdo_pos, data.slave_position); |
368 data.pdo_pos, data.slave_position); |
369 return -EINVAL; |
369 return -EINVAL; |
370 } |
370 } |
371 |
371 |
372 if (!(entry = ec_pdo_find_entry_by_pos_const( |
372 if (!(entry = ec_pdo_find_entry_by_pos_const( |
373 pdo, data.entry_pos))) { |
373 pdo, data.entry_pos))) { |
374 up(&master->master_sem); |
374 up(&master->master_sem); |
375 EC_ERR("Pdo 0x%04X does not contain an entry with " |
375 EC_ERR("PDO 0x%04X does not contain an entry with " |
376 "position %u in slave %u!\n", data.pdo_pos, |
376 "position %u in slave %u!\n", data.pdo_pos, |
377 data.entry_pos, data.slave_position); |
377 data.entry_pos, data.slave_position); |
378 return -EINVAL; |
378 return -EINVAL; |
379 } |
379 } |
380 |
380 |
567 return 0; |
567 return 0; |
568 } |
568 } |
569 |
569 |
570 /*****************************************************************************/ |
570 /*****************************************************************************/ |
571 |
571 |
572 /** Get slave Sdo information. |
572 /** Get slave SDO information. |
573 */ |
573 */ |
574 int ec_cdev_ioctl_slave_sdo( |
574 int ec_cdev_ioctl_slave_sdo( |
575 ec_master_t *master, /**< EtherCAT master. */ |
575 ec_master_t *master, /**< EtherCAT master. */ |
576 unsigned long arg /**< ioctl() argument. */ |
576 unsigned long arg /**< ioctl() argument. */ |
577 ) |
577 ) |
595 } |
595 } |
596 |
596 |
597 if (!(sdo = ec_slave_get_sdo_by_pos_const( |
597 if (!(sdo = ec_slave_get_sdo_by_pos_const( |
598 slave, data.sdo_position))) { |
598 slave, data.sdo_position))) { |
599 up(&master->master_sem); |
599 up(&master->master_sem); |
600 EC_ERR("Sdo %u does not exist in slave %u!\n", |
600 EC_ERR("SDO %u does not exist in slave %u!\n", |
601 data.sdo_position, data.slave_position); |
601 data.sdo_position, data.slave_position); |
602 return -EINVAL; |
602 return -EINVAL; |
603 } |
603 } |
604 |
604 |
605 data.sdo_index = sdo->index; |
605 data.sdo_index = sdo->index; |
614 return 0; |
614 return 0; |
615 } |
615 } |
616 |
616 |
617 /*****************************************************************************/ |
617 /*****************************************************************************/ |
618 |
618 |
619 /** Get slave Sdo entry information. |
619 /** Get slave SDO entry information. |
620 */ |
620 */ |
621 int ec_cdev_ioctl_slave_sdo_entry( |
621 int ec_cdev_ioctl_slave_sdo_entry( |
622 ec_master_t *master, /**< EtherCAT master. */ |
622 ec_master_t *master, /**< EtherCAT master. */ |
623 unsigned long arg /**< ioctl() argument. */ |
623 unsigned long arg /**< ioctl() argument. */ |
624 ) |
624 ) |
644 |
644 |
645 if (data.sdo_spec <= 0) { |
645 if (data.sdo_spec <= 0) { |
646 if (!(sdo = ec_slave_get_sdo_by_pos_const( |
646 if (!(sdo = ec_slave_get_sdo_by_pos_const( |
647 slave, -data.sdo_spec))) { |
647 slave, -data.sdo_spec))) { |
648 up(&master->master_sem); |
648 up(&master->master_sem); |
649 EC_ERR("Sdo %u does not exist in slave %u!\n", |
649 EC_ERR("SDO %u does not exist in slave %u!\n", |
650 -data.sdo_spec, data.slave_position); |
650 -data.sdo_spec, data.slave_position); |
651 return -EINVAL; |
651 return -EINVAL; |
652 } |
652 } |
653 } else { |
653 } else { |
654 if (!(sdo = ec_slave_get_sdo_const( |
654 if (!(sdo = ec_slave_get_sdo_const( |
655 slave, data.sdo_spec))) { |
655 slave, data.sdo_spec))) { |
656 up(&master->master_sem); |
656 up(&master->master_sem); |
657 EC_ERR("Sdo 0x%04X does not exist in slave %u!\n", |
657 EC_ERR("SDO 0x%04X does not exist in slave %u!\n", |
658 data.sdo_spec, data.slave_position); |
658 data.sdo_spec, data.slave_position); |
659 return -EINVAL; |
659 return -EINVAL; |
660 } |
660 } |
661 } |
661 } |
662 |
662 |
663 if (!(entry = ec_sdo_get_entry_const( |
663 if (!(entry = ec_sdo_get_entry_const( |
664 sdo, data.sdo_entry_subindex))) { |
664 sdo, data.sdo_entry_subindex))) { |
665 up(&master->master_sem); |
665 up(&master->master_sem); |
666 EC_ERR("Sdo entry 0x%04X:%02X does not exist " |
666 EC_ERR("SDO entry 0x%04X:%02X does not exist " |
667 "in slave %u!\n", sdo->index, |
667 "in slave %u!\n", sdo->index, |
668 data.sdo_entry_subindex, data.slave_position); |
668 data.sdo_entry_subindex, data.slave_position); |
669 return -EINVAL; |
669 return -EINVAL; |
670 } |
670 } |
671 |
671 |
1026 return 0; |
1026 return 0; |
1027 } |
1027 } |
1028 |
1028 |
1029 /*****************************************************************************/ |
1029 /*****************************************************************************/ |
1030 |
1030 |
1031 /** Get slave configuration Pdo information. |
1031 /** Get slave configuration PDO information. |
1032 */ |
1032 */ |
1033 int ec_cdev_ioctl_config_pdo( |
1033 int ec_cdev_ioctl_config_pdo( |
1034 ec_master_t *master, /**< EtherCAT master. */ |
1034 ec_master_t *master, /**< EtherCAT master. */ |
1035 unsigned long arg /**< ioctl() argument. */ |
1035 unsigned long arg /**< ioctl() argument. */ |
1036 ) |
1036 ) |
1062 |
1062 |
1063 if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
1063 if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
1064 &sc->sync_configs[data.sync_index].pdos, |
1064 &sc->sync_configs[data.sync_index].pdos, |
1065 data.pdo_pos))) { |
1065 data.pdo_pos))) { |
1066 up(&master->master_sem); |
1066 up(&master->master_sem); |
1067 EC_ERR("Invalid Pdo position!\n"); |
1067 EC_ERR("Invalid PDO position!\n"); |
1068 return -EINVAL; |
1068 return -EINVAL; |
1069 } |
1069 } |
1070 |
1070 |
1071 data.index = pdo->index; |
1071 data.index = pdo->index; |
1072 data.entry_count = ec_pdo_entry_count(pdo); |
1072 data.entry_count = ec_pdo_entry_count(pdo); |
1080 return 0; |
1080 return 0; |
1081 } |
1081 } |
1082 |
1082 |
1083 /*****************************************************************************/ |
1083 /*****************************************************************************/ |
1084 |
1084 |
1085 /** Get slave configuration Pdo entry information. |
1085 /** Get slave configuration PDO entry information. |
1086 */ |
1086 */ |
1087 int ec_cdev_ioctl_config_pdo_entry( |
1087 int ec_cdev_ioctl_config_pdo_entry( |
1088 ec_master_t *master, /**< EtherCAT master. */ |
1088 ec_master_t *master, /**< EtherCAT master. */ |
1089 unsigned long arg /**< ioctl() argument. */ |
1089 unsigned long arg /**< ioctl() argument. */ |
1090 ) |
1090 ) |
1117 |
1117 |
1118 if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
1118 if (!(pdo = ec_pdo_list_find_pdo_by_pos_const( |
1119 &sc->sync_configs[data.sync_index].pdos, |
1119 &sc->sync_configs[data.sync_index].pdos, |
1120 data.pdo_pos))) { |
1120 data.pdo_pos))) { |
1121 up(&master->master_sem); |
1121 up(&master->master_sem); |
1122 EC_ERR("Invalid Pdo position!\n"); |
1122 EC_ERR("Invalid PDO position!\n"); |
1123 return -EINVAL; |
1123 return -EINVAL; |
1124 } |
1124 } |
1125 |
1125 |
1126 if (!(entry = ec_pdo_find_entry_by_pos_const( |
1126 if (!(entry = ec_pdo_find_entry_by_pos_const( |
1127 pdo, data.entry_pos))) { |
1127 pdo, data.entry_pos))) { |
1143 return 0; |
1143 return 0; |
1144 } |
1144 } |
1145 |
1145 |
1146 /*****************************************************************************/ |
1146 /*****************************************************************************/ |
1147 |
1147 |
1148 /** Get slave configuration Sdo information. |
1148 /** Get slave configuration SDO information. |
1149 */ |
1149 */ |
1150 int ec_cdev_ioctl_config_sdo( |
1150 int ec_cdev_ioctl_config_sdo( |
1151 ec_master_t *master, /**< EtherCAT master. */ |
1151 ec_master_t *master, /**< EtherCAT master. */ |
1152 unsigned long arg /**< ioctl() argument. */ |
1152 unsigned long arg /**< ioctl() argument. */ |
1153 ) |
1153 ) |
1172 } |
1172 } |
1173 |
1173 |
1174 if (!(req = ec_slave_config_get_sdo_by_pos_const( |
1174 if (!(req = ec_slave_config_get_sdo_by_pos_const( |
1175 sc, data.sdo_pos))) { |
1175 sc, data.sdo_pos))) { |
1176 up(&master->master_sem); |
1176 up(&master->master_sem); |
1177 EC_ERR("Invalid Sdo position!\n"); |
1177 EC_ERR("Invalid SDO position!\n"); |
1178 return -EINVAL; |
1178 return -EINVAL; |
1179 } |
1179 } |
1180 |
1180 |
1181 data.index = req->index; |
1181 data.index = req->index; |
1182 data.subindex = req->subindex; |
1182 data.subindex = req->subindex; |