Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * cdc2.c -- CDC Composite driver, with ECM and ACM support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2008 David Brownell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 2008 Nokia Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "u_ether.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include "u_serial.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "u_ecm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define DRIVER_DESC		"CDC Composite Gadget"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define DRIVER_VERSION		"King Kamehameha Day 2008"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) /* DO NOT REUSE THESE IDs with a protocol-incompatible driver!!  Ever!!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * Instead:  allocate your own, using normal USB-IF procedures.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) /* Thanks to NetChip Technologies for donating this product ID.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * It's for devices with only this composite CDC configuration.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define CDC_VENDOR_NUM		0x0525	/* NetChip */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define CDC_PRODUCT_NUM		0xa4aa	/* CDC Composite: ECM + ACM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) USB_GADGET_COMPOSITE_OPTIONS();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) USB_ETHERNET_MODULE_PARAMETERS();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) static struct usb_device_descriptor device_desc = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	.bLength =		sizeof device_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	.bDescriptorType =	USB_DT_DEVICE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	/* .bcdUSB = DYNAMIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	.bDeviceClass =		USB_CLASS_COMM,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	.bDeviceSubClass =	0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	.bDeviceProtocol =	0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	/* .bMaxPacketSize0 = f(hardware) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	/* Vendor and product id can be overridden by module parameters.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	.idVendor =		cpu_to_le16(CDC_VENDOR_NUM),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	.idProduct =		cpu_to_le16(CDC_PRODUCT_NUM),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	/* .bcdDevice = f(hardware) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	/* .iManufacturer = DYNAMIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	/* .iProduct = DYNAMIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	/* NO SERIAL NUMBER */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	.bNumConfigurations =	1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static const struct usb_descriptor_header *otg_desc[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) /* string IDs are assigned dynamically */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static struct usb_string strings_dev[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	[USB_GADGET_MANUFACTURER_IDX].s = "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	[USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	[USB_GADGET_SERIAL_IDX].s = "",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	{  } /* end of list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) static struct usb_gadget_strings stringtab_dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	.language	= 0x0409,	/* en-us */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	.strings	= strings_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static struct usb_gadget_strings *dev_strings[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	&stringtab_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) static struct usb_function *f_acm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) static struct usb_function_instance *fi_serial;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) static struct usb_function *f_ecm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static struct usb_function_instance *fi_ecm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  * We _always_ have both CDC ECM and CDC ACM functions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) static int cdc_do_config(struct usb_configuration *c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	int	status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	if (gadget_is_otg(c->cdev->gadget)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		c->descriptors = otg_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	f_ecm = usb_get_function(fi_ecm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	if (IS_ERR(f_ecm)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		status = PTR_ERR(f_ecm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		goto err_get_ecm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	status = usb_add_function(c, f_ecm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		goto err_add_ecm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	f_acm = usb_get_function(fi_serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	if (IS_ERR(f_acm)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		status = PTR_ERR(f_acm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		goto err_get_acm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	status = usb_add_function(c, f_acm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	if (status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		goto err_add_acm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) err_add_acm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	usb_put_function(f_acm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) err_get_acm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	usb_remove_function(c, f_ecm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) err_add_ecm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	usb_put_function(f_ecm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) err_get_ecm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static struct usb_configuration cdc_config_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	.label			= "CDC Composite (ECM + ACM)",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	.bConfigurationValue	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	/* .iConfiguration = DYNAMIC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	.bmAttributes		= USB_CONFIG_ATT_SELFPOWER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) /*-------------------------------------------------------------------------*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) static int cdc_bind(struct usb_composite_dev *cdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	struct usb_gadget	*gadget = cdev->gadget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	struct f_ecm_opts	*ecm_opts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	int			status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	if (!can_support_ecm(cdev->gadget)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		dev_err(&gadget->dev, "controller '%s' not usable\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 				gadget->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	fi_ecm = usb_get_function_instance("ecm");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (IS_ERR(fi_ecm))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		return PTR_ERR(fi_ecm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	gether_set_qmult(ecm_opts->net, qmult);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	if (!gether_set_host_addr(ecm_opts->net, host_addr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		pr_info("using host ethernet address: %s", host_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	if (!gether_set_dev_addr(ecm_opts->net, dev_addr))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		pr_info("using self ethernet address: %s", dev_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	fi_serial = usb_get_function_instance("acm");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	if (IS_ERR(fi_serial)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		status = PTR_ERR(fi_serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	/* Allocate string descriptor numbers ... note that string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	 * contents can be overridden by the composite_dev glue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	status = usb_string_ids_tab(cdev, strings_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		goto fail1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	if (gadget_is_otg(gadget) && !otg_desc[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		struct usb_descriptor_header *usb_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		usb_desc = usb_otg_descriptor_alloc(gadget);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		if (!usb_desc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			status = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 			goto fail1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		usb_otg_descriptor_init(gadget, usb_desc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		otg_desc[0] = usb_desc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		otg_desc[1] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	/* register our configuration */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		goto fail2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	usb_composite_overwrite_options(cdev, &coverwrite);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			DRIVER_DESC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) fail2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	kfree(otg_desc[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	otg_desc[0] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) fail1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	usb_put_function_instance(fi_serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	usb_put_function_instance(fi_ecm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	return status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) static int cdc_unbind(struct usb_composite_dev *cdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	usb_put_function(f_acm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	usb_put_function_instance(fi_serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	if (!IS_ERR_OR_NULL(f_ecm))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		usb_put_function(f_ecm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	if (!IS_ERR_OR_NULL(fi_ecm))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		usb_put_function_instance(fi_ecm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	kfree(otg_desc[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	otg_desc[0] = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) static struct usb_composite_driver cdc_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	.name		= "g_cdc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	.dev		= &device_desc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	.strings	= dev_strings,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	.max_speed	= USB_SPEED_SUPER,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	.bind		= cdc_bind,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	.unbind		= cdc_unbind,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) module_usb_composite_driver(cdc_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) MODULE_DESCRIPTION(DRIVER_DESC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) MODULE_AUTHOR("David Brownell");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) MODULE_LICENSE("GPL");