platform/upstream/libusbg.git
7 years agolibsubgx: common: Allow to export dev_t attribute using libconfig
Krzysztof Opasiak [Fri, 16 Dec 2016 11:58:41 +0000 (12:58 +0100)]
libsubgx: common: Allow to export dev_t attribute using libconfig

Add a helper to export dev_t attributes to gadget schemes using
libconfig syntax.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: common: Add function for reading dev_t from ConfigFS
Krzysztof Opasiak [Fri, 16 Dec 2016 11:58:12 +0000 (12:58 +0100)]
libusbgx: common: Add function for reading dev_t from ConfigFS

As some of kernel functions expose details about device node
which is assigned to this instance in form:
      <major>:<minor>
Let's add a convenient helper which will read those values
form file and convert them to dev_t.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: common: Use fread() instead of fgets()
Krzysztof Opasiak [Fri, 16 Dec 2016 11:57:47 +0000 (12:57 +0100)]
libusbgx: common: Use fread() instead of fgets()

Reading binary data using fgets() may not be a good idea due
to \0 byte in the middle of data. Let's fix this by using fread()
instead of fgets().

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: common: Use fwrite() instead of fputs()
Krzysztof Opasiak [Fri, 16 Dec 2016 11:54:25 +0000 (12:54 +0100)]
libusbgx: common: Use fwrite() instead of fputs()

Using fputs() for writing binary data is not a good idea as \0
byte can be in the middle of our data. Let's just use fwrite()
instead.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: examples: Print strings in all available languages
Krzysztof Opasiak [Thu, 15 Dec 2016 16:24:36 +0000 (17:24 +0100)]
libusbgx: examples: Print strings in all available languages

Instead of printing strings only in US_EN let's make a use of
our new function and print all available strings.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Simplify strings handling in libconfig schemes
Krzysztof Opasiak [Thu, 15 Dec 2016 19:40:08 +0000 (20:40 +0100)]
libusbgx: Simplify strings handling in libconfig schemes

Make use of usbg_get_gadget_strs_langs() and
usbg_get_config_strs_langs() in libconfig schemes instead of
direct listing content of directory using scandir().

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Add usbg_get_config_str_langs()
Krzysztof Opasiak [Thu, 15 Dec 2016 16:08:13 +0000 (17:08 +0100)]
libusbgx: Add usbg_get_config_str_langs()

Add a function which allows to get the list of languages
in which config strings are currently available.

Thanks to this function now we may iterate through all strings
languages available in particular config and print their values.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Add usbg_get_gadget_strs_langs()
Krzysztof Opasiak [Thu, 15 Dec 2016 15:18:06 +0000 (16:18 +0100)]
libusbgx: Add usbg_get_gadget_strs_langs()

Add a function which allows to get the list of languages
in which gadget strings are currently available.

Thanks to this function now we may iterate through all strings
languages available in particular gadget and print their values
for each language.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Get rid of static buffers from usbg_config_strs
Krzysztof Opasiak [Thu, 15 Dec 2016 11:24:58 +0000 (12:24 +0100)]
libusbgx: Get rid of static buffers from usbg_config_strs

Remove static buffers which limits strings length from
usbg_config_strs.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Add usbg_free_config_strs()
Krzysztof Opasiak [Thu, 15 Dec 2016 10:47:26 +0000 (11:47 +0100)]
libusbgx: Add usbg_free_config_strs()

This is a first step to get rid of static buffers from usbg_config_strs.

This function should be called to release memory allocated for
configuration string.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Get rid of static buffers from usbg_gadget_strs
Krzysztof Opasiak [Wed, 14 Dec 2016 16:01:51 +0000 (17:01 +0100)]
libusbgx: Get rid of static buffers from usbg_gadget_strs

Remove static buffers which limits strings length from usbg_gadget_strs.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: common: Fix usbg_read_string_alloc() to read long strings correctly
Krzysztof Opasiak [Wed, 14 Dec 2016 15:59:43 +0000 (16:59 +0100)]
libusbgx: common: Fix usbg_read_string_alloc() to read long strings correctly

