usb: patches to selectively support both slp and functionfs
[platform/adaptation/samsung_exynos/device-manager-plugin-exynos5433.git] / hw / usb_cfs_client / usb_cfs_client.c
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,