summaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/usbstring.c
diff options
context:
space:
mode:
authorMacpaul Lin <macpaul.lin@mediatek.com>2020-06-18 11:13:38 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-06-18 16:07:57 +0200
commit81c7462883b0cc0a4eeef0687f80ad5b5baee5f6 (patch)
tree5f1cb16db49460e9a7947deb8fb65e23a1526cb1 /drivers/usb/gadget/usbstring.c
parentusb: xhci: fix spelling mistake in Kconfig "firwmare" -> "firmware" (diff)
downloadlinux-81c7462883b0cc0a4eeef0687f80ad5b5baee5f6.tar.xz
linux-81c7462883b0cc0a4eeef0687f80ad5b5baee5f6.zip
USB: replace hardcode maximum usb string length by definition
Replace hardcoded maximum USB string length (126 bytes) by definition "USB_MAX_STRING_LEN". Signed-off-by: Macpaul Lin <macpaul.lin@mediatek.com> Acked-by: Alan Stern <stern@rowland.harvard.edu> Link: https://lore.kernel.org/r/1592471618-29428-1-git-send-email-macpaul.lin@mediatek.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/gadget/usbstring.c')
-rw-r--r--drivers/usb/gadget/usbstring.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c
index 58a4d3325090..30f889ad3ad2 100644
--- a/drivers/usb/gadget/usbstring.c
+++ b/drivers/usb/gadget/usbstring.c
@@ -55,9 +55,9 @@ usb_gadget_get_string (const struct usb_gadget_strings *table, int id, u8 *buf)
return -EINVAL;
/* string descriptors have length, tag, then UTF16-LE text */
- len = min ((size_t) 126, strlen (s->s));
+ len = min((size_t)USB_MAX_STRING_LEN, strlen(s->s));
len = utf8s_to_utf16s(s->s, len, UTF16_LITTLE_ENDIAN,
- (wchar_t *) &buf[2], 126);
+ (wchar_t *) &buf[2], USB_MAX_STRING_LEN);
if (len < 0)
return -EINVAL;
buf [0] = (len + 1) * 2;