platform/upstream/libusbg.git
8 years agolibusbgx: Add own name to AUTHORS file.
Krzysztof Opasiak [Fri, 26 Sep 2014 14:59:55 +0000 (16:59 +0200)]
libusbgx: Add own name to AUTHORS file.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Make usbg_lookup_function_type() publicly available
Krzysztof Opasiak [Mon, 22 Sep 2014 10:46:22 +0000 (12:46 +0200)]
libusbgx: Make usbg_lookup_function_type() publicly available

Users of library may often receive function type as a string.
Instead of implementing parsing of such string in each program
it would be more convenient to provide such support in library.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Return suitable error codes instead of -1
Krzysztof Opasiak [Mon, 22 Sep 2014 10:30:03 +0000 (12:30 +0200)]
libusbgx: Return suitable error codes instead of -1

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Allow to set all gadget attrs using one function.
Krzysztof Opasiak [Thu, 18 Sep 2014 15:44:48 +0000 (17:44 +0200)]
libusbgx: Allow to set all gadget attrs using one function.

Having specialized functions for each attribute may be
sometime inconvenient to use. Provide also function
whihc allows to set attribute selected by parameter.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Simplify getting names form library structures
Krzysztof Opasiak [Thu, 18 Sep 2014 12:54:22 +0000 (14:54 +0200)]
libusbgx: Simplify getting names form library structures

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Changes since v1:
Fix show-gadgets example: get attributes before dereferencing them

Reported-by: Philippe De Swert <philippe.deswert@jollamobile.com>
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Always add '\0' at end of string
Krzysztof Opasiak [Thu, 11 Sep 2014 09:49:58 +0000 (11:49 +0200)]
libusbgx: Always add '\0' at end of string

strncpy() may not append trailing '\0' so let's append
it always at end of string to avoid getting into troubles.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: fix: Remove unused variables
Krzysztof Opasiak [Thu, 18 Sep 2014 13:14:46 +0000 (15:14 +0200)]
libusbgx: fix: Remove unused variables

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix off-by-one error.
Krzysztof Opasiak [Tue, 9 Sep 2014 13:24:00 +0000 (15:24 +0200)]
libusbgx: Fix off-by-one error.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: doc: Fix typos in doxygen documentation
Krzysztof Opasiak [Thu, 11 Sep 2014 13:24:48 +0000 (15:24 +0200)]
libusbgx: doc: Fix typos in doxygen documentation

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix usbg_disable_gadget to actually clear the UDC
Tony Lindgren [Sat, 20 Sep 2014 13:50:52 +0000 (15:50 +0200)]
libusbgx: Fix usbg_disable_gadget to actually clear the UDC

Currently usbg_disable_gadget() does not actually write anything
to UDC to clear it and the configured UDC name stays there.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: fix: reverse comparsion to fix error
Krzysztof Opasiak [Thu, 18 Sep 2014 18:38:32 +0000 (20:38 +0200)]
libusbgx: fix: reverse comparsion to fix error

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Return USBG_ERROR_PATH_TOO_LONG error when it happens
Philippe De Swert [Tue, 16 Sep 2014 10:04:47 +0000 (13:04 +0300)]
libusbgx: Return USBG_ERROR_PATH_TOO_LONG error when it happens

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
Acked-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix out-of-tree builds
Krzysztof Opasiak [Tue, 22 Dec 2015 19:46:03 +0000 (20:46 +0100)]
libusbgx: Fix out-of-tree builds

The include flag should point to the source directory, not the build
directory.

Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Rebased onto kopasiak/master.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: doc: Add document about gadget schemes
Krzysztof Opasiak [Mon, 7 Jul 2014 16:08:40 +0000 (18:08 +0200)]
libusbgx: doc: Add document about gadget schemes

