Add getter's to avoid direct access to gadget structure
members.

Signed-off-by: Krzysztof Opasiak <k.opas...@samsung.com>
---
 include/usbg/usbg.h |   18 ++++++++++++++++++
 src/usbg.c          |   24 ++++++++++++++++++++++++
 2 files changed, 42 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 8899a1e..51aa019 100644
--- a/src/usbg.c
+++ b/src/usbg.c
@@ -628,6 +628,18 @@ 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) {
@@ -693,6 +705,18 @@ 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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to