# HG changeset patch # User Florian Pose # Date 1223545739 0 # Node ID 0b411da5fd244fe5d732b72b7c208667058bed8d # Parent 3c3f8cb7674860d4ca8e7c76826cd5d06ba1242c Added ec_master_get_config(). diff -r 3c3f8cb76748 -r 0b411da5fd24 master/master.c --- a/master/master.c Thu Oct 09 09:31:23 2008 +0000 +++ b/master/master.c Thu Oct 09 09:48:59 2008 +0000 @@ -1121,6 +1121,32 @@ /*****************************************************************************/ +/** Common implementation for ec_master_get_config() + * and ec_master_get_config_const(). + */ +#define EC_FIND_CONFIG \ + do { \ + list_for_each_entry(sc, &master->configs, list) { \ + if (pos--) \ + continue; \ + return sc; \ + } \ + return NULL; \ + } while (0) + +/** Get a slave configuration via its position in the list. + * + * \return Slave configuration or \a NULL. + */ +ec_slave_config_t *ec_master_get_config( + const ec_master_t *master, /**< EtherCAT master. */ + unsigned int pos /**< List position. */ + ) +{ + ec_slave_config_t *sc; + EC_FIND_CONFIG; +} + /** Get a slave configuration via its position in the list. * * Const version. @@ -1133,14 +1159,7 @@ ) { const ec_slave_config_t *sc; - - list_for_each_entry(sc, &master->configs, list) { - if (pos--) - continue; - return sc; - } - - return NULL; + EC_FIND_CONFIG; } /*****************************************************************************/ diff -r 3c3f8cb76748 -r 0b411da5fd24 master/master.h --- a/master/master.h Thu Oct 09 09:31:23 2008 +0000 +++ b/master/master.h Thu Oct 09 09:48:59 2008 +0000 @@ -204,6 +204,8 @@ void ec_master_clear_slaves(ec_master_t *); unsigned int ec_master_config_count(const ec_master_t *); +ec_slave_config_t *ec_master_get_config( + const ec_master_t *, unsigned int); const ec_slave_config_t *ec_master_get_config_const( const ec_master_t *, unsigned int); unsigned int ec_master_domain_count(const ec_master_t *);