From bd4d1a32b512e42d0585342dd481aff65d8bd6c6 Mon Sep 17 00:00:00 2001 From: Florian Pose Date: Fri, 6 Jun 2008 09:22:19 +0000 Subject: [PATCH] Added ec_sdo_get_entry_const(). --- master/sdo.c | 30 ++++++++++++++++++++++++++++-- master/sdo.h | 1 + 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/master/sdo.c b/master/sdo.c index 65269959..f709d3ce 100644 --- a/master/sdo.c +++ b/master/sdo.c @@ -154,7 +154,7 @@ void ec_sdo_clear( /*****************************************************************************/ -/** Get and Sdo entry from an Sdo via its subindex. +/** Get an Sdo entry from an Sdo via its subindex. * * \retval >0 Pointer to the requested Sdo entry. * \retval NULL Sdo entry not found. @@ -167,7 +167,33 @@ ec_sdo_entry_t *ec_sdo_get_entry( ec_sdo_entry_t *entry; list_for_each_entry(entry, &sdo->entries, list) { - if (entry->subindex != subindex) continue; + if (entry->subindex != subindex) + continue; + return entry; + } + + return NULL; +} + +/*****************************************************************************/ + +/** Get an Sdo entry from an Sdo via its subindex. + * + * const version. + * + * \retval >0 Pointer to the requested Sdo entry. + * \retval NULL Sdo entry not found. + */ +const ec_sdo_entry_t *ec_sdo_get_entry_const( + const ec_sdo_t *sdo, /**< Sdo. */ + uint8_t subindex /**< Entry subindex. */ + ) +{ + const ec_sdo_entry_t *entry; + + list_for_each_entry(entry, &sdo->entries, list) { + if (entry->subindex != subindex) + continue; return entry; } diff --git a/master/sdo.h b/master/sdo.h index d7e8ef35..fdb84502 100644 --- a/master/sdo.h +++ b/master/sdo.h @@ -68,6 +68,7 @@ int ec_sdo_init(ec_sdo_t *, uint16_t, ec_slave_t *); void ec_sdo_destroy(ec_sdo_t *); ec_sdo_entry_t *ec_sdo_get_entry(ec_sdo_t *, uint8_t); +const ec_sdo_entry_t *ec_sdo_get_entry_const(const ec_sdo_t *, uint8_t); /*****************************************************************************/