Use usbg_read_string_limited() directly to avoid length limit
hidden in usbg_read_string().

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Add usbg_free_gadget_strs()
Krzysztof Opasiak [Wed, 14 Dec 2016 15:01:37 +0000 (16:01 +0100)]
libusbgx: Add usbg_free_gadget_strs()

This is a first step to get rid of static buffers in usbg_gadget_strs.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Keep gadget strs in the same order as in device desc
Krzysztof Opasiak [Wed, 14 Dec 2016 12:29:41 +0000 (13:29 +0100)]
libusbgx: Keep gadget strs in the same order as in device desc

Let's keep gadget strings in the same order as they appear
in USB device descriptor to avoid mistakes during structure
initialization.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Use string name similar to USB spec
Krzysztof Opasiak [Wed, 14 Dec 2016 12:23:12 +0000 (13:23 +0100)]
libusbgx: Use string name similar to USB spec

str_ser, str_prd and str_mnf are a little bit weird names
so let's replace them with names defined by USB spec.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: tests: Fix indent and line length
Krzysztof Opasiak [Wed, 14 Dec 2016 12:09:26 +0000 (13:09 +0100)]
libusbgx: tests: Fix indent and line length

Let's keep our lines not longer than 80 characters
and fix also indentation for function params.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Remove typedefs for public structures
Krzysztof Opasiak [Wed, 14 Dec 2016 12:03:26 +0000 (13:03 +0100)]
libusbgx: Remove typedefs for public structures

Let's remove typedefs from public structures to clearly
indicate users which structures can be accessed and which
should be used only as handles.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Use suitable prefix for usbg_function_type enum
Krzysztof Opasiak [Tue, 13 Dec 2016 21:40:05 +0000 (22:40 +0100)]
libusbgx: Use suitable prefix for usbg_function_type enum

Let's use USBG_ prefix for usbg_function_type enum values
to avoid users confusion.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Use suitable prefix for usbg_gadget_str enum
Krzysztof Opasiak [Tue, 13 Dec 2016 21:00:26 +0000 (22:00 +0100)]
libusbgx: Use suitable prefix for usbg_gadget_str enum

Let's use USBG_ prefix for usbg_gadget_str enum values
to avoid users confusion.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Use suitable prefix for usbg_gadget_attr enum
Krzysztof Opasiak [Tue, 13 Dec 2016 20:53:41 +0000 (21:53 +0100)]
libusbgx: Use suitable prefix for usbg_gadget_attr enum

Let's use USBG_ prefix for usbg_gadget_attr enum values
to avoid users confusion

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Move internal defines to a suitable heder
Krzysztof Opasiak [Tue, 6 Dec 2016 13:20:57 +0000 (14:20 +0100)]
libusbgx: Move internal defines to a suitable heder

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: fix: Add missing include in usb_common.c
Fabian Vogt [Fri, 2 Dec 2016 11:08:14 +0000 (12:08 +0100)]
libusbgx: fix: Add missing include in usb_common.c

snprintf is used multiple times in usb_common.c,
but it did not include stdio.h before.

Signed-off-by: Fabian Vogt <fvogt@suse.com>
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
7 years agolibusbgx: Add missing cpp guards
Krzysztof Opasiak [Tue, 6 Dec 2016 11:20:54 +0000 (12:20 +0100)]
libusbgx: Add missing cpp guards

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agoRemove redundant assignments
Krzysztof Opasiak [Wed, 5 Oct 2016 20:12:11 +0000 (22:12 +0200)]
Remove redundant assignments

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolicense: move COPYING file to the example package
taeyoung [Wed, 31 Aug 2016 09:11:58 +0000 (18:11 +0900)]
license: move COPYING file to the example package

- COPYING file is for the GPL-2.0.
- Library is under LGPL-2.1 and the example apps are under GPL-2.0.
  Thus COPYING is moved to the example package

Change-Id: I03810ef8adec37f6d1d943e9d1994cb4e765d315
Signed-off-by: taeyoung <ty317.kim@samsung.com>
[Ported from review.tizen.org]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Allow building without examples
John Keeping [Tue, 12 Jul 2016 12:26:47 +0000 (13:26 +0100)]
libusbgx: Allow building without examples

