Skip to content
Snippets Groups Projects
Commit 205845ef authored by Bin Liu's avatar Bin Liu Committed by Felipe Balbi
Browse files

usb: musb: only set test mode once


The MUSB test mode register can only be set once, otherwise the result
is undefined.

This prevents the debugfs testmode entry to set the register more than
once which causes test failure.

Signed-off-by: default avatarBin Liu <b-liu@ti.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent d72348fb
No related branches found
No related tags found
No related merge requests found
...@@ -191,9 +191,16 @@ static ssize_t musb_test_mode_write(struct file *file, ...@@ -191,9 +191,16 @@ static ssize_t musb_test_mode_write(struct file *file,
{ {
struct seq_file *s = file->private_data; struct seq_file *s = file->private_data;
struct musb *musb = s->private; struct musb *musb = s->private;
u8 test = 0; u8 test;
char buf[18]; char buf[18];
test = musb_readb(musb->mregs, MUSB_TESTMODE);
if (test) {
dev_err(musb->controller, "Error: test mode is already set. "
"Please do USB Bus Reset to start a new test.\n");
return count;
}
memset(buf, 0x00, sizeof(buf)); memset(buf, 0x00, sizeof(buf));
if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment