From 7765e989c47347c8cca9d0a7e23287268cf6e956 Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Thu, 9 Oct 2008 09:48:59 +0000 Subject: [PATCH] Added ec_master_get_config(). --- master/master.c | 35 +++++++++++++++++++++++++++-------- master/master.h | 2 ++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/master/master.c b/master/master.c index 39e72e4a..b1bb1d4b 100644 --- a/master/master.c +++ b/master/master.c @@ -1121,6 +1121,32 @@ unsigned int ec_master_config_count( /*****************************************************************************/ +/** 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 *ec_master_get_config_const( ) { 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 --git a/master/master.h b/master/master.h index 198ed095..8589f078 100644 --- a/master/master.h +++ b/master/master.h @@ -204,6 +204,8 @@ void ec_master_clear_eoe_handlers(ec_master_t *); 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 *);