Re: [RFC 2/9] usb: gadget: OS String support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



W dniu 01.05.2014 03:36, Michal Nazarewicz pisze:
On Thu, Apr 24 2014, Andrzej Pietrasiewicz wrote:
There is a custom (non-USB IF) extension to the USB standard:

http://msdn.microsoft.com/library/windows/hardware/gg463182

<snip>


diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index fab9064..0bfdb14 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -960,6 +960,22 @@ static int get_string(struct usb_composite_dev *cdev,
  		return s->bLength;
  	}

+	if (cdev->use_os_string && language == 0 && id == OS_STRING_IDX) {
+		/*
+		 * bLength|bDescriptorType|qwSignature|bMS_VendorCode|bPad
+		 * ---------------------------------------------------------
+		 * 1 Byte |1 Byte	  |14 Bytes   |1 Byte	     |1 Byte
+		 * ---------------------------------------------------------
+		 */

It would be better to have a structure defined for this.

+		u8 *b = buf;
+		b[0] = 0x12;
+		b[1] = USB_DT_STRING;
+		memcpy(&b[2], cdev->qw_sign, OS_STRING_QW_SIGN_LEN);
+		b[2 + OS_STRING_QW_SIGN_LEN] = cdev->b_vendor_code;
+		b[3 + OS_STRING_QW_SIGN_LEN] = 0;
+		return 0x12;
+	}
+

The purpose of get_string() is to fill in the passed buf which is interpreted
as a string. The "OS String" is, indeed, a string ;)
Do I get it right that you suggest creating a struct and then memcpy'ing it
to the destination buffer?

Something on the lines of:

struct usb_os_string {
	__u8	bLength;
	__u8	bDescriptorType;
	__u8	qwSignature[OS_STRING_QW_SIGN_LEN];
	__u8	bMS_VendorCode;
	__u8	bPad;
} __attribute__ ((packed));

And then have cdev have a struct usb_os_string member instead of
qw_sign and b_vendor_code?

AP


--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux