summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKrzysztof Opasiak <k.opasiak@samsung.com>2014-02-19 15:54:06 +0100
committerKrzysztof Opasiak <k.opasiak@samsung.com>2014-02-19 21:17:20 +0100
commitfae25c9f07c179efba01b001c05d9f48f8a764d3 (patch)
treedceb1b293824c2242dbe777e9e45a7defc7088e9 /include
parent7e9a9fc74ce655b494d76ce2f4f1012eb3dadfa8 (diff)
downloadlibusbg-fae25c9f07c179efba01b001c05d9f48f8a764d3.tar.gz
libusbg-fae25c9f07c179efba01b001c05d9f48f8a764d3.tar.bz2
libusbg-fae25c9f07c179efba01b001c05d9f48f8a764d3.zip
libusbg: Hide definition of gadget structure.
Remove definition of gadget structure to avoid direct access to its fields. Rename that structure to usbg_gadget. Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Diffstat (limited to 'include')
-rw-r--r--include/usbg/usbg.h93
1 files changed, 40 insertions, 53 deletions
diff --git a/include/usbg/usbg.h b/include/usbg/usbg.h
index 5cad066..ad67876 100644
--- a/include/usbg/usbg.h
+++ b/include/usbg/usbg.h
@@ -45,6 +45,7 @@
* Internal structures
*/
struct usbg_state;
+struct usbg_gadget;
/**
* @brief State of the gadget devices in the system
@@ -52,6 +53,11 @@ struct usbg_state;
typedef struct usbg_state usbg_state;
/**
+ * @brief USB gadget device
+ */
+typedef struct usbg_gadget usbg_gadget;
+
+/**
* @struct gadget_attrs
* @brief USB gadget device attributes
*/
@@ -79,25 +85,6 @@ struct gadget_strs
};
/**
- * @struct gadget
- * @brief USB gadget device
- */
-struct gadget
-{
- char name[USBG_MAX_NAME_LENGTH];
- char path[USBG_MAX_PATH_LENGTH];
- char udc[USBG_MAX_STR_LENGTH];
-
- struct gadget_attrs attrs;
- struct gadget_strs strs;
-
- TAILQ_ENTRY(gadget) gnode;
- TAILQ_HEAD(chead, config) configs;
- TAILQ_HEAD(fhead, function) functions;
- usbg_state *parent;
-};
-
-/**
* @struct config_attrs
* @brief USB configuration attributes
*/
@@ -124,7 +111,7 @@ struct config
{
TAILQ_ENTRY(config) cnode;
TAILQ_HEAD(bhead, binding) bindings;
- struct gadget *parent;
+ usbg_gadget *parent;
char name[USBG_MAX_NAME_LENGTH];
char path[USBG_MAX_PATH_LENGTH];
@@ -193,7 +180,7 @@ union attrs {
struct function
{
TAILQ_ENTRY(function) fnode;
- struct gadget *parent;
+ usbg_gadget *parent;
char name[USBG_MAX_NAME_LENGTH];
char path[USBG_MAX_PATH_LENGTH];
@@ -257,7 +244,7 @@ extern char *usbg_get_configfs_path(usbg_state *s, char *buf, size_t len);
* @param name Name of the gadget device
* @return Pointer to gadget or NULL if a matching gadget isn't found
*/
-extern struct gadget *usbg_get_gadget(usbg_state *s, const char *name);
+extern usbg_gadget *usbg_get_gadget(usbg_state *s, const char *name);
/**
* @brief Get a function by name
@@ -265,7 +252,7 @@ extern struct gadget *usbg_get_gadget(usbg_state *s, const char *name);
* @param name Name of the function
* @return Pointer to function or NULL if a matching function isn't found
*/
-extern struct function *usbg_get_function(struct gadget *g, const char *name);
+extern struct function *usbg_get_function(usbg_gadget *g, const char *name);
/**
* @brief Get a configuration by name
@@ -273,7 +260,7 @@ extern struct function *usbg_get_function(struct gadget *g, const char *name);
* @param name Name of the configuration
* @return Pointer to config or NULL if a matching config isn't found
*/
-extern struct config *usbg_get_config(struct gadget *g, const char *name);
+extern struct config *usbg_get_config(usbg_gadget *g, const char *name);
/* USB gadget allocation and configuration */
@@ -285,7 +272,7 @@ extern struct config *usbg_get_config(struct gadget *g, const char *name);
* @param idProduct Gadget product ID
* @return Pointer to gadget or NULL if the gadget cannot be created
*/
-extern struct gadget *usbg_create_gadget_vid_pid(usbg_state *s, char *name,
+extern usbg_gadget *usbg_create_gadget_vid_pid(usbg_state *s, char *name,
uint16_t idVendor, uint16_t idProduct);
/**
@@ -298,7 +285,7 @@ extern struct gadget *usbg_create_gadget_vid_pid(usbg_state *s, char *name,
* @note Given strings are assumed to be in US English
* @return Pointer to gadget or NULL if the gadget cannot be created
*/
-extern struct gadget *usbg_create_gadget(usbg_state *s, char *name,
+extern usbg_gadget *usbg_create_gadget(usbg_state *s, char *name,
struct gadget_attrs *g_attrs, struct gadget_strs *g_strs);
/**
@@ -306,7 +293,7 @@ extern struct gadget *usbg_create_gadget(usbg_state *s, char *name,
* @param g Pointer to gadget
* @param g_attrs Gadget attributes
*/
-extern void usbg_set_gadget_attrs(struct gadget *g,
+extern void usbg_set_gadget_attrs(usbg_gadget *g,
struct gadget_attrs *g_attrs);
/**
@@ -315,7 +302,7 @@ extern void usbg_set_gadget_attrs(struct gadget *g,
* @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,
+extern struct gadget_attrs *usbg_get_gadget_attrs(usbg_gadget *g,
struct gadget_attrs *g_attrs);
/**
@@ -323,7 +310,7 @@ extern struct gadget_attrs *usbg_get_gadget_attrs(struct gadget *g,
* @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);
+extern size_t usbg_get_gadget_name_len(usbg_gadget *g);
/**
* @brieg Get gadget name
@@ -332,28 +319,28 @@ extern size_t usbg_get_gadget_name_len(struct gadget *g);
* @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);
+extern char *usbg_get_gadget_name(usbg_gadget *g, char *buf, size_t len);
/**
* @brief Set the USB gadget vendor id
* @param g Pointer to gadget
* @param idVendor USB device vendor id
*/
-extern void usbg_set_gadget_vendor_id(struct gadget *g, uint16_t idVendor);
+extern void usbg_set_gadget_vendor_id(usbg_gadget *g, uint16_t idVendor);
/**
* @brief Set the USB gadget product id
* @param g Pointer to gadget
* @param idProduct USB device product id
*/
-extern void usbg_set_gadget_product_id(struct gadget *g, uint16_t idProduct);
+extern void usbg_set_gadget_product_id(usbg_gadget *g, uint16_t idProduct);
/**
* @brief Set the USB gadget device class code
* @param g Pointer to gadget
* @param bDeviceClass USB device class code
*/
-extern void usbg_set_gadget_device_class(struct gadget *g,
+extern void usbg_set_gadget_device_class(usbg_gadget *g,
uint8_t bDeviceClass);
/**
@@ -361,7 +348,7 @@ extern void usbg_set_gadget_device_class(struct gadget *g,
* @param g Pointer to gadget
* @param bDeviceProtocol USB protocol code
*/
-extern void usbg_set_gadget_device_protocol(struct gadget *g,
+extern void usbg_set_gadget_device_protocol(usbg_gadget *g,
uint8_t bDeviceProtocol);
/**
@@ -369,7 +356,7 @@ extern void usbg_set_gadget_device_protocol(struct gadget *g,
* @param g Pointer to gadget
* @param bDeviceSubClass USB device subclass code
*/
-extern void usbg_set_gadget_device_subclass(struct gadget *g,
+extern void usbg_set_gadget_device_subclass(usbg_gadget *g,
uint8_t bDeviceSubClass);
/**
@@ -377,7 +364,7 @@ extern void usbg_set_gadget_device_subclass(struct gadget *g,
* @param g Pointer to gadget
* @param bMaxPacketSize0 Maximum packet size
*/
-extern void usbg_set_gadget_device_max_packet(struct gadget *g,
+extern void usbg_set_gadget_device_max_packet(usbg_gadget *g,
uint8_t bMaxPacketSize0);
/**
@@ -385,7 +372,7 @@ extern void usbg_set_gadget_device_max_packet(struct gadget *g,
* @param g Pointer to gadget
* @param bcdDevice BCD release number
*/
-extern void usbg_set_gadget_device_bcd_device(struct gadget *g,
+extern void usbg_set_gadget_device_bcd_device(usbg_gadget *g,
uint16_t bcdDevice);
/**
@@ -393,7 +380,7 @@ extern void usbg_set_gadget_device_bcd_device(struct gadget *g,
* @param g Pointer to gadget
* @param bcdUSB BCD USB version
*/
-extern void usbg_set_gadget_device_bcd_usb(struct gadget *g, uint16_t bcdUSB);
+extern void usbg_set_gadget_device_bcd_usb(usbg_gadget *g, uint16_t bcdUSB);
/**
* @brief Get the USB gadget strings
@@ -401,7 +388,7 @@ extern void usbg_set_gadget_device_bcd_usb(struct gadget *g, uint16_t bcdUSB);
* @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,
+extern struct gadget_strs *usbg_get_gadget_strs(usbg_gadget *g,
struct gadget_strs *g_strs);
/**
@@ -410,7 +397,7 @@ extern struct gadget_strs *usbg_get_gadget_strs(struct gadget *g,
* @param lang USB language ID
* @param g_sttrs Gadget attributes
*/
-extern void usbg_set_gadget_strs(struct gadget *g, int lang,
+extern void usbg_set_gadget_strs(usbg_gadget *g, int lang,
struct gadget_strs *g_strs);
/**
@@ -419,7 +406,7 @@ extern void usbg_set_gadget_strs(struct gadget *g, int lang,
* @param lang USB language ID
* @param ser Serial number
*/
-extern void usbg_set_gadget_serial_number(struct gadget *g, int lang, char *ser);
+extern void usbg_set_gadget_serial_number(usbg_gadget *g, int lang, char *ser);
/**
* @brief Set the manufacturer name for a gadget
@@ -427,7 +414,7 @@ extern void usbg_set_gadget_serial_number(struct gadget *g, int lang, char *ser)
* @param lang USB language ID
* @param mnf Manufacturer
*/
-extern void usbg_set_gadget_manufacturer(struct gadget *g, int lang, char *mnf);
+extern void usbg_set_gadget_manufacturer(usbg_gadget *g, int lang, char *mnf);
/**
* @brief Set the product name for a gadget
@@ -435,7 +422,7 @@ extern void usbg_set_gadget_manufacturer(struct gadget *g, int lang, char *mnf);
* @param lang USB language ID
* @param prd Product
*/
-extern void usbg_set_gadget_product(struct gadget *g, int lang, char *prd);
+extern void usbg_set_gadget_product(usbg_gadget *g, int lang, char *prd);
/* USB function allocation and configuration */
@@ -447,7 +434,7 @@ extern void usbg_set_gadget_product(struct gadget *g, int lang, char *prd);
* @param f_attrs Function attributes to be set. If NULL setting is omitted.
* @return Pointer to function or NULL if it cannot be created
*/
-extern struct function *usbg_create_function(struct gadget *g, enum function_type type,
+extern struct function *usbg_create_function(usbg_gadget *g, enum function_type type,
char *instance, union attrs *f_attrs);
/**
@@ -476,7 +463,7 @@ extern char *usbg_get_function_name(struct function *f, char *buf, size_t len);
* @param c_strs Configuration strings to be set
* @return Pointer to configuration or NULL if it cannot be created
*/
-extern struct config *usbg_create_config(struct gadget *g, char *name,
+extern struct config *usbg_create_config(usbg_gadget *g, char *name,
struct config_attrs *c_attrs, struct config_strs *c_strs);
/**
@@ -598,13 +585,13 @@ extern int usbg_get_udcs(struct dirent ***udc_list);
* @param g Pointer to gadget
* @param udc Name of UDC to enable gadget
*/
-extern void usbg_enable_gadget(struct gadget *g, char *udc);
+extern void usbg_enable_gadget(usbg_gadget *g, char *udc);
/**
* @brief Disable a USB gadget device
* @param g Pointer to gadget
*/
-extern void usbg_disable_gadget(struct gadget *g);
+extern void usbg_disable_gadget(usbg_gadget *g);
/**
* @brief Get gadget name length
@@ -612,7 +599,7 @@ extern void usbg_disable_gadget(struct gadget *g);
* @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);
+extern size_t usbg_get_gadget_udc_len(usbg_gadget *g);
/**
* @brieg Get name of udc to which gadget is binded
@@ -622,7 +609,7 @@ extern size_t usbg_get_gadget_udc_len(struct gadget *g);
* @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);
+extern char *usbg_get_gadget_udc(usbg_gadget *g, char *buf, size_t len);
/*
* USB function-specific attribute configuration
@@ -715,7 +702,7 @@ extern void usbg_set_net_qmult(struct function *f, int qmult);
* @return Pointer to gadget or NULL if list is empty.
* @note Gadgets are sorted in strings (name) order
*/
-extern struct gadget *usbg_get_first_gadget(usbg_state *s);
+extern usbg_gadget *usbg_get_first_gadget(usbg_state *s);
/**
* @brief Get first function in function list
@@ -723,7 +710,7 @@ extern struct gadget *usbg_get_first_gadget(usbg_state *s);
* @return Pointer to function or NULL if list is empty.
* @note Functions are sorted in strings (name) order
*/
-extern struct function *usbg_get_first_function(struct gadget *g);
+extern struct function *usbg_get_first_function(usbg_gadget *g);
/**
* @brief Get first config in config list
@@ -731,7 +718,7 @@ extern struct function *usbg_get_first_function(struct gadget *g);
* @return Pointer to configuration or NULL if list is empty.
* @note Configs are sorted in strings (name) order
*/
-extern struct config *usbg_get_first_config(struct gadget *g);
+extern struct config *usbg_get_first_config(usbg_gadget *g);
/**
* @brief Get first binding in binding list
@@ -746,7 +733,7 @@ extern struct binding *usbg_get_first_binding(struct config *c);
* @pram g Pointer to current gadget
* @return Next gadget or NULL if end of list.
*/
-extern struct gadget *usbg_get_next_gadget(struct gadget *g);
+extern usbg_gadget *usbg_get_next_gadget(usbg_gadget *g);
/**
* @brief Get the next function on a list.