UPSTREAM: usb: dwc3: debugfs: Print/set link state for peripheral mode

Current implementation only prints/sets the link state for peripheral
mode only. Check and prevent printing bogus link state if the current
mode of operation is not peripheral.

Change-Id: I0c7d50836a526a78a87c1698de78746420f61c24
Signed-off-by: Thinh Nguyen <thinhn@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: William Wu <william.wu@rock-chips.com>
(cherry picked from commit d102444cac)
This commit is contained in:
Thinh Nguyen
2018-11-07 17:56:23 -08:00
committed by Tao Huang
parent cc99fb0315
commit f28d72c14a

View File

@@ -542,6 +542,13 @@ static int dwc3_link_state_show(struct seq_file *s, void *unused)
u8 speed;
spin_lock_irqsave(&dwc->lock, flags);
reg = dwc3_readl(dwc->regs, DWC3_GSTS);
if (DWC3_GSTS_CURMOD(reg) != DWC3_GSTS_CURMOD_DEVICE) {
seq_puts(s, "Not available\n");
spin_unlock_irqrestore(&dwc->lock, flags);
return 0;
}
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
state = DWC3_DSTS_USBLNKST(reg);
speed = reg & DWC3_DSTS_CONNECTSPD;
@@ -589,6 +596,12 @@ static ssize_t dwc3_link_state_write(struct file *file,
return -EINVAL;
spin_lock_irqsave(&dwc->lock, flags);
reg = dwc3_readl(dwc->regs, DWC3_GSTS);
if (DWC3_GSTS_CURMOD(reg) != DWC3_GSTS_CURMOD_DEVICE) {
spin_unlock_irqrestore(&dwc->lock, flags);
return -EINVAL;
}
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
speed = reg & DWC3_DSTS_CONNECTSPD;