Add document which clarify reasons of implementing
gadget schemes and also describes syntax of such files.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: examples: Add gadget-import sample app
Krzysztof Opasiak [Sat, 5 Jul 2014 11:29:55 +0000 (13:29 +0200)]
libusbgx: examples: Add gadget-import sample app

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add functions to get import error text and line
Krzysztof Opasiak [Mon, 7 Jul 2014 17:26:24 +0000 (19:26 +0200)]
libusbgx: Add functions to get import error text and line

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add import gadget functionality
Krzysztof Opasiak [Sat, 5 Jul 2014 12:14:22 +0000 (14:14 +0200)]
libusbgx: Add import gadget functionality

Whole gadget can be exported to file using usbg_export_gadget().
This commit adds complementary API function usbg_import_gadget()
which allows to import whole gadget (including attrs, strings,
configs, functions and bindings) from file to configfs.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Allow to store error information in usbg_state
Krzysztof Opasiak [Sat, 5 Jul 2014 12:01:09 +0000 (14:01 +0200)]
libusbgx: Allow to store error information in usbg_state

If error occurred during parsing user should have
an opportunity to get details about place and type
of error.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add import config functionality
Krzysztof Opasiak [Sat, 5 Jul 2014 12:12:34 +0000 (14:12 +0200)]
libusbgx: Add import config functionality

Configurations can be exported to file using usbg_export_config().
This commit adds complementary API function usbg_import_config()
which allows to import configuration (with attrs, strings and
bindings) from file to chosen gadget.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add import function functionality
Krzysztof Opasiak [Sat, 5 Jul 2014 11:52:41 +0000 (13:52 +0200)]
libusbgx: Add import function functionality

Functions can be exported to file using usbg_export_function().
This commit adds complementary API function usbg_import_function()
which allows to import function from file to configfs.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Allow to store error information in usbg_gadget
Krzysztof Opasiak [Sat, 5 Jul 2014 11:42:40 +0000 (13:42 +0200)]
libusbgx: Allow to store error information in usbg_gadget

If error occurred during parsing user should have
an oportunity to get details about place and type
of error.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add errors which may happen during parsing
Krzysztof Opasiak [Sat, 5 Jul 2014 11:38:21 +0000 (13:38 +0200)]
libusbgx: Add errors which may happen during parsing

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: examples: Add sample application to export gadget
Krzysztof Opasiak [Sat, 5 Jul 2014 10:48:18 +0000 (12:48 +0200)]
libusbgx: examples: Add sample application to export gadget

Add sample C code which shows how to use new functionality
of libusbg - gadget export. This program allows to export
chosen gadget from configfs to a file.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add export gadget functionality
Krzysztof Opasiak [Sat, 5 Jul 2014 11:03:27 +0000 (13:03 +0200)]
libusbgx: Add export gadget functionality

Whole gadget setting process take a lot of simple
commands (or lines of code). Those shell commands
may take a while or require dedicated script and
hard-coding gadget configuration. To avoid such
situation add to library ability to export a whole
gadget into file.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add export config functionality
Krzysztof Opasiak [Sat, 5 Jul 2014 10:52:25 +0000 (12:52 +0200)]
libusbgx: Add export config functionality

Configuration may have several functions if we add
strings and some attributes it gives a few shell commands
to set it up. To avoid this add export cofiguration
which allows to store usb configuration in a file.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add export function functionality
Krzysztof Opasiak [Sat, 5 Jul 2014 10:51:45 +0000 (12:51 +0200)]
libusbgx: Add export function functionality

Function settings may be complicated and their configuration
may take a long while. To save time it would be convenient
to allow for storing function settings in a file.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add label field to usbg_function structure
Krzysztof Opasiak [Sat, 5 Jul 2014 09:55:15 +0000 (11:55 +0200)]
libusbgx: Add label field to usbg_function structure

Add some field where additional label for function can be stored.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add dependency to libconfig
Krzysztof Opasiak [Tue, 22 Dec 2015 19:42:30 +0000 (20:42 +0100)]
libusbgx: Add dependency to libconfig

This library is used to import and export
gadget/function/config to and from file.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Use reentrant functions to avoid static buffers usage
Krzysztof Opasiak [Sat, 5 Jul 2014 09:01:17 +0000 (11:01 +0200)]
libusbgx: Use reentrant functions to avoid static buffers usage