When just using the library, the examples are not needed, so provide a
way to avoid building and installing them.

Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: fix INSERT_TAILQ_STRING_ORDER
Nicolas Saenz Julienne [Tue, 23 Feb 2016 23:14:25 +0000 (23:14 +0000)]
libusbgx: fix INSERT_TAILQ_STRING_ORDER

If inserting a node in the middle of a list that's long enough (> 3) the macro
will add the node in the right spot and then step on the rest of entries until
the end.

Signed-off-by: Nicolas Saenz Julienne <nicolassaenzj@gmail.com>
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: loopback: Fix loopback function name
Krzysztof Opasiak [Tue, 26 Jan 2016 10:13:48 +0000 (11:13 +0100)]
libusbgx: loopback: Fix loopback function name

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix pkgconfig to link correct library
Krzysztof Opasiak [Mon, 25 Jan 2016 18:58:34 +0000 (19:58 +0100)]
libusbgx: Fix pkgconfig to link correct library

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: ms: fix: Use correct variable to check function result
Krzysztof Opasiak [Mon, 25 Jan 2016 15:37:35 +0000 (16:37 +0100)]
libusbgx: ms: fix: Use correct variable to check function result

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: fix: Add missing includes
Krzysztof Opasiak [Mon, 25 Jan 2016 15:37:00 +0000 (16:37 +0100)]
libusbgx: fix: Add missing includes

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Remove unused out label in usbg_set_function_attrs()
Krzysztof Opasiak [Mon, 25 Jan 2016 15:36:11 +0000 (16:36 +0100)]
libusbgx: Remove unused out label in usbg_set_function_attrs()

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Make usbg_cleanup_function() return void
Krzysztof Opasiak [Mon, 25 Jan 2016 15:35:26 +0000 (16:35 +0100)]
libusbgx: Make usbg_cleanup_function() return void

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Remove unused out label
Krzysztof Opasiak [Mon, 25 Jan 2016 15:22:55 +0000 (16:22 +0100)]
libusbgx: Remove unused out label

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: net: Fix ether addr importing
Krzysztof Opasiak [Mon, 25 Jan 2016 15:18:17 +0000 (16:18 +0100)]
libusbgx: net: Fix ether addr importing

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: fix: Install also function-specific headers
Krzysztof Opasiak [Wed, 23 Dec 2015 10:42:21 +0000 (11:42 +0100)]
libusbgx: fix: Install also function-specific headers

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Release libusbgx version 0.1.0 libusbgx-v0.1.0
Krzysztof Opasiak [Tue, 22 Dec 2015 23:39:11 +0000 (00:39 +0100)]
libusbgx: Release libusbgx version 0.1.0

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add suitable copyrights
Krzysztof Opasiak [Tue, 22 Dec 2015 23:31:52 +0000 (00:31 +0100)]
libusbgx: Add suitable copyrights

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Use rmdir() instead of unlink() for directories
Krzysztof Opasiak [Tue, 22 Dec 2015 16:22:17 +0000 (17:22 +0100)]
libusbgx: Use rmdir() instead of unlink() for directories

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Update tests to use *_s() functions
Krzysztof Opasiak [Tue, 22 Dec 2015 14:06:06 +0000 (15:06 +0100)]
libusbgx: tests: Update tests to use *_s() functions

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Replace *_cpy_*() functions with *_s() convention
Krzysztof Opasiak [Tue, 22 Dec 2015 14:05:51 +0000 (15:05 +0100)]
libusbgx: Replace *_cpy_*() functions with *_s() convention

Instead of having _cpy_ and _len function for getting
each string value let's use *_s() which behave like snprintf()
family.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Refactor the core code to be more readable
Krzysztof Opasiak [Tue, 22 Dec 2015 13:05:49 +0000 (14:05 +0100)]
libusbgx: Refactor the core code to be more readable

Let's use more kernel-like convention to make gadget
code more readable.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Port all tests to new API
Krzysztof Opasiak [Mon, 21 Dec 2015 22:43:57 +0000 (23:43 +0100)]
libusbgx: tests: Port all tests to new API

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: examples: Port all examples to new API
Krzysztof Opasiak [Tue, 22 Dec 2015 23:04:29 +0000 (00:04 +0100)]
libusbgx: examples: Port all examples to new API

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Switch to a new function API
Krzysztof Opasiak [Mon, 21 Dec 2015 21:51:53 +0000 (22:51 +0100)]
libusbgx: Switch to a new function API

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: ms: Add implementation of function specific API
Krzysztof Opasiak [Tue, 22 Dec 2015 22:22:47 +0000 (23:22 +0100)]
libusbgx: ms: Add implementation of function specific API

