From: Mike Lockwood Date: Fri, 16 Apr 2010 19:32:15 +0000 (-0400) Subject: USB: composite: Add support for functions overriding USB_DT_STRING descriptors X-Git-Tag: firefly_0821_release~7613^2~808 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fb52b002c2d20205d01598f0440dc89ece98ba2d;p=firefly-linux-kernel-4.4.55.git USB: composite: Add support for functions overriding USB_DT_STRING descriptors Needed for MTP support. Signed-off-by: Mike Lockwood --- diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index e15c0b6a5849..03b02876ba18 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -931,6 +931,21 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) case USB_DT_STRING: value = get_string(cdev, req->buf, w_index, w_value & 0xff); + + /* Allow functions to handle USB_DT_STRING. + * This is required for MTP. + */ + if (value < 0) { + struct usb_configuration *cfg; + list_for_each_entry(cfg, &cdev->configs, list) { + if (cfg && cfg->setup) { + value = cfg->setup(cfg, ctrl); + if (value >= 0) + break; + } + } + } + if (value >= 0) value = min(w_length, (u16) value); break;