29 #include <linux/module.h> 46 INIT_LIST_HEAD(&pl->
list);
66 list_for_each_entry_safe(pdo, next, &pl->
list, list) {
67 list_del_init(&pdo->
list);
83 unsigned int bit_size;
89 list_for_each_entry(pdo, &pl->
list, list) {
90 list_for_each_entry(pdo_entry, &pdo->
entries, list) {
96 byte_size = bit_size / 8 + 1;
98 byte_size = bit_size / 8;
117 EC_ERR(
"Failed to allocate memory for PDO.\n");
118 return ERR_PTR(-ENOMEM);
123 list_add_tail(&pdo->
list, &pl->
list);
142 list_for_each_entry(mapped_pdo, &pl->
list, list) {
143 if (mapped_pdo->
index != pdo->
index)
continue;
144 EC_ERR(
"PDO 0x%04X is already mapped!\n", pdo->
index);
148 if (!(mapped_pdo = kmalloc(
sizeof(
ec_pdo_t), GFP_KERNEL))) {
149 EC_ERR(
"Failed to allocate PDO memory.\n");
159 list_add_tail(&mapped_pdo->
list, &pl->
list);
180 list_for_each_entry(other_pdo, &other->
list, list) {
204 const struct list_head *h1, *h2, *l1, *l2;
207 h1 = l1 = &pl1->
list;
208 h2 = l2 = &pl2->
list;
214 if ((l1 == h1) ^ (l2 == h2))
219 p1 = list_entry(l1,
ec_pdo_t, list);
220 p2 = list_entry(l2,
ec_pdo_t, list);
242 list_for_each_entry(pdo, &pl->
list, list) {
243 if (pdo->
index != index)
264 list_for_each_entry(pdo, &pl->
list, list) {
265 if (pdo->
index != index)
288 list_for_each_entry(pdo, &pl->
list, list) {
308 unsigned int num = 0;
310 list_for_each_entry(pdo, &pl->
list, list) {
327 if (list_empty(&pl->
list)) {
328 printk(KERN_CONT
"(none)");
330 list_for_each_entry(pdo, &pl->
list, list) {
331 printk(KERN_CONT
"0x%04X", pdo->
index);
333 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.