Add getter's to avoid direct access to gadget structure members. Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx> --- include/usbg/usbg.h | 18 ++++++++++++++++++ src/usbg.c | 22 ++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h index c3e9d29..1ffc75d 100644 --- a/include/usbg/usbg.h +++ b/include/usbg/usbg.h @@ -294,6 +294,15 @@ extern void usbg_set_gadget_attrs(struct gadget *g, struct gadget_attrs *g_attrs); /** + * @brief Get the USB gadget strings + * @param g Pointer to gadget + * @param g_attrs Structure to be filled + * @retur Pointer to filled structure or NULL if error occurred. + */ +extern struct gadget_attrs *usbg_get_gadget_attrs(struct gadget *g, + struct gadget_attrs *g_attrs); + +/** * @brief Set the USB gadget vendor id * @param g Pointer to gadget * @param idVendor USB device vendor id @@ -355,6 +364,15 @@ extern void usbg_set_gadget_device_bcd_device(struct gadget *g, extern void usbg_set_gadget_device_bcd_usb(struct gadget *g, uint16_t bcdUSB); /** + * @brief Get the USB gadget strings + * @param g Pointer to gadget + * @param g_sttrs Structure to be filled + * @retur Pointer to filled structure or NULL if error occurred. + */ +extern struct gadget_strs *usbg_get_gadget_strs(struct gadget *g, + struct gadget_strs *g_strs); + +/** * @brief Set the USB gadget strings * @param g Pointer to gadget * @param lang USB language ID diff --git a/src/usbg.c b/src/usbg.c index a263cb9..4465a87 100644 --- a/src/usbg.c +++ b/src/usbg.c @@ -624,6 +624,17 @@ struct gadget *usbg_create_gadget(struct state *s, char *name, return g; } +struct gadget_attrs *usbg_get_gadget_attrs(struct gadget *g, + struct gadget_attrs *g_attrs) +{ + if (g && g_attrs) + *g_attrs = g->attrs; + else + g_attrs = NULL; + + return g_attrs; +} + void usbg_set_gadget_attrs(struct gadget *g, struct gadget_attrs *g_attrs) { if (!g || !g_attrs) @@ -688,6 +699,17 @@ void usbg_set_gadget_device_bcd_usb(struct gadget *g, uint16_t bcdUSB) usbg_write_hex16(g->path, g->name, "bcdUSB", bcdUSB); } +struct gadget_strs *usbg_get_gadget_strs(struct gadget *g, + struct gadget_strs *g_strs) +{ + if (g && g_strs) + *g_strs = g->strs; + else + g_strs = NULL; + + return g_strs; +} + void usbg_set_gadget_strs(struct gadget *g, int lang, struct gadget_strs *g_strs) { -- 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