libusbg: Remove unused variables to make compiler happy.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Refresh gadget attributes while each get.

Gadget attributes may be changed by kernel or other
user so they should not be cached in library structures.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Refresh gadget strings while each get.

Gadget strings should not be cached in library.
Removing internal strings structure allowed to add
full support for multilingual strings.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Refresh config attributes while each get.

Config attributes may be changed by kernel or other
user so they should not be cached in library structures.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Refresh config strings while each get.

Config strings should not be cached in library.
Removing internal strings structure allowed to add
full support for multilingual strings.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Refresh function attributes while each get.

Function attributes may be changed by kernel or other
user so they should not be cached in library structures.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Add internal free functions for each library structure.

Library should have internal API for freing structures instead of
copy pasting same code in different places.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Fix wrong binding parsing.

usbg_parse_bindings() function has done parsing incorrectly
and in inefficent way. Changes made in this function provide
better performance and fix wrong linking issue when having
two instances of the same function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Add error handling to usbg_init() and related functions.

Assumption that all malloc() and read()/write() finish correctly
is too bold. Errors should be handled and propagated to upper
layers of library and returned to user.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Return usbg_error instead of -1 in usbg_*_len().

Functions which provides user length of some internal
strings should return usbg_error instead of -1.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Return usbg_error instead of char* in usbg_get_*_name().

API should be consistent and use error codes to determine what
type of error occurred instead of returning NULL only.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Add parenthesis to INSERT_TAILQ_STRING_ORDER macro.

Surround each pointer in macro with parenthesis to avid
errors related to operator precedence.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
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>
libusbg: Add return value to usbg_set_gadget_*() functions.

Setting each of attribute may fail due to a lot of reasons
so those functions should report this failure to a user.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Add return value to usb function related functions.

Each usbg_set_*() may fail so it should have a return value
to notify user about reason of failure.

To be consistent with rest of API usbg_create_function()
should also return error code to notify user about reasons
of failure instead of binary information (NULL or not).

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Add return value to config related functions.

Each usbg_set_config_*() may fail so it should have
a return value to notify user about reason of failure.

To be consistent with rest of API usbg_create_config()
should also return error code to notify user about reasons
of failure instead of binary information (NULL or not).

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Add return value to usbg_enable/disable_gadget().

Enabling and disabling gadget may fail due to many reasons
so those functions should notify user about it.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Return error code instead of NULL pointer.

Change usbg_get_gadget_strs() and usbg_get_gadget_attrs()
to return usbg_error instead of NULL pointer.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Return error code instead of NULL pointer - config.

Change usbg_get_config_strs() and usbg_get_config_attrs()
to return usbg_error instead of NULL pointer.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
libusbg: Change usbg_get_function_attrs() to return error code.

usbg_get_function_attrs() may fail due to many reasons
so it should notify the user about exact reason of failure
instead of returning only NULL pointer.

Add also USBG_ERROR_NOT_SUPPORTED to usbg_set_function_attrs().

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>