359 ) |
359 ) |
360 { |
360 { |
361 const ec_sdo_request_t *req; |
361 const ec_sdo_request_t *req; |
362 |
362 |
363 list_for_each_entry(req, &sc->sdo_configs, list) { |
363 list_for_each_entry(req, &sc->sdo_configs, list) { |
|
364 if (pos--) |
|
365 continue; |
|
366 return req; |
|
367 } |
|
368 |
|
369 return NULL; |
|
370 } |
|
371 |
|
372 /*****************************************************************************/ |
|
373 |
|
374 /** Get the number of IDN configurations. |
|
375 * |
|
376 * \return Number of SDO configurations. |
|
377 */ |
|
378 unsigned int ec_slave_config_idn_count( |
|
379 const ec_slave_config_t *sc /**< Slave configuration. */ |
|
380 ) |
|
381 { |
|
382 const ec_soe_request_t *req; |
|
383 unsigned int count = 0; |
|
384 |
|
385 list_for_each_entry(req, &sc->soe_configs, list) { |
|
386 count++; |
|
387 } |
|
388 |
|
389 return count; |
|
390 } |
|
391 |
|
392 /*****************************************************************************/ |
|
393 |
|
394 /** Finds an IDN configuration via its position in the list. |
|
395 * |
|
396 * Const version. |
|
397 */ |
|
398 const ec_soe_request_t *ec_slave_config_get_idn_by_pos_const( |
|
399 const ec_slave_config_t *sc, /**< Slave configuration. */ |
|
400 unsigned int pos /**< Position in the list. */ |
|
401 ) |
|
402 { |
|
403 const ec_soe_request_t *req; |
|
404 |
|
405 list_for_each_entry(req, &sc->soe_configs, list) { |
364 if (pos--) |
406 if (pos--) |
365 continue; |
407 continue; |
366 return req; |
408 return req; |
367 } |
409 } |
368 |
410 |
949 EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, drive_no = %u, idn = 0x%04X, " |
991 EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, drive_no = %u, idn = 0x%04X, " |
950 "state = %u, data = 0x%p, size = %zu)\n", |
992 "state = %u, data = 0x%p, size = %zu)\n", |
951 __func__, sc, drive_no, idn, state, data, size); |
993 __func__, sc, drive_no, idn, state, data, size); |
952 |
994 |
953 if (drive_no > 7) { |
995 if (drive_no > 7) { |
954 EC_CONFIG_ERR(sc, "Invalid drive number!\n"); |
996 EC_CONFIG_ERR(sc, "Invalid drive number %u!\n", |
|
997 (unsigned int) drive_no); |
955 return -EINVAL; |
998 return -EINVAL; |
956 } |
999 } |
957 |
1000 |
958 if (state != EC_AL_STATE_PREOP && state != EC_AL_STATE_SAFEOP) { |
1001 if (state != EC_AL_STATE_PREOP && state != EC_AL_STATE_SAFEOP) { |
959 EC_CONFIG_ERR(sc, "AL state for IDN config" |
1002 EC_CONFIG_ERR(sc, "AL state for IDN config" |