Skip to content

Commit

Permalink
usb: musb: only set test mode once
Browse files Browse the repository at this point in the history
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: Bin Liu <b-liu@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Bin Liu authored and Felipe Balbi committed Apr 27, 2015
1 parent d72348f commit 205845e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/usb/musb/musb_debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,16 @@ static ssize_t musb_test_mode_write(struct file *file,
{
struct seq_file *s = file->private_data;
struct musb *musb = s->private;
u8 test = 0;
u8 test;
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));

if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
Expand Down

0 comments on commit 205845e

Please sign in to comment.