ether_aton() and ether_ntoa() use static buffers which are
overwritten by next call of this function so those functions
should not be used in multithread environment.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add missing const qualifiers
Krzysztof Opasiak [Fri, 4 Jul 2014 20:25:19 +0000 (22:25 +0200)]
libusbgx: Add missing const qualifiers

Const qualifers should be placed in all functions which
don't need to modify provided buffers to allow caller to
pass literals or pointers to non-modifable space.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Don't try to set read only attribute
Krzysztof Opasiak [Wed, 2 Jul 2014 07:42:13 +0000 (09:42 +0200)]
libusbgx: Don't try to set read only attribute

Some of function attributes are read only on configfs, so library
should not try to set them and accept only empty values in functions
which set multiple attributes at single call.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add example to show how to create ffs functions.
Krzysztof Opasiak [Mon, 9 Jun 2014 11:06:15 +0000 (13:06 +0200)]
libusbgx: Add example to show how to create ffs functions.

Add example which demonstartes two ways of creating ffs
based usb functions.

How to set-up gadget using this example:
1) Run gadget-ffs

2) Mount both instances:
 $ mount my_dev_name -t functionfs /path/to/mount/dir1
 $ mount my_awesome_dev_name -t functionfs /path/to/mount/dir2

3) Run ffs daemons for both instances:
 $ my-ffs-daemon /path/to/mount/dir1
 $ my-ffs-daemon /path/to/mount/dir2

4) Enable your gadget:
 $ echo "my_udc_name" > /sys/kernel/config/usb_gadget/g1/UDC

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Update show gadget example support ffs functions.
Krzysztof Opasiak [Tue, 10 Jun 2014 16:26:36 +0000 (18:26 +0200)]
libusbgx: Update show gadget example support ffs functions.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add support for functionFS.
Krzysztof Opasiak [Mon, 9 Jun 2014 09:28:47 +0000 (11:28 +0200)]
libusbgx: Add support for functionFS.

Recent kernel versions supports creation of functionFS based
functions using configFS, so this library also should support this.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix potential memory leak in usbg_init()
Krzysztof Opasiak [Tue, 10 Jun 2014 15:20:38 +0000 (17:20 +0200)]
libusbgx: Fix potential memory leak in usbg_init()

Memory allocated with asprintf() for variable path
could be not free() in some cases. Fix this issue by
doing some small refactoring.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Update examples to new API functionality.
Krzysztof Opasiak [Fri, 7 Mar 2014 09:10:27 +0000 (10:10 +0100)]
libusbgx: Update examples to new API functionality.

Removing gadget/config/function/binding functionality
has been added to API so add example of how to use it.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add remove gadget functionality.
Krzysztof Opasiak [Thu, 3 Apr 2014 14:57:26 +0000 (16:57 +0200)]
libusbgx: Add remove gadget functionality.

Add function which allow to remove USB gadget.
This functions also remove gadget from internal
library structures what means that after this
operation all pointers to removed gadget are invalid.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add remove function functionality.
Krzysztof Opasiak [Thu, 3 Apr 2014 14:55:24 +0000 (16:55 +0200)]
libusbgx: Add remove function functionality.

Add function which allow to remove USB function.
This functions also remove function from internal
library structures what means that after this
operation all pointers to removed function are invalid.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add remove configuration functionality.
Krzysztof Opasiak [Thu, 3 Apr 2014 14:52:39 +0000 (16:52 +0200)]
libusbgx: Add remove configuration functionality.

Add function which allow to remove configuration.
This functions also remove binding from internal
library structures what means that after this
operation all pointers to removed config are invalid.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add remove gadget/config strings functionality.
Krzysztof Opasiak [Thu, 13 Mar 2014 12:59:03 +0000 (13:59 +0100)]
libusbgx: Add remove gadget/config strings functionality.

Add functions which allow to remove strings in gadget
and configuration.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add remove binding functionality.
Krzysztof Opasiak [Thu, 13 Mar 2014 12:57:16 +0000 (13:57 +0100)]
libusbgx: Add remove binding functionality.

