master/slave_config.c
changeset 814 a51f857b1b2d
parent 807 f8bca95ab75d
child 834 0791aac03180
equal deleted inserted replaced
813:bfc3f1ab52de 814:a51f857b1b2d
   165 
   165 
   166     // Free Pdo mappings
   166     // Free Pdo mappings
   167     for (dir = EC_DIR_OUTPUT; dir <= EC_DIR_INPUT; dir++)
   167     for (dir = EC_DIR_OUTPUT; dir <= EC_DIR_INPUT; dir++)
   168         ec_pdo_mapping_clear(&sc->mapping[dir]);
   168         ec_pdo_mapping_clear(&sc->mapping[dir]);
   169 
   169 
   170     // free all SDO configurations
   170     // free all Sdo configurations
   171     list_for_each_entry_safe(sdodata, next_sdodata, &sc->sdo_configs, list) {
   171     list_for_each_entry_safe(sdodata, next_sdodata, &sc->sdo_configs, list) {
   172         list_del(&sdodata->list);
   172         list_del(&sdodata->list);
   173         kfree(sdodata->data);
   173         kfree(sdodata->data);
   174         kfree(sdodata);
   174         kfree(sdodata);
   175     }
   175     }
   193  * \retval -1  FMMU limit reached.
   193  * \retval -1  FMMU limit reached.
   194  */
   194  */
   195 int ec_slave_config_prepare_fmmu(
   195 int ec_slave_config_prepare_fmmu(
   196         ec_slave_config_t *sc, /**< Slave configuration. */
   196         ec_slave_config_t *sc, /**< Slave configuration. */
   197         ec_domain_t *domain, /**< Domain. */
   197         ec_domain_t *domain, /**< Domain. */
   198         ec_direction_t dir /**< PDO direction. */
   198         ec_direction_t dir /**< Pdo direction. */
   199         )
   199         )
   200 {
   200 {
   201     unsigned int i;
   201     unsigned int i;
   202     ec_fmmu_config_t *fmmu;
   202     ec_fmmu_config_t *fmmu;
   203 
   203 
   261         }
   261         }
   262     }
   262     }
   263     
   263     
   264     // type-cast to avoid warnings on some compilers
   264     // type-cast to avoid warnings on some compilers
   265     if (!list_empty((struct list_head *) &sc->sdo_configs)) {
   265     if (!list_empty((struct list_head *) &sc->sdo_configs)) {
   266         buf += sprintf(buf, "\nSDO configurations:\n");
   266         buf += sprintf(buf, "\nSdo configurations:\n");
   267 
   267 
   268         list_for_each_entry(sdodata, &sc->sdo_configs, list) {
   268         list_for_each_entry(sdodata, &sc->sdo_configs, list) {
   269             switch (sdodata->size) {
   269             switch (sdodata->size) {
   270                 case 1: sprintf(str, "%u", EC_READ_U8(sdodata->data)); break;
   270                 case 1: sprintf(str, "%u", EC_READ_U8(sdodata->data)); break;
   271                 case 2: sprintf(str, "%u", EC_READ_U16(sdodata->data)); break;
   271                 case 2: sprintf(str, "%u", EC_READ_U16(sdodata->data)); break;
   302     return 0;
   302     return 0;
   303 }
   303 }
   304 
   304 
   305 /*****************************************************************************/
   305 /*****************************************************************************/
   306 
   306 
   307 /** Adds an SDO configuration.
   307 /** Adds an Sdo configuration.
   308  */
   308  */
   309 int ec_slave_config_sdo(ec_slave_config_t *sc, uint16_t index,
   309 int ec_slave_config_sdo(ec_slave_config_t *sc, uint16_t index,
   310         uint8_t subindex, const uint8_t *data, size_t size)
   310         uint8_t subindex, const uint8_t *data, size_t size)
   311 {
   311 {
   312     ec_slave_t *slave = sc->slave;
   312     ec_slave_t *slave = sc->slave;
   317         return -1;
   317         return -1;
   318     }
   318     }
   319 
   319 
   320     if (!(sdodata = (ec_sdo_data_t *)
   320     if (!(sdodata = (ec_sdo_data_t *)
   321           kmalloc(sizeof(ec_sdo_data_t), GFP_KERNEL))) {
   321           kmalloc(sizeof(ec_sdo_data_t), GFP_KERNEL))) {
   322         EC_ERR("Failed to allocate memory for SDO configuration object!\n");
   322         EC_ERR("Failed to allocate memory for Sdo configuration object!\n");
   323         return -1;
   323         return -1;
   324     }
   324     }
   325 
   325 
   326     if (!(sdodata->data = (uint8_t *) kmalloc(size, GFP_KERNEL))) {
   326     if (!(sdodata->data = (uint8_t *) kmalloc(size, GFP_KERNEL))) {
   327         EC_ERR("Failed to allocate memory for SDO configuration data!\n");
   327         EC_ERR("Failed to allocate memory for Sdo configuration data!\n");
   328         kfree(sdodata);
   328         kfree(sdodata);
   329         return -1;
   329         return -1;
   330     }
   330     }
   331 
   331 
   332     sdodata->index = index;
   332     sdodata->index = index;
   479                 }
   479                 }
   480             }
   480             }
   481         }
   481         }
   482     }
   482     }
   483 
   483 
   484     EC_ERR("PDO entry 0x%04X:%u is not mapped in slave config %u:%u.\n",
   484     EC_ERR("Pdo entry 0x%04X:%u is not mapped in slave config %u:%u.\n",
   485            index, subindex, sc->alias, sc->position);
   485            index, subindex, sc->alias, sc->position);
   486     return -1;
   486     return -1;
   487 
   487 
   488 found:
   488 found:
   489     byte_offset = bit_offset / 8;
   489     byte_offset = bit_offset / 8;