Re: [PATCH 2/8] usb: gadget: OS String support

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

 



On Tue, May 06 2014, Andrzej Pietrasiewicz wrote:
> Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>

Acked-by: Michal Nazarewicz <mina86@xxxxxxxxxx>

> ---
>  drivers/usb/gadget/composite.c | 27 +++++++++++++++++++++++++++
>  include/linux/usb/composite.h  | 11 +++++++++++
>  2 files changed, 38 insertions(+)
>
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index fab9064..4e8aaa6 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -21,6 +21,22 @@
>  #include <linux/usb/composite.h>
>  #include <asm/unaligned.h>
>  
> +/**
> + * struct usb_os_string - represents OS String to be reported by a gadget
> + * @bLength: total length of the entire descritor, always 0x12
> + * @bDescriptorType: USB_DT_STRING
> + * @qwSignature: the OS String proper
> + * @bMS_VendorCode: code used by the host for subsequent requests
> + * @bPad: not used

“not used” or “not used, must be zero”?  I'd prefer the latter to be stated.

> + */
> +struct usb_os_string {
> +	__u8	bLength;
> +	__u8	bDescriptorType;
> +	__u8	qwSignature[OS_STRING_QW_SIGN_LEN];
> +	__u8	bMS_VendorCode;
> +	__u8	bPad;
> +} __packed;
> +
>  /*
>   * The code in this file is utility code, used to build a gadget driver
>   * from one or more "function" drivers, one or more "configuration"
> @@ -960,6 +976,17 @@ static int get_string(struct usb_composite_dev *cdev,
>  		return s->bLength;
>  	}
>  
> +	if (cdev->use_os_string && language == 0 && id == OS_STRING_IDX) {
> +		struct usb_os_string *b = buf;
> +		b->bLength = sizeof(*b);
> +		b->bDescriptorType = USB_DT_STRING;
> +		BUG_ON(sizeof(b->qwSignature) != sizeof(cdev->qw_sign));

BUG_ON is a runtime construct.  compiletime_assert would be much better
here.

> +		memcpy(&b->qwSignature, cdev->qw_sign, sizeof(b->qwSignature));
> +		b->bMS_VendorCode = cdev->b_vendor_code;
> +		b->bPad = 0;
> +		return sizeof(*b);
> +	}
> +
>  	list_for_each_entry(uc, &cdev->gstrings, list) {
>  		struct usb_gadget_strings **sp;
>  

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@xxxxxxxxxx>--<xmpp:mina86@xxxxxxxxxx>--ooO--(_)--Ooo--

Attachment: signature.asc
Description: PGP signature


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

  Powered by Linux