Add function which allow to remove binding between function
and configuration. This functions also remove binding from
internal library structures wht means that after this
operation all pointers to removed binding are invalid.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Do not dereference usb config attributes when they are NULL. CID#56126
Philippe De Swert [Tue, 13 May 2014 13:43:11 +0000 (16:43 +0300)]
libusbgx: Do not dereference usb config attributes when they are NULL. CID#56126

We probably need to check if we get valid attributes passed. Otherwise we will
try to dereference a NULL-pointer as the usb_config_attr will not be valid.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Do not try to dereference func when it is NULL. CID#56127
Philippe De Swert [Fri, 9 May 2014 12:08:41 +0000 (15:08 +0300)]
libusbgx: Do not try to dereference func when it is NULL. CID#56127

We check if func is NULL, so if the allocation function failed we should
not dereference or handle it anymore, so we jump straight to the end.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix buffer overrun issue. CID#56128
Philippe De Swert [Tue, 13 May 2014 12:58:40 +0000 (15:58 +0300)]
libusbgx: Fix buffer overrun issue. CID#56128

Avoid calling usbg_read_string() with a 40 byte long buffer, which in turn is filled in
by usbg_read_buf() which uses a maximum of 256 bytes (USBG_MAX_STR_LENGTH). This adjusts
the buffer to be the right size.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix readlink/buffer overrun issue. CID#56130, CID#56129
Philippe De Swert [Tue, 13 May 2014 12:55:57 +0000 (15:55 +0300)]
libusbgx: Fix readlink/buffer overrun issue. CID#56130, CID#56129

Readlink() can return the total length of the buffer (here 4096/USBG_MAX_PATH_LENGTH),
so we do not want to dereference target[4096] as that would give an off by one error.

Signed-off-by: Philippe De Swert <philippe.deswert@jollamobile.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Use config ID and label instead of config name.
Krzysztof Opasiak [Wed, 2 Apr 2014 16:49:57 +0000 (18:49 +0200)]
libusbgx: Use config ID and label instead of config name.

Naming convention of Config FS should not be exposed
to user of library. All API functions should use
configuration ID (configuration number) as unique
identificator and configuration label as human
readable description.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Replace usage of function name with type and instance.
Krzysztof Opasiak [Wed, 2 Apr 2014 16:46:21 +0000 (18:46 +0200)]
libusbgx: Replace usage of function name with type and instance.

User of library should not use directly function name but
only type of the function and name of instance. Using this
will separate user for naming convention on Config FS.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add checking for legal function type.
Krzysztof Opasiak [Fri, 21 Mar 2014 15:58:26 +0000 (16:58 +0100)]
libusbgx: Add checking for legal function type.

Function type provided by user to functions should
be checked before usage to avoid errors.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix wrong malloc sizes in allocate functions.
Krzysztof Opasiak [Wed, 26 Mar 2014 14:34:05 +0000 (15:34 +0100)]
libusbgx: Fix wrong malloc sizes in allocate functions.

Functions usbg_allocate_function() and usbg_allocate_binding()
had allocated sizeof(usbg_config) instead of usbg_function
and usbg_binding.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix missing read of bcdDevice.
Krzysztof Opasiak [Tue, 1 Apr 2014 19:30:40 +0000 (21:30 +0200)]
libusbgx: Fix missing read of bcdDevice.

Value of bcdDevice has been never read from Config FS
and this field was leaved uninitialized. Change
usbg_parse_gadget_attrs() to read also from this file.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Replace sprintf with snprintf.
Krzysztof Opasiak [Thu, 13 Mar 2014 12:32:10 +0000 (13:32 +0100)]
libusbgx: Replace sprintf with snprintf.

Usage of sprintf() may be dangerous in some cases
so use snprintf() to avoid writing after allocated
memory.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Remove fixed-size buffers from usbg_binding.
Krzysztof Opasiak [Tue, 18 Mar 2014 19:48:20 +0000 (20:48 +0100)]
libusbgx: Remove fixed-size buffers from usbg_binding.

Path and name length should not be placed in constant
size buffer but in allocated memory.

