From 370884e45b4677b8913e39c1edf6bd35f227e03d Mon Sep 17 00:00:00 2001 From: Marc Schink Date: Sat, 24 Oct 2015 17:56:59 +0200 Subject: [PATCH] Change API of jaylink_get_selected_interface() --- libjaylink/libjaylink.h | 3 ++- libjaylink/target.c | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/libjaylink/libjaylink.h b/libjaylink/libjaylink.h index 9bf8c6c..4d0bb18 100644 --- a/libjaylink/libjaylink.h +++ b/libjaylink/libjaylink.h @@ -423,7 +423,8 @@ JAYLINK_API int jaylink_select_interface(struct jaylink_device_handle *devh, JAYLINK_API int jaylink_get_available_interfaces( struct jaylink_device_handle *devh, uint32_t *interfaces); JAYLINK_API int jaylink_get_selected_interface( - struct jaylink_device_handle *devh); + struct jaylink_device_handle *devh, + enum jaylink_target_interface *interface); JAYLINK_API int jaylink_clear_reset(struct jaylink_device_handle *devh); JAYLINK_API int jaylink_set_reset(struct jaylink_device_handle *devh); JAYLINK_API int jaylink_set_target_power(struct jaylink_device_handle *devh, diff --git a/libjaylink/target.c b/libjaylink/target.c index 100b24c..ea5ef65 100644 --- a/libjaylink/target.c +++ b/libjaylink/target.c @@ -300,21 +300,26 @@ JAYLINK_API int jaylink_get_available_interfaces( * #JAYLINK_DEV_CAP_SELECT_TIF capability. * * @param[in,out] devh Device handle. + * @param[out] interface Selected target interface on success, and undefined on + * failure. * - * @return The currently selected target interface on success, or a negative - * error code on failure. + * @retval JAYLINK_OK Success. + * @retval JAYLINK_ERR_ARG Invalid arguments. + * @retval JAYLINK_ERR_TIMEOUT A timeout occurred. + * @retval JAYLINK_ERR Other error conditions. * * @see jaylink_get_caps() to retrieve device capabilities. */ JAYLINK_API int jaylink_get_selected_interface( - struct jaylink_device_handle *devh) + struct jaylink_device_handle *devh, + enum jaylink_target_interface *interface) { int ret; struct jaylink_context *ctx; uint8_t buf[4]; uint32_t tmp; - if (!devh) + if (!devh || !interface) return JAYLINK_ERR_ARG; ctx = devh->dev->ctx; @@ -349,7 +354,9 @@ JAYLINK_API int jaylink_get_selected_interface( return JAYLINK_ERR; } - return tmp; + *interface = tmp; + + return JAYLINK_OK; } /** -- 2.11.4.GIT