aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2014-11-27 16:25:45 -0500
committerFelipe Balbi <balbi@ti.com>2014-12-22 11:25:37 -0500
commite87c3f80ad0490d26ffe04754b7d094463b40f30 (patch)
treedd12c2eb2b2439a5bbcfae0188e6f3c1429e9d02
parentb1d347830d811f3648a52d28700896c6c404d609 (diff)
usb: musb: Fix a few off-by-one lengths
!strncmp(buf, "force host", 9) is true if and only if buf starts with "force hos". This was obviously not what was intended. The same error exists for "force full-speed", "force high-speed" and "test packet". Using strstarts avoids the error-prone hardcoding of the prefix length. For consistency, also change the other occurences of the !strncmp idiom. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/musb/musb_cppi41.c4
-rw-r--r--drivers/usb/musb/musb_debugfs.c16
2 files changed, 10 insertions, 10 deletions
diff --git a/drivers/usb/musb/musb_cppi41.c b/drivers/usb/musb/musb_cppi41.c
index f64fd964dc6d..c39a16ad7832 100644
--- a/drivers/usb/musb/musb_cppi41.c
+++ b/drivers/usb/musb/musb_cppi41.c
@@ -628,9 +628,9 @@ static int cppi41_dma_controller_start(struct cppi41_dma_controller *controller)
628 ret = of_property_read_string_index(np, "dma-names", i, &str); 628 ret = of_property_read_string_index(np, "dma-names", i, &str);
629 if (ret) 629 if (ret)
630 goto err; 630 goto err;
631 if (!strncmp(str, "tx", 2)) 631 if (strstarts(str, "tx"))
632 is_tx = 1; 632 is_tx = 1;
633 else if (!strncmp(str, "rx", 2)) 633 else if (strstarts(str, "rx"))
634 is_tx = 0; 634 is_tx = 0;
635 else { 635 else {
636 dev_err(dev, "Wrong dmatype %s\n", str); 636 dev_err(dev, "Wrong dmatype %s\n", str);
diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c
index 54e8cde9ebd9..48131aa8472c 100644
--- a/drivers/usb/musb/musb_debugfs.c
+++ b/drivers/usb/musb/musb_debugfs.c
@@ -199,30 +199,30 @@ static ssize_t musb_test_mode_write(struct file *file,
199 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) 199 if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
200 return -EFAULT; 200 return -EFAULT;
201 201
202 if (!strncmp(buf, "force host", 9)) 202 if (strstarts(buf, "force host"))
203 test = MUSB_TEST_FORCE_HOST; 203 test = MUSB_TEST_FORCE_HOST;
204 204
205 if (!strncmp(buf, "fifo access", 11)) 205 if (strstarts(buf, "fifo access"))
206 test = MUSB_TEST_FIFO_ACCESS; 206 test = MUSB_TEST_FIFO_ACCESS;
207 207
208 if (!strncmp(buf, "force full-speed", 15)) 208 if (strstarts(buf, "force full-speed"))
209 test = MUSB_TEST_FORCE_FS; 209 test = MUSB_TEST_FORCE_FS;
210 210
211 if (!strncmp(buf, "force high-speed", 15)) 211 if (strstarts(buf, "force high-speed"))
212 test = MUSB_TEST_FORCE_HS; 212 test = MUSB_TEST_FORCE_HS;
213 213
214 if (!strncmp(buf, "test packet", 10)) { 214 if (strstarts(buf, "test packet")) {
215 test = MUSB_TEST_PACKET; 215 test = MUSB_TEST_PACKET;
216 musb_load_testpacket(musb); 216 musb_load_testpacket(musb);
217 } 217 }
218 218
219 if (!strncmp(buf, "test K", 6)) 219 if (strstarts(buf, "test K"))
220 test = MUSB_TEST_K; 220 test = MUSB_TEST_K;
221 221
222 if (!strncmp(buf, "test J", 6)) 222 if (strstarts(buf, "test J"))
223 test = MUSB_TEST_J; 223 test = MUSB_TEST_J;
224 224
225 if (!strncmp(buf, "test SE0 NAK", 12)) 225 if (strstarts(buf, "test SE0 NAK"))
226 test = MUSB_TEST_SE0_NAK; 226 test = MUSB_TEST_SE0_NAK;
227 227
228 musb_writeb(musb->mregs, MUSB_TESTMODE, test); 228 musb_writeb(musb->mregs, MUSB_TESTMODE, test);