From 48af9fbf1225352108c6d61e2c1da017eb2b4405 Mon Sep 17 00:00:00 2001 From: Krzysztof Opasiak Date: Fri, 14 Feb 2014 13:17:58 +0100 Subject: libusbg: Add getter for gadget name and udc. Add usbg_get_gadget_name() and usbg_get_gadget_udc() to avoid direct gadget structure members access. Add also usbg_get_gadget_name_len() and usbg_get_gadget_udc_len() to allow getting udc and name length. Signed-off-by: Krzysztof Opasiak --- include/usbg/usbg.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'include/usbg') diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h index 1ffc75d..f471255 100644 --- a/include/usbg/usbg.h +++ b/include/usbg/usbg.h @@ -302,6 +302,22 @@ extern void usbg_set_gadget_attrs(struct gadget *g, extern struct gadget_attrs *usbg_get_gadget_attrs(struct gadget *g, struct gadget_attrs *g_attrs); +/** + * @brief Get gadget name length + * @param g Gadget which name length should be returned + * @return Length of name string or -1 if error occurred. + */ +extern size_t usbg_get_gadget_name_len(struct gadget *g); + +/** + * @brieg Get gadget name + * @param b Pointer to gadget + * @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_gadget_name(struct gadget *g, char *buf, size_t len); + /** * @brief Set the USB gadget vendor id * @param g Pointer to gadget @@ -479,6 +495,24 @@ extern void usbg_enable_gadget(struct gadget *g, char *udc); */ extern void usbg_disable_gadget(struct gadget *g); +/** + * @brief Get gadget name length + * @param g Gadget which name length should be returned + * @return Length of name string or -1 if error occurred. + * @note If gadget isn't enabled on any udc returned size is 0. + */ +extern size_t usbg_get_gadget_udc_len(struct gadget *g); + +/** + * @brieg Get name of udc to which gadget is binded + * @param b Pointer to gadget + * @param buf Buffer where udc name should be copied + * @param len Length of given buffer + * @return Pointer to destination or NULL if error occurred. + * @note If gadget isn't enabled on any udc returned string is empty. + */ +extern char *usbg_get_gadget_udc(struct gadget *g, char *buf, size_t len); + /* * USB function-specific attribute configuration */ -- cgit v1.2.3