Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53e6242d authored by Macpaul Lin's avatar Macpaul Lin Committed by Felipe Balbi
Browse files

usb: gadget: composite: add USB_DT_OTG request handling



Copy usb_otg_descriptor from config's descriptor if host requests
USB_DT_OTG.

Signed-off-by: default avatarMacpaul Lin <macpaul@gmail.com>
Signed-off-by: default avatarLi Jun <jun.li@freescale.com>
Reviewed-by: default avatarRoger Quadros <rogerq@ti.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 84704bb3
Loading
Loading
Loading
Loading
+27 −0
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@
#include <linux/utsname.h>
#include <linux/utsname.h>


#include <linux/usb/composite.h>
#include <linux/usb/composite.h>
#include <linux/usb/otg.h>
#include <asm/unaligned.h>
#include <asm/unaligned.h>


#include "u_os_desc.h"
#include "u_os_desc.h"
@@ -1540,6 +1541,32 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
				value = min(w_length, (u16) value);
				value = min(w_length, (u16) value);
			}
			}
			break;
			break;
		case USB_DT_OTG:
			if (gadget_is_otg(gadget)) {
				struct usb_configuration *config;
				int otg_desc_len = 0;

				if (cdev->config)
					config = cdev->config;
				else
					config = list_first_entry(
							&cdev->configs,
						struct usb_configuration, list);
				if (!config)
					goto done;

				if (gadget->otg_caps &&
					(gadget->otg_caps->otg_rev >= 0x0200))
					otg_desc_len += sizeof(
						struct usb_otg20_descriptor);
				else
					otg_desc_len += sizeof(
						struct usb_otg_descriptor);

				value = min_t(int, w_length, otg_desc_len);
				memcpy(req->buf, config->descriptors[0], value);
			}
			break;
		}
		}
		break;
		break;