Implement all function-specific functions from header file

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Update tests to read params in correct orders
Krzysztof Opasiak [Thu, 10 Dec 2015 21:43:38 +0000 (22:43 +0100)]
libusbgx: tests: Update tests to read params in correct orders

Oreder of rading parameters from ConfigFS by net function has
changed, so let's update also related tests cases.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: net: Add implementation of function specific API
Krzysztof Opasiak [Tue, 22 Dec 2015 21:47:05 +0000 (22:47 +0100)]
libusbgx: net: Add implementation of function specific API

Implement all function-specific functions from header file

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: midi: Add implementation of function specific API
Krzysztof Opasiak [Tue, 22 Dec 2015 21:45:59 +0000 (22:45 +0100)]
libusbgx: midi: Add implementation of function specific API

Implement all function-specific functions from header file

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: loopback: Add implementation of function specific API
Krzysztof Opasiak [Tue, 22 Dec 2015 21:44:17 +0000 (22:44 +0100)]
libusbgx: loopback: Add implementation of function specific API

Implement all function-specific functions from header file

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: serial: Add implementation of function specific API
Krzysztof Opasiak [Tue, 22 Dec 2015 21:43:10 +0000 (22:43 +0100)]
libusbgx: serial: Add implementation of function specific API

Implement all function-specific functions from header file

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: phonet: Add implementation of function specific API
Krzysztof Opasiak [Tue, 22 Dec 2015 21:42:12 +0000 (22:42 +0100)]
libusbgx: phonet: Add implementation of function specific API

Implement all function-specific functions from header file

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: ffs: Add implementation of function specific API
Krzysztof Opasiak [Tue, 22 Dec 2015 21:41:37 +0000 (22:41 +0100)]
libusbgx: ffs: Add implementation of function specific API

Implement all function-specific functions from header file

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: common: Add alloc_inst() and free_inst() callbacks
Krzysztof Opasiak [Tue, 22 Dec 2015 22:13:44 +0000 (23:13 +0100)]
libusbgx: common: Add alloc_inst() and free_inst() callbacks

Those callback can be used by specific function type to allocate
and then free more memory than in raw usbg_function structure.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: common: Add helper for getting and setting bool values
Krzysztof Opasiak [Mon, 21 Dec 2015 20:43:15 +0000 (21:43 +0100)]
libusbgx: common: Add helper for getting and setting bool values

Add helper functions which allows to get and set bool values
from both configfs and libconfig files.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: common: Add helper for getting and setting ether addr
Krzysztof Opasiak [Tue, 22 Dec 2015 21:47:14 +0000 (22:47 +0100)]
libusbgx: common: Add helper for getting and setting ether addr

Add helper functions which allows to get and set ether addr
from both configfs and libconfig files.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: common: Add helper for getting and setting string values
Krzysztof Opasiak [Tue, 22 Dec 2015 22:36:59 +0000 (23:36 +0100)]
libusbgx: common: Add helper for getting and setting string values

Add helper functions which allows to get and set string values
from both configfs and libconfig files.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: common: Add helper for getting and setting dec values
Krzysztof Opasiak [Tue, 22 Dec 2015 22:36:48 +0000 (23:36 +0100)]
libusbgx: common: Add helper for getting and setting dec values

Add helper functions which allows to get and set int values
from both configfs and libconfig files.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: common: Add functions for reading string with limited length
Krzysztof Opasiak [Wed, 9 Dec 2015 21:16:05 +0000 (22:16 +0100)]
libusbgx: common: Add functions for reading string with limited length

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: ms: Define new API for mass storage function
Krzysztof Opasiak [Tue, 22 Dec 2015 11:29:13 +0000 (12:29 +0100)]
libusbgx: ms: Define new API for mass storage function

As mass storage support has been separated form main
library file we may now define function-specific
API for better support of this function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: serial: Define new API for serial functions
Krzysztof Opasiak [Tue, 22 Dec 2015 22:00:04 +0000 (23:00 +0100)]
libusbgx: serial: Define new API for serial functions

