Re: [PATCH] usb: replace hardcoded maximum usb string length by definition

From: Alan Stern
Date: Fri Jun 12 2020 - 10:02:15 EST


On Fri, Jun 12, 2020 at 01:32:47PM +0800, Macpaul Lin wrote:
> Replace hardcoded maximum usb string length (126 bytes) by definition
> "MAX_USB_STRING_LEN".
>
> Signed-off-by: Macpaul Lin <macpaul.lin@xxxxxxxxxxxx>

...

> diff --git a/include/linux/usb.h b/include/linux/usb.h
> index 9f3c721..df4a9cb 100644
> --- a/include/linux/usb.h
> +++ b/include/linux/usb.h
> @@ -1815,6 +1815,8 @@ static inline int usb_get_ptm_status(struct usb_device *dev, void *data)
> 0, data);
> }
>
> +/* USB String descriptors can contain at most 126 characters. */
> +#define MAX_USB_STRING_LEN 126

This definition belongs in include/uapi/linux/usb/ch9.h (near the
definition of struct usb_string_descriptor) because it is part of the USB
standard rather than specific to the Linux USB stack.

Alan Stern