Add usbg_get_binding_target() to avoid direct binding structure members access. Add also usbg_get_binding_name_len() and usbg_get_binding_name() to allow getting binding name. Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx> --- include/usbg/usbg.h | 23 +++++++++++++++++++++++ src/usbg.c | 15 +++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h index 5b8f482..603a4a3 100644 --- a/include/usbg/usbg.h +++ b/include/usbg/usbg.h @@ -562,6 +562,29 @@ extern void usbg_set_config_string(struct config *c, int lang, char *string); */ extern int usbg_add_config_function(struct config *c, char *name, struct function *f); +/** + * @brief Get target function of given binding + * @param b Binding between configuration and function + * @return Pointer to USB function which is target for this binding + */ +extern struct function *usbg_get_binding_target(struct binding *b); + +/** + * @brief Get binding name length + * @param b Binding which name length should be returned + * @return Length of name string or -1 if error occurred. + */ +extern size_t usbg_get_binding_name_len(struct binding *b); + +/** + * @brief Get binding name + * @param b Pointer to binding + * @param buf Buffer where name should be copied + * @param len Length of given buffer + * @return Pointer to destination or NULL if error occurred. + */ +extern char *usbg_get_binding_name(struct binding *b, char *buf, size_t len); + /* USB gadget setup and teardown */ /** diff --git a/src/usbg.c b/src/usbg.c index 9a461dd..b160822 100644 --- a/src/usbg.c +++ b/src/usbg.c @@ -1068,6 +1068,21 @@ int usbg_add_config_function(struct config *c, char *name, struct function *f) return 0; } +struct function *usbg_get_binding_target(struct binding *b) +{ + return b ? b->target : NULL; +} + +size_t usbg_get_binding_name_len(struct binding *b) +{ + return b ? strlen(b->name) : -1; +} + +char *usbg_get_binding_name(struct binding *b, char *buf, size_t len) +{ + return b ? strncpy(buf, b->name, len) : NULL; +} + int usbg_get_udcs(struct dirent ***udc_list) { return scandir("/sys/class/udc", udc_list, file_select, alphasort); -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html