Handle overflows of snprintf in related funcitons.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Remove fixed-size buffers from usbg_function.
Krzysztof Opasiak [Wed, 12 Mar 2014 14:26:57 +0000 (15:26 +0100)]
libusbgx: Remove fixed-size buffers from usbg_function.

Path and name length should not be placed in constant
size buffer but in allocated memory.

Handle overflows of snprintf in related funcitons.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Remove fixed-size buffers from usbg_config.
Krzysztof Opasiak [Wed, 12 Mar 2014 13:10:33 +0000 (14:10 +0100)]
libusbgx: Remove fixed-size buffers from usbg_config.

Path and name length should not be placed in constant
size buffer but in allocated memory.

Use PATH_MAX macro from limits.h as default size for
USBG_MAX_PATH_LENGTH.

Handle overflows of snprintf in related funcitons.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Remove fixed-size buffers from usbg_gadget.
Krzysztof Opasiak [Wed, 12 Mar 2014 11:21:31 +0000 (12:21 +0100)]
libusbgx: Remove fixed-size buffers from usbg_gadget.

Path and name length should not be placed in constant
size buffer but in allocated memory.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Remove fixed-size buffer from usbg_state.
Krzysztof Opasiak [Wed, 12 Mar 2014 11:05:52 +0000 (12:05 +0100)]
libusbgx: Remove fixed-size buffer from usbg_state.

Path length should not be placed in constant size buffer
but in allocated memory.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix wrong target size.
Krzysztof Opasiak [Tue, 18 Mar 2014 19:45:33 +0000 (20:45 +0100)]
libusbgx: Fix wrong target size.

Variable target is a place for path to USB function
so it should have size USBG_MAX_PATH_LENGTH not
USBG_MAX_STR_LENGTH size.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Update examples to use returned error codes.
Krzysztof Opasiak [Mon, 3 Mar 2014 16:26:59 +0000 (17:26 +0100)]
libusbgx: Update examples to use returned error codes.

Examples provided with the library should use returned
error codes and provide information to user.

Remove todo baceuse it has been already done.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add functions for getting error strings.
Krzysztof Opasiak [Mon, 3 Mar 2014 16:15:58 +0000 (17:15 +0100)]
libusbgx: Add functions for getting error strings.

Add usbg_error_name() to get error name as a string.

Add usbg_strerror() to get brief error description in English.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Return error code instead of -1.
Krzysztof Opasiak [Mon, 3 Mar 2014 14:38:35 +0000 (15:38 +0100)]
libusbgx: Return error code instead of -1.