As serial functions support has been separated form main
library file we may now define function-specific
API for better support of this function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: phonet: Define new API for phonet function
Krzysztof Opasiak [Tue, 22 Dec 2015 21:59:56 +0000 (22:59 +0100)]
libusbgx: phonet: Define new API for phonet function

As phonet support has been separated form main
library file we may now define function-specific
API for better support of this function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: net: Define new API for net functions
Krzysztof Opasiak [Tue, 22 Dec 2015 21:59:50 +0000 (22:59 +0100)]
libusbgx: net: Define new API for net functions

As net functions support has been separated form main
library file we may now define function-specific
API for better support of this function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: midi: Define new API for midi function
Krzysztof Opasiak [Tue, 22 Dec 2015 21:59:44 +0000 (22:59 +0100)]
libusbgx: midi: Define new API for midi function

As midi support has been separated form main
library file we may now define function-specific
API for better support of this function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: loopback: Define new API for loopback function
Krzysztof Opasiak [Tue, 22 Dec 2015 21:59:38 +0000 (22:59 +0100)]
libusbgx: loopback: Define new API for loopback function

As loopback support has been separated form main
library file we may now define function-specific
API for better support of this function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: ffs: Define new API for functionfs function
Krzysztof Opasiak [Tue, 22 Dec 2015 21:59:28 +0000 (22:59 +0100)]
libusbgx: ffs: Define new API for functionfs function

As functionfs support has been separated form main
library file we may now define function-specific
API for better support of this function.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add internal API for defining function types
Krzysztof Opasiak [Tue, 22 Dec 2015 23:17:25 +0000 (00:17 +0100)]
libusbgx: Add internal API for defining function types

Adding support for a new function type was quite complicated.
Moreover the main library source fail was growing realy fast.

As a solution introduce internal OO API for defining function.
Thanks to this support for each function may be placed in
a separate file.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Move some common functions to a separate file
Krzysztof Opasiak [Tue, 22 Dec 2015 21:29:32 +0000 (22:29 +0100)]
libusbgx: Move some common functions to a separate file

Main library file is definitely too big so let's move
some common functions into a separate file.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Move error-ralted functions to a separate file
Krzysztof Opasiak [Tue, 22 Dec 2015 21:27:43 +0000 (22:27 +0100)]
libusbgx: Move error-ralted functions to a separate file

Main library file is definitely too big so let's move
some error-related functions into a separate file.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: packaging: Add packaging for generating rpm package.
Krzysztof Opasiak [Tue, 22 Dec 2015 23:17:08 +0000 (00:17 +0100)]
libusbgx: packaging: Add packaging for generating rpm package.

Change-Id: I69eb6b752e35e0a718cce06b1634ece376c2bcb4
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix memory leak in usbg_set_function_ms_attrs()
Krzysztof Opasiak [Thu, 19 Nov 2015 10:09:43 +0000 (11:09 +0100)]
libusbgx: Fix memory leak in usbg_set_function_ms_attrs()

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add support for importing/exporting loopback function
Krzysztof Opasiak [Mon, 21 Sep 2015 18:58:18 +0000 (20:58 +0200)]
libusbgx: Add support for importing/exporting loopback function

Now it is also possible to use loopback function in gadget
schemes.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add support for loopback function.
Krzysztof Opasiak [Mon, 21 Sep 2015 18:56:02 +0000 (20:56 +0200)]
libusbgx: Add support for loopback function.

Now it is also possible to create and manage loopback
function using libusbgx library.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Add missing test cases
Pawel Szewczyk [Thu, 20 Aug 2015 09:18:04 +0000 (11:18 +0200)]
libusbgx: tests: Add missing test cases

Some test functions are not executed at all. This commit fix it.

Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Add tests for gadget strings enum
Pawel Szewczyk [Wed, 19 Aug 2015 11:59:05 +0000 (13:59 +0200)]
libusbgx: tests: Add tests for gadget strings enum

Test recently added functions using usbg_gadget_str enum.

Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add enum for gadget strings
Pawel Szewczyk [Mon, 6 Jul 2015 12:12:06 +0000 (14:12 +0200)]
libusbgx: Add enum for gadget strings

