37 #include <linux/module.h> 54 INIT_LIST_HEAD(&pl->
list);
74 list_for_each_entry_safe(pdo, next, &pl->
list, list) {
75 list_del_init(&pdo->
list);
91 unsigned int bit_size;
97 list_for_each_entry(pdo, &pl->
list, list) {
98 list_for_each_entry(pdo_entry, &pdo->
entries, list) {
104 byte_size = bit_size / 8 + 1;
106 byte_size = bit_size / 8;
125 EC_ERR(
"Failed to allocate memory for PDO.\n");
126 return ERR_PTR(-ENOMEM);
131 list_add_tail(&pdo->
list, &pl->
list);
150 list_for_each_entry(mapped_pdo, &pl->
list, list) {
151 if (mapped_pdo->
index != pdo->
index)
continue;
152 EC_ERR(
"PDO 0x%04X is already mapped!\n", pdo->
index);
156 if (!(mapped_pdo = kmalloc(
sizeof(
ec_pdo_t), GFP_KERNEL))) {
157 EC_ERR(
"Failed to allocate PDO memory.\n");
167 list_add_tail(&mapped_pdo->
list, &pl->
list);
188 list_for_each_entry(other_pdo, &other->
list, list) {
212 const struct list_head *h1, *h2, *l1, *l2;
215 h1 = l1 = &pl1->
list;
216 h2 = l2 = &pl2->
list;
222 if ((l1 == h1) ^ (l2 == h2))
227 p1 = list_entry(l1,
ec_pdo_t, list);
228 p2 = list_entry(l2,
ec_pdo_t, list);
250 list_for_each_entry(pdo, &pl->
list, list) {
251 if (pdo->
index != index)
272 list_for_each_entry(pdo, &pl->
list, list) {
273 if (pdo->
index != index)
296 list_for_each_entry(pdo, &pl->
list, list) {
316 unsigned int num = 0;
318 list_for_each_entry(pdo, &pl->
list, list) {
335 if (list_empty(&pl->
list)) {
336 printk(KERN_CONT
"(none)");
338 list_for_each_entry(pdo, &pl->
list, list) {
339 printk(KERN_CONT
"0x%04X", pdo->
index);
341 printk(KERN_CONT
" ");
const ec_pdo_t * ec_pdo_list_find_pdo_const(const ec_pdo_list_t *pl, uint16_t index)
Finds a PDO with the given index and returns a const pointer.
void ec_pdo_list_print(const ec_pdo_list_t *pl)
Outputs the PDOs in the list.
int ec_pdo_list_copy(ec_pdo_list_t *pl, const ec_pdo_list_t *other)
Makes a deep copy of another PDO list.
void ec_pdo_list_clear(ec_pdo_list_t *pl)
PDO list destructor.
struct list_head list
List of PDOs.
void ec_pdo_list_clear_pdos(ec_pdo_list_t *pl)
Clears the list of mapped PDOs.
void ec_pdo_init(ec_pdo_t *pdo)
PDO constructor.
unsigned int ec_pdo_list_count(const ec_pdo_list_t *pl)
Get the number of PDOs in the list.
Global definitions and macros.
EtherCAT master structure.
void ec_pdo_clear(ec_pdo_t *pdo)
PDO destructor.
EtherCAT PDO list structure.
int ec_pdo_init_copy(ec_pdo_t *pdo, const ec_pdo_t *other_pdo)
PDO copy constructor.
uint16_t ec_pdo_list_total_size(const ec_pdo_list_t *pl)
Calculates the total size of the mapped PDO entries.
int ec_pdo_list_add_pdo_copy(ec_pdo_list_t *pl, const ec_pdo_t *pdo)
Add the copy of an existing PDO to the list.
uint8_t bit_length
entry length in bit
struct list_head entries
List of PDO entries.
ec_pdo_t * ec_pdo_list_add_pdo(ec_pdo_list_t *pl, uint16_t index)
Add a new PDO to the list.
#define EC_ERR(fmt, args...)
Convenience macro for printing EtherCAT-specific errors to syslog.
void ec_pdo_list_init(ec_pdo_list_t *pl)
PDO list constructor.
EtherCAT slave configuration structure.
int ec_pdo_list_equal(const ec_pdo_list_t *pl1, const ec_pdo_list_t *pl2)
Compares two PDO lists.
const ec_pdo_t * ec_pdo_list_find_pdo_by_pos_const(const ec_pdo_list_t *pl, unsigned int pos)
Finds a PDO via its position in the list.
struct list_head list
List item.
ec_pdo_t * ec_pdo_list_find_pdo(const ec_pdo_list_t *pl, uint16_t index)
Finds a PDO with the given index.
EtherCAT Process data object structure.