Change usbg_add_config_function() to return usbg_error
instead of returning 0 or -1.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Change usbg_get_function_attrs() to return error code.
Krzysztof Opasiak [Mon, 3 Mar 2014 13:33:27 +0000 (14:33 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Return error code instead of NULL pointer - config.
Krzysztof Opasiak [Mon, 3 Mar 2014 13:04:59 +0000 (14:04 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Return error code instead of NULL pointer.
Krzysztof Opasiak [Wed, 5 Mar 2014 11:00:20 +0000 (12:00 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add return value to usbg_enable/disable_gadget().
Krzysztof Opasiak [Mon, 3 Mar 2014 11:10:01 +0000 (12:10 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add return value to config related functions.
Krzysztof Opasiak [Fri, 28 Feb 2014 10:53:02 +0000 (11:53 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add return value to usb function related functions.
Krzysztof Opasiak [Fri, 28 Feb 2014 08:59:19 +0000 (09:59 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add return value to usbg_set_gadget_*() functions.
Krzysztof Opasiak [Thu, 27 Feb 2014 18:00:12 +0000 (19:00 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add return value to gadget creation functions.
Krzysztof Opasiak [Thu, 27 Feb 2014 17:21:33 +0000 (18:21 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add parenthesis to INSERT_TAILQ_STRING_ORDER macro.
Krzysztof Opasiak [Thu, 27 Feb 2014 14:23:05 +0000 (15:23 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Return usbg_error instead of char* in usbg_get_*_name().
Krzysztof Opasiak [Wed, 26 Feb 2014 15:06:31 +0000 (16:06 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Return usbg_error instead of -1 in usbg_*_len().
Krzysztof Opasiak [Wed, 26 Feb 2014 14:04:15 +0000 (15:04 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add error handling to usbg_init() and related functions.
Krzysztof Opasiak [Fri, 7 Mar 2014 10:44:42 +0000 (11:44 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix wrong binding parsing.
Krzysztof Opasiak [Tue, 4 Mar 2014 19:29:50 +0000 (20:29 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add internal free functions for each library structure.
Krzysztof Opasiak [Mon, 24 Feb 2014 19:29:03 +0000 (20:29 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Refresh function attributes while each get.
Krzysztof Opasiak [Mon, 24 Feb 2014 16:18:11 +0000 (17:18 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Refresh config strings while each get.
Krzysztof Opasiak [Thu, 20 Feb 2014 10:35:23 +0000 (11:35 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Refresh config attributes while each get.
Krzysztof Opasiak [Thu, 20 Feb 2014 10:21:04 +0000 (11:21 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Refresh gadget strings while each get.
Krzysztof Opasiak [Wed, 19 Feb 2014 13:56:27 +0000 (14:56 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Refresh gadget attributes while each get.
Krzysztof Opasiak [Wed, 19 Feb 2014 13:53:19 +0000 (14:53 +0100)]
libusbgx: 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-of-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Remove unused variables to make compiler happy.
Krzysztof Opasiak [Wed, 19 Feb 2014 10:15:55 +0000 (11:15 +0100)]
libusbgx: Remove unused variables to make compiler happy.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Update examples to new API.
Krzysztof Opasiak [Fri, 14 Feb 2014 08:28:33 +0000 (09:28 +0100)]
libusbgx: Update examples to new API.

API of library has been changed, so it is necessary
to update examples of library usage.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Rename all public structures to usbg convention.
Krzysztof Opasiak [Wed, 19 Feb 2014 15:38:33 +0000 (16:38 +0100)]
libusbgx: Rename all public structures to usbg convention.

Switch form struct * to typedef usbg_* to provide convenient
API for user.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Hide definition of binding structure.
Krzysztof Opasiak [Wed, 19 Feb 2014 14:58:38 +0000 (15:58 +0100)]
libusbgx: Hide definition of binding structure.

Hide definition of binding structure to avoid direct
access to its fields. Rename it to usbg_binding.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Hide definition of function structure.
Krzysztof Opasiak [Wed, 19 Feb 2014 14:56:31 +0000 (15:56 +0100)]
libusbgx: Hide definition of function structure.

Hide definition of function structure to avoid direct
access to its fields. Rename it to usbg_function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Hide definition of config structure.
Krzysztof Opasiak [Wed, 19 Feb 2014 19:50:12 +0000 (20:50 +0100)]
libusbgx: Hide definition of config structure.

Hide definition of config structure to avoid direct
access to its fields. Rename it to usbg_confg.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Hide definition of gadget structure.
Krzysztof Opasiak [Wed, 19 Feb 2014 14:54:06 +0000 (15:54 +0100)]
libusbgx: 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>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Hide definition of state structure.
Krzysztof Opasiak [Wed, 12 Feb 2014 14:01:32 +0000 (15:01 +0100)]
libusbgx: Hide definition of state structure.

Hide definition of state structure to avoid direct
access to its fields. Rename it to usbg_state.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add getter for binding name and target.
Krzysztof Opasiak [Thu, 13 Feb 2014 14:13:29 +0000 (15:13 +0100)]
libusbgx: Add getter for binding name and target.

Add usbg_get_binding_target() to avoid direct binding
structure members access. Add also usbg_get_binding_name_len()
and usbg_get_binding_name() to allow getting binding name.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add getter for function name.
Krzysztof Opasiak [Fri, 14 Feb 2014 15:31:06 +0000 (16:31 +0100)]
libusbgx: Add getter for function name.

Add usbg_get_function_name() and usbg_get_function_name_len()
to avoid direct function structure members access.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add functions for get/set function attributes.
Krzysztof Opasiak [Thu, 13 Feb 2014 12:47:37 +0000 (13:47 +0100)]
libusbgx: Add functions for get/set function attributes.

Add usbg_get_function_attrs() and usbg_get_function_type()
to aviod direct access to function structure members.

Add usbg_set_function_attrs() to allow set all function\
attributes with one call.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Remove function_names from header file.
Krzysztof Opasiak [Thu, 13 Feb 2014 10:34:24 +0000 (11:34 +0100)]
libusbgx: Remove function_names from header file.

function_names table is for internal usage only.
User should use function_types enum.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add getter for config name.
Krzysztof Opasiak [Fri, 14 Feb 2014 14:57:59 +0000 (15:57 +0100)]
libusbgx: Add getter for config name.

Add usbg_get_config_name() and usbg_get_config_name_len()
to avoid direct config structure members access.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add set/get config attrs/strings functions.
Krzysztof Opasiak [Wed, 19 Feb 2014 15:36:40 +0000 (16:36 +0100)]
libusbgx: Add set/get config attrs/strings functions.

Add usbg_set_config_attrs() function to allow setting
all attributes with one call. Add also getter for attrs
to avoid direct accessing of configuration fields.

Add usbg_set_config_strs() to be consistent with gadget
API.

Change usbg_create_config() to allow configuration creation
and attribute setting with one call.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Separate config attrs and strs form configuration.
Krzysztof Opasiak [Wed, 19 Feb 2014 13:39:35 +0000 (14:39 +0100)]
libusbgx: Separate config attrs and strs form configuration.

Configuration, its attributes and strings are all logically
independent so should be placed in separate structures.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add getter for configfs path in state.
Krzysztof Opasiak [Fri, 14 Feb 2014 13:11:59 +0000 (14:11 +0100)]
libusbgx: Add getter for configfs path in state.

Add usbg_get_configfs_path_len() and usbg_get_configfs_path()
to avoid direct access to state structure.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Change for each macros to avoid direct access to fields.
Krzysztof Opasiak [Wed, 12 Feb 2014 13:33:32 +0000 (14:33 +0100)]
libusbgx: Change for each macros to avoid direct access to fields.

Add dedicated functions for iterating over gadgets, configs,
bindigs and functions to avoid direct access to fields of this
structures. Change definitons of usbg_for_each_* macros to use
new functions.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add getter for gadget name and udc.
Krzysztof Opasiak [Fri, 14 Feb 2014 12:17:58 +0000 (13:17 +0100)]
libusbgx: Add getter for gadget name and udc.

Add usbg_get_gadget_name() and usbg_get_gadget_udc() to avoid
direct gadget structure members access.

Add also usbg_get_gadget_name_len() and
usbg_get_gadget_udc_len() to allow getting udc and name length.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add getters for gadget strings and attributes.
Krzysztof Opasiak [Wed, 12 Feb 2014 12:17:55 +0000 (13:17 +0100)]
libusbgx: Add getters for gadget strings and attributes.

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

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add functions to set all strs and attrs with one call.
Krzysztof Opasiak [Fri, 14 Feb 2014 11:52:27 +0000 (12:52 +0100)]
libusbgx: Add functions to set all strs and attrs with one call.

Rename usbg_create_gadget() to usbg_create_vid_pid().
dd usbg_create_gadget() to allow gadget creation
with given attributes and strings. Add usbg_set_gadget_attrs()
which allow to set all attributes with one call. Add
usbg_set_gadget_strs() which allow to set all strings with
one call.

Gadget structure creation and initialization has been moved to
usbg_create_empty_gadget() to avoid copy-paste same code in
usbg_create_gadget_vid_pid() and usbg_create_gadget().

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix wrong paths while setting gadget attributes.
Krzysztof Opasiak [Mon, 17 Feb 2014 13:45:17 +0000 (14:45 +0100)]
libusbgx: Fix wrong paths while setting gadget attributes.

Add missing gadget name to path while writting gadget attributes.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>