This commit provides functionality for gadget strings similar to
existing gadget attributes api. It allows to iterate over gadget
strings and to write cleaner and more flexible code.

Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add USBG_ERROR_NOT_EMPTY error code
Pawel Szewczyk [Mon, 6 Jul 2015 11:13:57 +0000 (13:13 +0200)]
libusbgx: Add USBG_ERROR_NOT_EMPTY error code

ENOTEMPTY error is common when removing configfs objects. This commit
adds proper error message and internal usbg error code for this
situation.

Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Add create function test
Pawel Szewczyk [Mon, 25 May 2015 13:11:28 +0000 (15:11 +0200)]
libusbgx: tests: Add create function test

Change-Id: I3a47f0d16b9259f09bb4ea3eeb3734a89af43019
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Add getting function attributes tests
Pawel Szewczyk [Mon, 25 May 2015 13:11:24 +0000 (15:11 +0200)]
libusbgx: tests: Add getting function attributes tests

Change-Id: Ia82f5f124e7b57c2694c605ddc942513fc337645
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Add assertions for function attributes
Pawel Szewczyk [Thu, 28 May 2015 10:32:50 +0000 (12:32 +0200)]
libusbgx: tests: Add assertions for function attributes

Change-Id: Idfc179ff08a0d23b73ca0f30519bbc73f6556e10
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Add creating configuration test
Pawel Szewczyk [Thu, 28 May 2015 10:31:17 +0000 (12:31 +0200)]
libusbgx: tests: Add creating configuration test

Change-Id: I0e5c09b5664f8e15d9ba70e9a5682992341e0884
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Add framework setup for creating config
Pawel Szewczyk [Thu, 19 Feb 2015 13:12:30 +0000 (14:12 +0100)]
libusbgx: tests: Add framework setup for creating config

Change-Id: I19b4777e9b61c7dc63c8bb0644de2a63089e6bd3
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Move initialization from for_each functions to tests
Pawel Szewczyk [Tue, 26 May 2015 08:46:49 +0000 (10:46 +0200)]
libusbgx: tests: Move initialization from for_each functions to tests

Instead of passing void **state as argument for for_each_* functions and
initializing state there, we make initialization first and pass initialized
state as argument for them. It looks more natural this way. This also
allows to run these functions multiple times in single test function.

Change-Id: If84bbedf374f1f0ebf70315cea950dcd2e527d18
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Separate safe state initialization from tests
Pawel Szewczyk [Tue, 26 May 2015 08:04:41 +0000 (10:04 +0200)]
libusbgx: tests: Separate safe state initialization from tests

Test functions usually need to initialize usbg state before testing.
However, initialization may fail, causing test to finish immediatelly,
running teardown function.

This commit add function which takes care of state pointer when
initializing.

Change-Id: I797e56ac3cda67e871c6c4fbd2184220b05068f6
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Add macros for structures definitions
Pawel Szewczyk [Tue, 5 May 2015 13:23:25 +0000 (15:23 +0200)]
libusbgx: tests: Add macros for structures definitions

To avoid defining the same or similar values multiple times, we can define
data by proper macros.

Change-Id: I8fa5fd02c76f16a1b9d65a33482a6cd1caa16b70
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Separate common code of gadget testing
Pawel Szewczyk [Tue, 5 May 2015 09:49:01 +0000 (11:49 +0200)]
libusbgx: tests: Separate common code of gadget testing

Most gadget tests run the same initialization and loop through all
gadgets, performing single operation on them and checking results.
Common code is now separated to for_each_test_gadget function.

Change-Id: I0a1870487aa0c25153c96e57da5501e1bccb8132
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Add wrappers for safe allocation
Pawel Szewczyk [Thu, 30 Apr 2015 11:50:57 +0000 (13:50 +0200)]
libusbgx: tests: Add wrappers for safe allocation

Every allocation here requires checking if it was successful and
storing it on queue to be freed later. Now it can all be done by single
function call.

Change-Id: I06c0099d0b44cb030b6ab8e338ccd58e078a92ac
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: tests: Use new version of cmocka
Pawel Szewczyk [Tue, 19 May 2015 09:30:00 +0000 (11:30 +0200)]
libusbgx: tests: Use new version of cmocka

