diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2011-10-31 22:25:40 +0100 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2011-12-12 10:48:26 +0100 |
commit | 3140e8cbfec18ecb9c9ef856933fdb98c09af1e8 (patch) | |
tree | c4aad9489eabb168e4bf3eaa5006194286a2a158 /drivers/usb/dwc3/debugfs.c | |
parent | usb: dwc3: ep0: don't use ep0in for transfers (diff) | |
download | linux-3140e8cbfec18ecb9c9ef856933fdb98c09af1e8.tar.xz linux-3140e8cbfec18ecb9c9ef856933fdb98c09af1e8.zip |
usb: dwc3: use a helper function for operation mode setting
There are two where need to set operational mode:
- during initialization while we decide to run in host,device or DRD
mode
- at runtime via the debugfs interface.
This patch provides a new function which sets the operational mode and
moves its initialiation to the mode switch instead in the gadget code
itself.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/dwc3/debugfs.c')
-rw-r--r-- | drivers/usb/dwc3/debugfs.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c index b5370e781500..ca4be0afc33d 100644 --- a/drivers/usb/dwc3/debugfs.c +++ b/drivers/usb/dwc3/debugfs.c @@ -443,29 +443,26 @@ static ssize_t dwc3_mode_write(struct file *file, struct seq_file *s = file->private_data; struct dwc3 *dwc = s->private; unsigned long flags; - u32 reg; + u32 mode = 0; char buf[32]; if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) return -EFAULT; - spin_lock_irqsave(&dwc->lock, flags); - reg = dwc3_readl(dwc->regs, DWC3_GCTL); - - reg &= ~(DWC3_GCTL_PRTCAPDIR(DWC3_GCTL_PRTCAP_OTG)); - if (!strncmp(buf, "host", 4)) - reg |= DWC3_GCTL_PRTCAP(DWC3_GCTL_PRTCAP_HOST); + mode |= DWC3_GCTL_PRTCAP_HOST; if (!strncmp(buf, "device", 6)) - reg |= DWC3_GCTL_PRTCAP(DWC3_GCTL_PRTCAP_DEVICE); + mode |= DWC3_GCTL_PRTCAP_DEVICE; if (!strncmp(buf, "otg", 3)) - reg |= DWC3_GCTL_PRTCAP(DWC3_GCTL_PRTCAP_OTG); - - dwc3_writel(dwc->regs, DWC3_GCTL, reg); - spin_unlock_irqrestore(&dwc->lock, flags); + mode |= DWC3_GCTL_PRTCAP_OTG; + if (mode) { + spin_lock_irqsave(&dwc->lock, flags); + dwc3_set_mode(dwc, mode); + spin_unlock_irqrestore(&dwc->lock, flags); + } return count; } |