master/pdo_entry.c
changeset 1313 ed15eef57d5c
parent 1186 ff481f097c97
child 1326 ef907b0b5125
equal deleted inserted replaced
1312:74853e018898 1313:ed15eef57d5c
    54 }
    54 }
    55 
    55 
    56 /*****************************************************************************/
    56 /*****************************************************************************/
    57 
    57 
    58 /** Pdo entry copy constructor.
    58 /** Pdo entry copy constructor.
       
    59  *
       
    60  * \retval  0 Success.
       
    61  * \retval <0 Error code.
    59  */
    62  */
    60 int ec_pdo_entry_init_copy(
    63 int ec_pdo_entry_init_copy(
    61         ec_pdo_entry_t *entry, /**< Pdo entry. */
    64         ec_pdo_entry_t *entry, /**< Pdo entry. */
    62         const ec_pdo_entry_t *other /**< Pdo entry to copy from. */
    65         const ec_pdo_entry_t *other /**< Pdo entry to copy from. */
    63         )
    66         )
    65     entry->index = other->index;
    68     entry->index = other->index;
    66     entry->subindex = other->subindex;
    69     entry->subindex = other->subindex;
    67     entry->name = NULL;
    70     entry->name = NULL;
    68     entry->bit_length = other->bit_length;
    71     entry->bit_length = other->bit_length;
    69 
    72 
    70     if (ec_pdo_entry_set_name(entry, other->name))
    73     return ec_pdo_entry_set_name(entry, other->name);
    71         return -1;
       
    72 
       
    73     return 0;
       
    74 }
    74 }
    75 
    75 
    76 /*****************************************************************************/
    76 /*****************************************************************************/
    77 
    77 
    78 /** Pdo entry destructor.
    78 /** Pdo entry destructor.
    84 }
    84 }
    85 
    85 
    86 /*****************************************************************************/
    86 /*****************************************************************************/
    87 
    87 
    88 /** Set Pdo entry name.
    88 /** Set Pdo entry name.
       
    89  *
       
    90  * \retval  0 Success.
       
    91  * \retval <0 Error code.
    89  */
    92  */
    90 int ec_pdo_entry_set_name(
    93 int ec_pdo_entry_set_name(
    91         ec_pdo_entry_t *entry, /**< Pdo entry. */
    94         ec_pdo_entry_t *entry, /**< Pdo entry. */
    92         const char *name /**< New name. */
    95         const char *name /**< New name. */
    93         )
    96         )
   101         kfree(entry->name);
   104         kfree(entry->name);
   102 
   105 
   103     if (name && (len = strlen(name))) {
   106     if (name && (len = strlen(name))) {
   104         if (!(entry->name = (char *) kmalloc(len + 1, GFP_KERNEL))) {
   107         if (!(entry->name = (char *) kmalloc(len + 1, GFP_KERNEL))) {
   105             EC_ERR("Failed to allocate Pdo entry name.\n");
   108             EC_ERR("Failed to allocate Pdo entry name.\n");
   106             return -1;
   109             return -ENOMEM;
   107         }
   110         }
   108         memcpy(entry->name, name, len + 1);
   111         memcpy(entry->name, name, len + 1);
   109     } else {
   112     } else {
   110         entry->name = NULL;
   113         entry->name = NULL;
   111     }
   114     }