Deprecated functions of cmocka are no longer used.

Change-Id: If8804103492b089cf033a35d055260452553638e
Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: schemes: Allow to import midi function
Pawel Szewczyk [Tue, 19 May 2015 10:42:01 +0000 (12:42 +0200)]
libusbgx: schemes: Allow to import midi function

Add support for importing midi function from gadget scheme.

Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: schemes: Allow to export midi function
Pawel Szewczyk [Tue, 19 May 2015 15:33:49 +0000 (17:33 +0200)]
libusbgx: schemes: Allow to export midi function

Add support for exporting midi function to gadget scheme.

Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: examples: Use digital format for bMaxPacketSize0
Krzysztof Opasiak [Tue, 19 May 2015 15:26:48 +0000 (17:26 +0200)]
libusbgx: examples: Use digital format for bMaxPacketSize0

bMaxPacketSize0 is maximal size of packet which can be
used for communication with ep0. As most people use digital
format for size, lets use digital format for both
initialization of this member in gadget atributes and for
printing it in show-gadgets.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: examples: Print bcdUSB and bcdDevice as BCD not HEX
Krzysztof Opasiak [Tue, 19 May 2015 14:53:04 +0000 (16:53 +0200)]
libusbgx: examples: Print bcdUSB and bcdDevice as BCD not HEX

bcdUSB and bcdDevice members should be interpreted as BCD.
So let's print them as BCD instea of HEX.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: examples: Print gadget data in the same order as lsusb.
Krzysztof Opasiak [Tue, 19 May 2015 14:31:42 +0000 (16:31 +0200)]
libusbgx: examples: Print gadget data in the same order as lsusb.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: examples: Make examples easier to read
Krzysztof Opasiak [Tue, 19 May 2015 14:15:36 +0000 (16:15 +0200)]
libusbgx: examples: Make examples easier to read

Use the same order of structure initialization in all
examples.

Initialize gadget attributes and strings using:
.member = val,
syntax to make examples easier to read.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Allow to pass NULL as name to usbg_add_config_function()
Krzysztof Opasiak [Tue, 19 May 2015 13:02:15 +0000 (15:02 +0200)]
libusbgx: Allow to pass NULL as name to usbg_add_config_function()

Somtimes we would like to add function to configuration
without any extraordinary name. In that case we can simply
use type.instance as symlink name.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: examples: add example of midi function usage
Pawel Szewczyk [Tue, 19 May 2015 08:48:11 +0000 (10:48 +0200)]
libusbgx: examples: add example of midi function usage

Support for midi function was recently added. This commit adds an example
program which shows how to create midi gadget with this function.

Signed-off-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Update show-gadgets example to support MIDI gadgets
Dominic Sacré [Tue, 12 May 2015 08:19:22 +0000 (10:19 +0200)]
libusbgx: Update show-gadgets example to support MIDI gadgets

Signed-off-by: Dominic Sacré <dominic.sacre@gmx.de>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Add support for MIDI function
Dominic Sacré [Mon, 11 May 2015 12:45:10 +0000 (14:45 +0200)]
libusbgx: Add support for MIDI function

Signed-off-by: Dominic Sacré <dominic.sacre@gmx.de>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Fix usbg_parse_function_midi_attrs() to store qlen value
in qlen member of attrs struct instead of in buflen

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Mark char pointers in usbg_*_attrs as const
Dominic Sacré [Mon, 11 May 2015 16:28:47 +0000 (18:28 +0200)]
libusbgx: Mark char pointers in usbg_*_attrs as const

These attributes are const as far as a library user is concerned.
This change allows attributes to be cleanly initialized from string
literals.

Signed-off-by: Dominic Sacré <dominic.sacre@gmx.de>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
8 years agolibusbgx: Fix warnings when compiling with -Wall
Dominic Sacré [Mon, 11 May 2015 15:56:50 +0000 (17:56 +0200)]
libusbgx: Fix warnings when compiling with -Wall

Remove unused variables and duplicate const specifiers.
This makes libusbgx compile cleanly using -Wall with both gcc and clang.

Signed-off-by: Dominic Sacré <dominic.sacre@gmx.de>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
[Update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>