Pawel Szewczyk [Tue, 10 Feb 2015 13:25:30 +0000 (14:25 +0100)]
libusbgx: tests: Add getting config tests
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Remove unused variable in for_each_test_config().
Change-Id: I6dd8dc33639dff2d3322c6098a43c69beb8a7ef6
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Mon, 17 Nov 2014 12:23:40 +0000 (13:23 +0100)]
libusbgx: tests: Add getting configfs path test
Change-Id: Ia7d368c8749d28235a4209d5a0de90dc6878717b
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Wed, 11 Feb 2015 09:13:01 +0000 (10:13 +0100)]
libusbgx: tests: Add getting functions tests
Change-Id: I89296562177061559de84aa5332d8dc9347d2e13
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Wed, 11 Feb 2015 10:43:17 +0000 (11:43 +0100)]
libusbgx: tests: Use cast_to_largest_integral_type()
Direct cast from pointer to integer of different size
causes ugly compiler warning. To avoid this use
dedicated macro from cmocka.
Change-Id: I56f4095dd8f98c8349d02b421f02de1d61e0b2b8
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Tue, 10 Feb 2015 14:29:18 +0000 (15:29 +0100)]
libusbgx: tests: Make some functions static, some move to header
init_with_state is also used by functions in usbg-test.c, so was declared
globaly in header. Other functions from test.c is not used outside and
we can make them static.
Change-Id: I56f4095dd8f98c8349d02b421f02de1d61e0b2b7
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 22 Dec 2015 20:21:27 +0000 (21:21 +0100)]
libusbgx: tests: Add doxygen macros for documenting test cases
Also proceed doxygen config file with autoconf now. Autoconf copy .in file,
substituting found variable values. It allows to specify what documentation
should be build by configure script.
Change-Id: I00cae61aefcc5b6444b0afc0dfe73c5973de34a9
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Rebase and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Mon, 9 Feb 2015 09:29:59 +0000 (10:29 +0100)]
libusbgx: tests: Remove unused variables
Change-Id: I4db3a1d8683867c1e969898882f0589f477ebe4c
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Wed, 26 Nov 2014 15:19:15 +0000 (16:19 +0100)]
libusbgx: tests: Add guarding macros in header
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Remove unnecessary newline.
Change-Id: I3db3a1d8683867c1e969898882f0589f477ebe4b
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Fri, 12 Dec 2014 13:36:06 +0000 (14:36 +0100)]
libusbgx: tests: Add autotools making description to guideline
Change-Id: I82b8b5b2f792bf72586d93cc5d6987ad017be618
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 22 Dec 2015 20:17:18 +0000 (21:17 +0100)]
libusbgx: tests: Build tests with autotools
Change-Id: I1438caf6806d2197bcf20a63b56e33d9243fb2a0
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description and rebase]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Wed, 7 Jan 2015 15:53:06 +0000 (16:53 +0100)]
libusbgx: tests: Add proper path comparing
Multiple slashes are allowed in paths, so they cannot be compared as
simple strings.
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Fix some code style issue. Move expect_path() macro
to heder file.
Change-Id: I613f9335ac665ae0e038b0493c6582a20678bd12
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 3 Feb 2015 13:16:42 +0000 (14:16 +0100)]
libusbgx: tests: Fix tests to use correct usbg_state field
Due to recent changes in usbg_state, lets
introduce configfs_path field in state test_state
structure and fill it.
Since now path field should not be filled as it's
filled by prepare_state() function and generates
subsystem path using given configfs path.
Change-Id: I50e606c9f8c5eb478ac48fc453840b9a3efdd117
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 3 Feb 2015 13:24:56 +0000 (14:24 +0100)]
libusbgx: tests: Fix tests build
Due to adding configure flags which allows to disable
libconfig dependency introduce a temporary fix which should
be removed when we will build tests with autotools.
Change-Id: I51f606c9f8c5eb478ac48fc453840b9a3efdd117
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Wed, 7 Jan 2015 10:21:56 +0000 (11:21 +0100)]
libusbgx: tests: Remove negative buffer test
Size_t is unsigned and passing -1 as buffer length makes no sense.
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Rebase and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 22 Dec 2015 20:44:45 +0000 (21:44 +0100)]
libusbgx: tests: Add options parsing to running script
Change-Id: I1658663e8b7f14b5595ef806c5fca03ae10c830d
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Signed-off-by: Stanislaw Wadas <s.wadas@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Mon, 17 Nov 2014 16:06:34 +0000 (17:06 +0100)]
libusbgx: tests: Add testing guideline
Change-Id: Ia7c2fa66a0bfa024858cde90a52ed05cbd41b12c
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Fri, 14 Nov 2014 15:14:23 +0000 (16:14 +0100)]
libusbgx: tests: Allow to skip some tests
In some cases we may want to mark some tests as skipped.
Doing this in code requires recompilation after each change.
This patch extends the tests framework and allows to create
configuration file and mark some tests as skipped (for example
using # and comment some test and run them always from the
same binary file.
We use stdin/stdout for reading/writing configuration
because we are wrapping filesystem operations in our
mock framework (usbg-io-wrappers). To keep our mock
framework as simple as we can we use those standard
streams which are forrwarded by framework to original
implementations of those functions.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Fri, 14 Nov 2014 13:22:54 +0000 (14:22 +0100)]
libusbgx: tests: Add init and getting gadgets tests
Change-Id: I4c872a76bf59b8eaababfdf4bbb1804d4008f8de
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Make two macros (generic and specific) for defining test
cases instead of hardcoding everything in one macro.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Fri, 14 Nov 2014 14:09:47 +0000 (15:09 +0100)]
libusbgx: tests: Add assert functions for internal usbg structures
Internal usbg structures definitions are required to check if they are
correctly filled by libusbg.
Change-Id: I61d88b03d7255e6a4a6760ce5b9ad564a686c492
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Wed, 12 Nov 2014 15:54:13 +0000 (16:54 +0100)]
libusbgx: tests: Use RTLD to access original fputs()
Sometimes we would like to print something to stderr
or stdout from tests so our wrapper should use standard
fputs() definition for this function.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Tue, 9 Sep 2014 09:28:11 +0000 (11:28 +0200)]
libusbgx: tests: Add simulation of configfs for init by wrapping i/o funcs.
To separate libusbgx from configfs we simulate it by replacing i/o
functions. We can define gadgets and pass them to init and other usbg
functions through simulated file system.
Change-Id: I9d0964f13b6ef7385d32d6f0d6775fe88ff8eb17
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Fri, 6 Mar 2015 15:00:33 +0000 (16:00 +0100)]
libusbgx: Fix compilation warnings
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Pawel Szewczyk [Wed, 11 Feb 2015 13:03:39 +0000 (14:03 +0100)]
libusbgx: Fix gadget attributes reading order
To be more consistent we read and write gadget attributes in the same order
specified by usbg_gadget_attr enum. It can make difference in testing, where
order often does matter and allows to write tests more efficient when
using wrapped filesystem operations. Also, consistency is always a good
thing.
Change-Id: Ieb3c7f81a8c0a135c47ebd358e5a87fe04766f2a
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Fri, 6 Feb 2015 15:20:19 +0000 (16:20 +0100)]
libusbgx: Add include guards to internal header
Change-Id: I4db3a1d8683867c1e969898882f0589f477ebe4b
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 3 Feb 2015 13:14:09 +0000 (14:14 +0100)]
libusbgx: Fix usbg_get_configfs_path()
Store configfs path in configfs_path attribute
and return it in usbg_get_configfs_path()
instead of returning path to usbg_gadget subsys.
Based on patch "libusbg: Fix configfs path" created by:
Pawel Szewczyk <p.szewczyk@samsung.com>
Change-Id: I49e606c9f8c5eb478ac48fc453840b9a3efdd117
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 22 Dec 2015 20:09:24 +0000 (21:09 +0100)]
libusbgx: add --disable-gadget-schemes to configure
This commit adds --disable-gadget-schemes option to configure.
It allows to build libusbgx without libconfig.
This change does not change the API - we add instead empty functions.
The default solution is to use libconfig.
Change-Id: Ia8581fdb6368fb1877e97ee56d91d29e5128611e
Signed-off-by: Przemyslaw Kedzierski <p.kedzierski@samsung.com>
[Rebase and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Wed, 29 Oct 2014 15:15:21 +0000 (16:15 +0100)]
libusbgx: Add empty definitions of gadget schemes functions
In some cases user may want to not use gadget schemes
functionality so he should be able to remove libconfig
dependency. To be able to do this without API break
add empty definitions of gadget schemes functions which
only returns USBG_ERROR_NOT_SUPPORTED.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 22 Dec 2015 20:07:20 +0000 (21:07 +0100)]
libusbgx: Move gadget schemes functionality to separate file
Having wholle code in one file hurts code readability.
It would be more convenient to split this large file
into a few smaller. This commits move whole functinality
related to gadget schemes to separate file.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Wed, 29 Oct 2014 14:26:12 +0000 (15:26 +0100)]
libusbgx: Extract internal header file
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Sat, 4 Oct 2014 08:27:40 +0000 (10:27 +0200)]
libusbgx: Add max and min values to enums
In some cases user of library would like to iterate over
all enum values. Depending on enum values order is not
a good idea so provide suitable min and max values to alow
doing something like:
int i;
for(i = USBG_GADGET_ATTR_MIN; i < USBG_GADGET_ATTR_MAX; ++i)
do_something_useful(i);
Moreover, ensure that function_names and gadget_attr_names
arrays has allways the same size as number of meaningful
values in related enums.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 11 Sep 2014 18:48:08 +0000 (20:48 +0200)]
libusbgx: Add example how to use usbg_udc structure
This example shows how to learn what udcs are available
in system and also how to find out what gadgets are
enabled on them.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 11 Sep 2014 18:44:33 +0000 (20:44 +0200)]
libusbgx: Allow to get gadget enabled on given UDC
Add usbg_get_udc_gadget() which allows user to learn
which gadget is attached to selected UDC.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 11 Sep 2014 18:17:22 +0000 (20:17 +0200)]
libusbgx: Refresh gadget UDC while each usbg_get_gadget_udc()
Kernel may decide to detach our gadget in some cases.
A good example is when FFS daemon received a SIGSEGV
and all descriptors has been closed.
To avoid returning false informations to user we have
to refresh UDC attribute before returning cached pointer
to usbg_udc.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Tue, 23 Sep 2014 09:56:11 +0000 (11:56 +0200)]
libusbgx: Rework API to use usbg_udc structure
Using string as udc identifier provides a lot
of troubles. To be more consistent with rest of
API rework it to start using usbg_udc structure
instead of using char *.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 11 Sep 2014 17:15:57 +0000 (19:15 +0200)]
libusbgx: Replace usbg_get_udcs() with loop
Library allows to iterate over each gadget using loop.
To be consistent with this convention add similar loop
for UDCs.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Thu, 18 Sep 2014 16:12:46 +0000 (18:12 +0200)]
libusbgx: Add udc structure
Add structure to store informations about available udcs
instead of using their names as a string.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Krzysztof Opasiak [Fri, 26 Sep 2014 15:12:57 +0000 (17:12 +0200)]
libusbgx: Don't print errno when it has not been directly set
Replace ERRORNO() macro with ERROR(). Difference betwen
them is that ERRORNO() prints also standard error string
based on errno value. This variable should not be accessed
when called function doesn't directly set it.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>