On Thursday 23 February 2012 09:34 PM, Tom Warren wrote:
Puneet,

-----Original Message-----
From: Puneet Saxena
Sent: Thursday, February 23, 2012 7:25 AM
To: u-boot@lists.denx.de; s...@chromium.org
Cc: vap...@gentoo.org; Tom Warren; Puneet Saxena
Subject: [PATCH 2/2] usb: Add quirk "USB_QUIRK_STRING_FETCH_255"

Add a quirk "USB_QUIRK_STRING_FETCH_255", borrowed from Linux kernel to
fetch string using descriptor length then fetch actual bytes returned in
descriptor buffer.

Signed-off-by: Puneet Saxena<pune...@nvidia.com>
---
Changes for v2:
    - Add quirk for fetching actual bytes

  common/usb.c                    |    4 ++++
  include/configs/tegra2-common.h |    7 +++++++
  2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/common/usb.c b/common/usb.c index 75926aa..cd85c18 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -660,7 +660,11 @@ static int usb_string_sub(struct usb_device *dev,
unsigned int langid,

        /* Try to read the string descriptor by asking for the maximum
         * possible number of bytes */
+#ifdef USB_QUIRK_STRING_FETCH_255
+       rc = -4;
+#else
        rc = usb_get_string(dev, langid, index, buf, 255);
+#endif

        /* If that failed try to read the descriptor length, then
         * ask for just that many bytes */
diff --git a/include/configs/tegra2-common.h b/include/configs/tegra2-
common.h index 266d0e5..51cc200 100644
--- a/include/configs/tegra2-common.h
+++ b/include/configs/tegra2-common.h
@@ -172,4 +172,11 @@

  #define CONFIG_TEGRA2_GPIO
  #define CONFIG_CMD_GPIO
+
+/*
+ * Imported the quirk from Linux kernel  */
+/* string descriptors must not be fetched using a 255-byte read */
+#define USB_QUIRK_STRING_FETCH_255     0x00000001
+
  #endif /* __TEGRA2_COMMON_H */
--
1.7.1
Make sure you include the USB custodian/expert when submitting USB patches 
(Remy Bohmer, li...@bohmer.net). Also, as TomR says, this should be a 
CONFIG_USB_QUIRK_xxx string. Note that it doesn't need a 0x00000001 - 
#define'ing a switch means it's explicitly enabled - no need for 1 or 0 (see 
all the other CONFIG_ defines in the config headers).

Tom

My thought of adding "#define USB_QUIRK_STRING_FETCH_255 0x00000001" instead "#define USB_QUIRK_STRING_FETCH_255" is, some time in future we might have to implement kernel quirk kind of functionality to make generic
implementation. Its not needed as of now. Will incorporate in next patch.

Thanks,
Puneet

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------
_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to