All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Scot Doyle <lkml14@scotdoyle.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sarah Sharp <sarah.a.sharp@linux.intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Daniel Mack <daniel@caiaq.de>, <linux-usb@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: core: downgrade log severity to info when descriptor missing
Date: Tue, 23 Sep 2014 10:26:57 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1409231021190.1322-100000@iolanthe.rowland.org> (raw)
In-Reply-To: <alpine.DEB.2.11.1409222012230.1839@localhost.localdomain>

On Mon, 22 Sep 2014, Scot Doyle wrote:

> 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.

This is a good description, but it's not what the patch actually does.

> Signed-off-by: Scot Doyle <lkml14@scotdoyle.com>
> ---
>  drivers/usb/core/message.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
> index 0c8a7fc..6b95de7 100644
> --- a/drivers/usb/core/message.c
> +++ b/drivers/usb/core/message.c
> @@ -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.

>  		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) */

-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.

> +	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.

> +
>  	/* 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


  reply	other threads:[~2014-09-23 14:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-22 20:20 [PATCH] usb: core: downgrade log severity to info when descriptor missing Scot Doyle
2014-09-23 14:26 ` Alan Stern [this message]
2014-09-23 19:06   ` Scot Doyle
2014-09-23 19:12     ` [PATCH v2] usb: core: downgrade log severity to info when descriptor unavailable Scot Doyle
2014-09-24  5:18       ` Greg Kroah-Hartman
2014-09-24 17:56         ` Scot Doyle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.44L0.1409231021190.1322-100000@iolanthe.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=dan.j.williams@intel.com \
    --cc=daniel@caiaq.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lkml14@scotdoyle.com \
    --cc=sarah.a.sharp@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.