summaryrefslogtreecommitdiff
path: root/include/usbg
diff options
context:
space:
mode:
authorKrzysztof Opasiak <k.opasiak@samsung.com>2014-02-27 18:21:33 +0100
committerKrzysztof Opasiak <k.opasiak@samsung.com>2014-03-11 09:25:12 +0100
commit427d5ab2a777937ab4775eed525ed273f185c2ad (patch)
treeee9eb1b272699f412f2f04d0af31f444ece4391c /include/usbg
parent06424b374571adaa57b4b660fe25ce1d62a1a067 (diff)
downloadlibusbg-427d5ab2a777937ab4775eed525ed273f185c2ad.tar.gz
libusbg-427d5ab2a777937ab4775eed525ed273f185c2ad.tar.bz2
libusbg-427d5ab2a777937ab4775eed525ed273f185c2ad.zip
libusbg: Add return value to gadget creation functions.
Functions related to gadget creation should return error codes instead of pointer. Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Diffstat (limited to 'include/usbg')
-rw-r--r--include/usbg/usbg.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h
index 0d76010..f6f7a2e 100644
--- a/include/usbg/usbg.h
+++ b/include/usbg/usbg.h
@@ -186,6 +186,7 @@ typedef enum {
USBG_ERROR_INVALID_PARAM = -3,
USBG_ERROR_NOT_FOUND = -4,
USBG_ERROR_IO = -5,
+ USBG_ERROR_EXIST = -6,
USBG_ERROR_OTHER_ERROR = -99
} usbg_error;
@@ -255,10 +256,11 @@ extern usbg_config *usbg_get_config(usbg_gadget *g, const char *name);
* @param name Name of the gadget
* @param idVendor Gadget vendor ID
* @param idProduct Gadget product ID
- * @return Pointer to gadget or NULL if the gadget cannot be created
+ * @param g Pointer to be filled with pointer to gadget
+ * @return 0 on success usbg_error if error occurred
*/
-extern usbg_gadget *usbg_create_gadget_vid_pid(usbg_state *s, char *name,
- uint16_t idVendor, uint16_t idProduct);
+extern int usbg_create_gadget_vid_pid(usbg_state *s, char *name,
+ uint16_t idVendor, uint16_t idProduct, usbg_gadget **g);
/**
* @brief Create a new USB gadget device and set given attributes
@@ -267,18 +269,20 @@ extern usbg_gadget *usbg_create_gadget_vid_pid(usbg_state *s, char *name,
* @param name Name of the gadget
* @param g_attrs Gadget attributes to be set. If NULL setting is omitted.
* @param g_strs Gadget strings to be set. If NULL setting is omitted.
+ * @param g Pointer to be filled with pointer to gadget
* @note Given strings are assumed to be in US English
- * @return Pointer to gadget or NULL if the gadget cannot be created
+ * @return 0 on success usbg_error if error occurred
*/
-extern usbg_gadget *usbg_create_gadget(usbg_state *s, char *name,
- usbg_gadget_attrs *g_attrs, usbg_gadget_strs *g_strs);
+extern int usbg_create_gadget(usbg_state *s, char *name,
+ usbg_gadget_attrs *g_attrs, usbg_gadget_strs *g_strs, usbg_gadget **g);
/**
* @brief Set the USB gadget attributes
* @param g Pointer to gadget
* @param g_attrs Gadget attributes
+ * @return 0 on success usbg_error if error occurred
*/
-extern void usbg_set_gadget_attrs(usbg_gadget *g,
+extern int usbg_set_gadget_attrs(usbg_gadget *g,
usbg_gadget_attrs *g_attrs);
/**
@@ -383,8 +387,9 @@ extern usbg_gadget_strs *usbg_get_gadget_strs(usbg_gadget *g, int lang,
* @param g Pointer to gadget
* @param lang USB language ID
* @param g_sttrs Gadget attributes
+ * @return 0 on success usbg_error if error occurred
*/
-extern void usbg_set_gadget_strs(usbg_gadget *g, int lang,
+extern int usbg_set_gadget_strs(usbg_gadget *g, int lang,
usbg_gadget_strs *g_strs);
/**