usb: patches to selectively support both slp and functionfs 69/175069/3
authorINSUN PYO <insun.pyo@samsung.com>
Wed, 14 Mar 2018 01:23:57 +0000 (10:23 +0900)
committerPaweł Szewczyk <p.szewczyk@samsung.com>
Mon, 9 Apr 2018 12:23:55 +0000 (14:23 +0200)
If /sys/class/usb_mode/usb0/enable exists, it is slp usb_hal.
Otherwise it is configfs usb_hal.

Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
Change-Id: I8e6b74ffbc6287fe7b5f0a7ab475edff16b2fd88

CMakeLists.txt
hw/usb_cfs_client/CMakeLists.txt [new file with mode: 0644]
hw/usb_cfs_client/usb_cfs_client.c [moved from hw/usb_client/usb_client_configfs.c with 99% similarity]
hw/usb_client/usb_client.c
packaging/device-manager-plugin-artik.spec

index a12e14b..7fab672 100755 (executable)
@@ -10,3 +10,4 @@ ADD_SUBDIRECTORY(hw/led)
 ADD_SUBDIRECTORY(hw/touchscreen)
 ADD_SUBDIRECTORY(hw/usb_gadget)
 ADD_SUBDIRECTORY(hw/usb_client)
+ADD_SUBDIRECTORY(hw/usb_cfs_client)
diff --git a/hw/usb_cfs_client/CMakeLists.txt b/hw/usb_cfs_client/CMakeLists.txt
new file mode 100644 (file)
index 0000000..15e7cbc
--- /dev/null
@@ -0,0 +1,19 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(usb_cfs_client C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(usb_cfs_client_pkgs REQUIRED hwcommon dlog glib-2.0 libsystemd libusbgx)
+
+FOREACH(flag ${usb_cfs_client_pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} MODULE usb_cfs_client.c ../shared.c)
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${usb_cfs_client_pkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR}/hw COMPONENT RuntimeLibraries)
similarity index 99%
rename from hw/usb_client/usb_client_configfs.c
rename to hw/usb_cfs_client/usb_cfs_client.c
index deaafcd..0e76f3b 100644 (file)
@@ -27,6 +27,7 @@
 #include <sys/types.h>
 #include <sys/mount.h>
 #include <usbg/usbg.h>
+#include <unistd.h>
 #include <systemd/sd-bus.h>
 
 #include <unistd.h>
@@ -965,6 +966,10 @@ static int cfs_gadget_open(struct hw_info *info,
        if (!info || !common)
                return -EINVAL;
 
+       /* used exclusively with slp usb_client*/
+       if (!access("/sys/class/usb_mode/usb0/enable", F_OK))
+               return -ENOENT;
+
        cfs_client = zalloc(sizeof(*cfs_client));
        if (!cfs_client)
                return -ENOMEM;
@@ -1031,7 +1036,7 @@ HARDWARE_MODULE_STRUCTURE = {
        .magic = HARDWARE_INFO_TAG,
        .hal_version = HARDWARE_INFO_VERSION,
        .device_version = USB_CLIENT_HARDWARE_DEVICE_VERSION,
-       .id = USB_CLIENT_HARDWARE_DEVICE_ID,
+       .id = USB_CFS_CLIENT_HARDWARE_DEVICE_ID,
        .name = "cfs-gadget",
        .open = cfs_gadget_open,
        .close = cfs_gadget_close,
index df5229a..824e562 100644 (file)
@@ -23,6 +23,7 @@
 #include <limits.h>
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
 #include <systemd/sd-bus.h>
 
 #define zalloc(amount) calloc(1, amount)
@@ -715,6 +716,10 @@ static int legacy_gadget_open(struct hw_info *info,
        if (!info || !common)
                return -EINVAL;
 
+       /* check if slp usb gadget exists */
+       if (access("/sys/class/usb_mode/usb0/enable", F_OK))
+               return -ENOENT;
+
        legacy = zalloc(sizeof(*legacy));
        if (!legacy)
                return -ENOMEM;
index 5feaf0e..7268a6a 100755 (executable)
@@ -16,6 +16,7 @@ BuildRequires:  pkgconfig(libudev)
 BuildRequires:  pkgconfig(capi-system-peripheral-io)
 BuildRequires:  pkgconfig(libusbgx)
 BuildRequires:  pkgconfig(libsystemd)
+BuildRequires:  pkgconfig(libusbgx)
 
 %description
 Device manager plugin artik