diff options
author | Krzysztof Opasiak <k.opasiak@samsung.com> | 2015-04-16 12:31:30 +0200 |
---|---|---|
committer | Krzysztof Opasiak <k.opasiak@samsung.com> | 2015-04-27 10:13:45 +0200 |
commit | dd855cf004ec753dd281f193586e31c0c73b43a9 (patch) | |
tree | 6f874c9fdd096b98edb51caf7b975df163fea267 /src | |
parent | b8e0509c90d51ad6329c4177439b132f05497944 (diff) | |
download | libusbg-dd855cf004ec753dd281f193586e31c0c73b43a9.tar.gz libusbg-dd855cf004ec753dd281f193586e31c0c73b43a9.tar.bz2 libusbg-dd855cf004ec753dd281f193586e31c0c73b43a9.zip |
libusbg: Allow to pass usbg_init() without access to /sys/class/udc
We may would like to use this library on machine where
is no udc support (no /sys/class/udc directory) or
where we don't have sufficient rights to read udc
directory.
This commit adds support for such situation. If we are
running on such machine we will be able to pass usbg_init()
function and manage usb gadgets but we won't be able to bind
gadget to udc as we were unable to read their names.
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
Reviewed-by: Pawel Szewczyk <p.szewczyk@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/usbg.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1354,8 +1354,17 @@ static int usbg_parse_state(usbg_state *s) { int ret = USBG_SUCCESS; + /* + * USBG_ERROR_NOT_FOUND is returned if we are runing on machine where + * there is no udc support in kernel (no /sys/class/udc dir). + * This check allows to run library on such machine or if we don't + * have rights to read this directory. + * User will be able to finish init function and manage gadgets but + * wont be able to bind it as there is no UDC. + */ ret = usbg_parse_udcs(s); - if (ret != USBG_SUCCESS) { + if (ret != USBG_SUCCESS && ret != USBG_ERROR_NOT_FOUND && + ret != USBG_ERROR_NO_ACCESS) { ERROR("Unable to parse udcs"); goto out; } |