master/pdo.c
changeset 799 068a58b96965
parent 792 3778920f61e4
child 814 a51f857b1b2d
equal deleted inserted replaced
798:5a58606726f3 799:068a58b96965
   168     return 0;
   168     return 0;
   169 }
   169 }
   170 
   170 
   171 /*****************************************************************************/
   171 /*****************************************************************************/
   172 
   172 
       
   173 /** Compares the entries of two Pdos.
       
   174  *
       
   175  * \retval 1 The entries of the given Pdos are equal.
       
   176  * \retval 0 The entries of the given Pdos differ.
       
   177  */
       
   178 int ec_pdo_equal_entries(
       
   179         const ec_pdo_t *pdo1, /**< First Pdo. */
       
   180         const ec_pdo_t *pdo2 /**< Second Pdo. */
       
   181         )
       
   182 {
       
   183     const struct list_head *head1, *head2, *item1, *item2;
       
   184     const ec_pdo_entry_t *entry1, *entry2;
       
   185 
       
   186     head1 = item1 = &pdo1->entries;
       
   187     head2 = item2 = &pdo2->entries;
       
   188 
       
   189     while (1) {
       
   190         item1 = item1->next;
       
   191         item2 = item2->next;
       
   192 
       
   193         if ((item1 == head1) ^ (item2 == head2)) // unequal lengths
       
   194             return 0;
       
   195         if (item1 == head1 && item2 == head2) // both finished
       
   196             break;
       
   197 
       
   198         entry1 = list_entry(item1, ec_pdo_entry_t, list);
       
   199         entry2 = list_entry(item2, ec_pdo_entry_t, list);
       
   200         if (!ec_pdo_entry_equal(entry1, entry2))
       
   201             return 0;
       
   202     }
       
   203 
       
   204     return 1;
       
   205 }
       
   206 
       
   207 /*****************************************************************************/
       
   208 
   173 /** Pdo entry constructor.
   209 /** Pdo entry constructor.
   174  */
   210  */
   175 void ec_pdo_entry_init(
   211 void ec_pdo_entry_init(
   176         ec_pdo_entry_t *entry /**< Pdo entry. */
   212         ec_pdo_entry_t *entry /**< Pdo entry. */
   177         )
   213         )
   235 
   271 
   236     return 0;
   272     return 0;
   237 }
   273 }
   238 
   274 
   239 /*****************************************************************************/
   275 /*****************************************************************************/
       
   276 
       
   277 /** Compares two Pdo entries.
       
   278  *
       
   279  * \retval 1 The entries are equal.
       
   280  * \retval 0 The entries differ.
       
   281  */
       
   282 int ec_pdo_entry_equal(
       
   283         const ec_pdo_entry_t *entry1, /**< First Pdo entry. */
       
   284         const ec_pdo_entry_t *entry2 /**< Second Pdo entry. */
       
   285         )
       
   286 {
       
   287     return entry1->index == entry2->index
       
   288         && entry1->subindex == entry2->subindex
       
   289         && entry1->bit_length == entry2->bit_length;
       
   290 }
       
   291 
       
   292 /*****************************************************************************/