usb: core: downgrade log severity to info when descriptor missing
PATCH 1/1 usb: core: downgrade log severity to info when descriptor missing
According to commit 0cce2eda19923e5e5ccc8b042dec5af87b3ffad0
USB: fix LANGID=0 regression
usb devices are not required to report string descriptors. Since they are optional, log an info message instead of an error message. In addition, use a higher level info message while moving the details to a debug message.
Tested with USB device 0930:021c.
--- drivers/usb/core/message.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/usb/core/message.c +13 -1
@@ -766,7 +766,7 @@ static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf)/* If the string was reported but is malformed, default to english * (0x0409) */ -if (err == -ENODATA || (err >0 && err <4 )) { +if (err >0 && err <4 ) { dev->string_langid =0x0409 ; dev->have_langid =1 ; dev_err(&dev->dev,
@@ -776,6 +776,18 @@ static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf)return 0 ; } +/* If the string was unavailable, default to english (0x0409) */ +if (err == -ENODATA ) { + dev->string_langid =0x0409 ; + dev->have_langid =1 ; +dev_info (&dev->dev, +"no string descriptor language, defaulting to English" ); +dev_dbg (&dev->dev, +"string descriptor 0 unavailable (err = -ENODATA), " +"defaulting to 0x%04x\n" , dev->string_langid); +return 0 ; + } +/* In case of all other errors, we assume the device is not able to * deal with strings at all. Set string_langid to -1 in order to * prevent any string to be retrieved from the device */
Signature · 1 line
2.1.0
Quoted 8 lines · Scot Doyle
According to commit
0cce2eda19923e5e5ccc8b042dec5af87b3ffad0
USB: fix LANGID=0 regressionusb devices are not required to report string descriptors. Since they are optional, log an info message instead of an error message. In addition, use a higher level info message while moving the details to a debug message.
Tested with USB device 0930:021c.
This is a good description, but it's not what the patch actually does.
Quoted 10 lines
Signed-off-by Scot Doyle <[email protected]>--- drivers/usb/core/message.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)drivers/usb/core/message.c +0
-0
drivers/usb/core/message.c static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf) · line 769
Quoted 5 lines
drivers/usb/core/message.c +1
-1@@ -766,7 +766,7 @@ static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf)/* If the string was reported but is malformed, default to english * (0x0409) */ -if (err == -ENODATA || (err >0 && err <4 )) { +if (err >0 && err <4 ) {
Why treat ENODATA as a separate case? It's just like the others -- the device returned some data, but the data was malformed.
If the device really does not support string descriptors at all, err would be equal to -EPIPE.
drivers/usb/core/message.c static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf) · line 779
Quoted 8 lines
drivers/usb/core/message.c +1
-0dev->string_langid =0x0409 ; dev->have_langid =1 ; dev_err(&dev->dev,@@ -776,6 +776,18 @@ static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf)return 0 ; } +/* If the string was unavailable, default to english (0x0409) */
-ENODATA doesn't mean the string was unavailable. It means that the second byte of the reply was different from USB_DT_STRING, i.e., the reply was malformed.
drivers/usb/core/message.c static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf) · line 789
Quoted 10 lines
drivers/usb/core/message.c +10
-0+if (err == -ENODATA ) { + dev->string_langid =0x0409 ; + dev->have_langid =1 ; +dev_info (&dev->dev, +"no string descriptor language, defaulting to English" ); +dev_dbg (&dev->dev, +"string descriptor 0 unavailable (err = -ENODATA), " +"defaulting to 0x%04x\n" , dev->string_langid); +return 0 ; + }
Therefore this section is completely unnecessary.
drivers/usb/core/message.c static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf) · line 793
Quoted 4 lines
drivers/usb/core/message.c +1
-0+/* In case of all other errors, we assume the device is not able to * deal with strings at all. Set string_langid to -1 in order to * prevent any string to be retrieved from the device */
And down here is where you should call either dev_info() or dev_err(), depending on whether err is equal to -EPIPE or something else.
Alan Stern
Quoted 3 lines · Alan Stern
-ENODATAdoesn't mean the string was unavailable. It means that the second byte of the reply was different fromUSB_DT_STRING, i.e., the reply was malformed.
Thank you for the correction!
Quoted 2 lines
And down here is where you should call either
dev_info()ordev_err(), depending on whether err is equal to-EPIPEor something else.
I hope to send it shortly.
PATCH v2 1/1 usb: core: downgrade log severity to info when descriptor unavailable
According to commit 0cce2eda19923e5e5ccc8b042dec5af87b3ffad0
USB: fix LANGID=0 regression
usb devices are not required to report string descriptors. Since they are optional, log an info message instead of an error message.
--- drivers/usb/core/message.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/core/message.c +6 -2
@@ -780,8 +780,12 @@ static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf)* deal with strings at all. Set string_langid to -1 in order to * prevent any string to be retrieved from the device */ if (err <0 ) { -dev_err (&dev->dev,"string descriptor 0 read error: %d\n" , - err); +if (err == -EPIPE ) +dev_info (&dev->dev, +"string descriptor 0 read error: -EPIPE\n" ); +else +dev_err (&dev->dev, +"string descriptor 0 read error: %d\n" , err); dev->string_langid =-1 ;return -EPIPE ; }
Signature · 1 line
2.1.0
Greg Kroah-Hartman
maintainerRe: [PATCH v2] usb: core: downgrade log severity to info when descriptor unavailable
Quoted 17 lines · Scot Doyle
According to commit
0cce2eda19923e5e5ccc8b042dec5af87b3ffad0
USB: fix LANGID=0 regressionusb devices are not required to report string descriptors. Since they are optional, log an info message instead of an error message.
Signed-off-by Scot Doyle <[email protected]>--- drivers/usb/core/message.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/usb/core/message.c +0
-0@@ -780,8 +780,12 @@ static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf)* deal with strings at all. Set string_langid to -1 in order to
drivers/usb/core/message.c static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf) · line 788
Quoted 10 lines
drivers/usb/core/message.c +6
-2* prevent any string to be retrieved from the device */ if (err <0 ) { -dev_err (&dev->dev,"string descriptor 0 read error: %d\n" , - err); +if (err == -EPIPE ) +dev_info (&dev->dev, +"string descriptor 0 read error: -EPIPE\n" ); +else +dev_err (&dev->dev, +"string descriptor 0 read error: %d\n" , err);
What real difference does this patch make? What would a user do with -EPIPE?
And USB devices _are_ required to provide a string descriptor if they provide a string id, so your changelog body doesn't make much sense. I suggest rewriting it to say they aren't required to provide a string descriptor for string "0".
But even then, I don't understand the goal of this patch.
thanks,
greg k-h
Re: [PATCH v2] usb: core: downgrade log severity to info when descriptor unavailable
Quoted 23 lines · Greg Kroah-Hartman
Quoted 22 lines · Scot Doyle
According to commit
0cce2eda19923e5e5ccc8b042dec5af87b3ffad0
USB: fix LANGID=0 regressionusb devices are not required to report string descriptors. Since they are optional, log an info message instead of an error message.
Signed-off-by Scot Doyle <[email protected]>--- drivers/usb/core/message.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/usb/core/message.c +1
-2@@ -780,8 +780,12 @@ static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf)* deal with strings at all. Set string_langid to -1 in order to * prevent any string to be retrieved from the device */ if (err <0 ) { -dev_err (&dev->dev,"string descriptor 0 read error: %d\n" , - err); +if (err == -EPIPE )
Quoted 8 lines
drivers/usb/core/message.c static int usb_get_langid(struct usb_device *dev, unsigned char *tbuf) · line 788
Quoted 5 lines
drivers/usb/core/message.c +5
-0+dev_info (&dev->dev, +"string descriptor 0 read error: -EPIPE\n" ); + else + dev_err(&dev->dev, + "string descriptor 0 read error: %d\n", err);What real difference does this patch make? What would a user do with
-EPIPE?
Not much difference, except e.g. a log line that isn't red.
Quoted 6 lines
And USB devices _are_ required to provide a string descriptor if they provide a string id, so your changelog body doesn't make much sense. I suggest rewriting it to say they aren't required to provide a string descriptor for string "0".
But even then, I don't understand the goal of this patch.
I'm happy to drop this patch request, since in my case the return value is -ENODATA, which is covered by the other patch: "[RFC PATCH] usb: core: log more general message on malformed LANGID descriptor"