usb: dwc3: add functions to set force mode
[firefly-linux-kernel-4.4.55.git] / drivers / usb / dwc3 / debugfs.c
index 26eb34ce014425c447c1f75ef4772ecb400c88fd..0f7f702bcbeb0dc33be2e858f10add7a36d9aaf6 100644 (file)
@@ -402,11 +402,17 @@ static ssize_t dwc3_mode_write(struct file *file,
        if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
                return -EFAULT;
 
-       if (!strncmp(buf, "host", 4))
+       if (!strncmp(buf, "host", 4)) {
                mode |= DWC3_GCTL_PRTCAP_HOST;
+               dwc3_force_mode(dwc, mode);
+               return count;
+       }
 
-       if (!strncmp(buf, "device", 6))
+       if (!strncmp(buf, "device", 6)) {
                mode |= DWC3_GCTL_PRTCAP_DEVICE;
+               dwc3_force_mode(dwc, mode);
+               return count;
+       }
 
        if (!strncmp(buf, "otg", 3))
                mode |= DWC3_GCTL_PRTCAP_OTG;