1
0
Fork 0
mirror of https://github.com/linux-usb-gadgets/libusbgx.git synced 2025-07-13 05:09:43 +03:00
Commit graph

27 commits

Author SHA1 Message Date
Gwenhael Goavec-Merou
45c14ef4d5 libusbgx: fix build with glibc-2.28 since <sys/sysmacros.h> is no more included by <sys/types.h>
Signed-off-by: Sid Spry R030t1@gmail.com
Signed-off-by: Gwenhael Goavec-Merou gwenhael.goavec-merou@trabucayre.com
[Copy sign-offs from pull requst to commit msg]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2018-09-12 15:10:33 +02:00
Krzysztof Opasiak
67aaf8ea7e 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>
2016-12-14 13:23:12 +01:00
Krzysztof Opasiak
3749ccec3d 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>
2016-12-14 13:03:26 +01:00
Krzysztof Opasiak
a23dee0c86 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>
2016-12-13 22:45:06 +01:00
Krzysztof Opasiak
77449edfe0 libusbgx: Add suitable copyrights
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-23 00:49:03 +01:00
Krzysztof Opasiak
98bd3bb016 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>
2015-12-22 21:45:36 +01:00
Krzysztof Opasiak
2f09cdc9b6 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>
2015-12-22 21:45:36 +01:00
Krzysztof Opasiak
bc1bf2e15a 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>
2015-12-22 20:38:48 +01:00
Krzysztof Opasiak
63f3bf5c57 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>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
709c04fab9 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>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
5ab3f47865 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>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
b1aa35521a 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>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
97c6c58b87 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>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
2631010de5 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>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
93ab85191c 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>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
1025541129 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>
2015-12-22 20:35:21 +01:00
Krzysztof Opasiak
9b886d172f 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>
2015-12-22 20:35:20 +01:00
Krzysztof Opasiak
233bdd6575 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>
2015-12-22 20:35:20 +01:00
Krzysztof Opasiak
0f4c36efc3 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>
2015-12-22 20:35:20 +01:00
Krzysztof Opasiak
42c6bc3e56 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>
2015-12-22 20:35:20 +01:00
Krzysztof Opasiak
b44baf9d2e 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>
2015-12-22 20:35:20 +01:00
Krzysztof Opasiak
2a0e2bc756 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>
2015-12-22 20:35:20 +01:00
Krzysztof Opasiak
b8dd6d8f9a libusbgx: Fix gadget-acm-ecm example to cleanup at exit.
Make use of previously unused variable ret to cleanup
after successful gadget creation.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
2015-12-22 20:33:56 +01:00
Matt Porter
1a0f241233 libusbg: use /sys/kernel/config mount point in examples
Update documentation and example source code to reflect use of the
standard /sys/kernel/config mount point for configfs.

Signed-off-by: Matt Porter <mporter@linaro.org>
2014-01-21 07:58:24 -05:00
Matt Porter
14949f6764 libusbg: update preferred email address
Update email address for myself throughout the code.

Signed-off-by: Matt Porter <mporter@linaro.org>
2014-01-21 07:58:24 -05:00
Matt Porter
a371518d64 libusbg: rename gadget_*() -> usbg_*(), libusbg, and usbg.h
Rename library to libusbg. Moves the API include to usbg.h and
accordingly changes all API prefixes to usbg_*().

Signed-off-by: Matt Porter <mporter@linaro.org>
2014-01-21 07:58:24 -05:00
Matt Porter
a6a036a403 Initial release
Signed-off-by: Matt Porter <matt.porter@linaro.org>
2013-09-04 12:51:23 -04:00