ncm.c (b10778a00d40b3d9fdaaf5891e802794781ff71c) | ncm.c (c94e289f195e0e13cf34d27f9338d28221a85751) |
---|---|
1/* 2 * ncm.c -- NCM gadget driver 3 * 4 * Copyright (C) 2010 Nokia Corporation 5 * Contact: Yauheni Kaliuta <yauheni.kaliuta@nokia.com> 6 * 7 * The driver borrows from ether.c which is: 8 * --- 93 unchanged lines hidden (view full) --- 102 NULL, 103}; 104 105static struct usb_function_instance *f_ncm_inst; 106static struct usb_function *f_ncm; 107 108/*-------------------------------------------------------------------------*/ 109 | 1/* 2 * ncm.c -- NCM gadget driver 3 * 4 * Copyright (C) 2010 Nokia Corporation 5 * Contact: Yauheni Kaliuta <yauheni.kaliuta@nokia.com> 6 * 7 * The driver borrows from ether.c which is: 8 * --- 93 unchanged lines hidden (view full) --- 102 NULL, 103}; 104 105static struct usb_function_instance *f_ncm_inst; 106static struct usb_function *f_ncm; 107 108/*-------------------------------------------------------------------------*/ 109 |
110static int __init ncm_do_config(struct usb_configuration *c) | 110static int ncm_do_config(struct usb_configuration *c) |
111{ 112 int status; 113 114 /* FIXME alloc iConfiguration string, set it in c->strings */ 115 116 if (gadget_is_otg(c->cdev->gadget)) { 117 c->descriptors = otg_desc; 118 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; --- 19 unchanged lines hidden (view full) --- 138 .label = "CDC Ethernet (NCM)", 139 .bConfigurationValue = 1, 140 /* .iConfiguration = DYNAMIC */ 141 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 142}; 143 144/*-------------------------------------------------------------------------*/ 145 | 111{ 112 int status; 113 114 /* FIXME alloc iConfiguration string, set it in c->strings */ 115 116 if (gadget_is_otg(c->cdev->gadget)) { 117 c->descriptors = otg_desc; 118 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; --- 19 unchanged lines hidden (view full) --- 138 .label = "CDC Ethernet (NCM)", 139 .bConfigurationValue = 1, 140 /* .iConfiguration = DYNAMIC */ 141 .bmAttributes = USB_CONFIG_ATT_SELFPOWER, 142}; 143 144/*-------------------------------------------------------------------------*/ 145 |
146static int __init gncm_bind(struct usb_composite_dev *cdev) | 146static int gncm_bind(struct usb_composite_dev *cdev) |
147{ 148 struct usb_gadget *gadget = cdev->gadget; 149 struct f_ncm_opts *ncm_opts; 150 int status; 151 152 f_ncm_inst = usb_get_function_instance("ncm"); 153 if (IS_ERR(f_ncm_inst)) 154 return PTR_ERR(f_ncm_inst); --- 26 unchanged lines hidden (view full) --- 181 182 return 0; 183 184fail: 185 usb_put_function_instance(f_ncm_inst); 186 return status; 187} 188 | 147{ 148 struct usb_gadget *gadget = cdev->gadget; 149 struct f_ncm_opts *ncm_opts; 150 int status; 151 152 f_ncm_inst = usb_get_function_instance("ncm"); 153 if (IS_ERR(f_ncm_inst)) 154 return PTR_ERR(f_ncm_inst); --- 26 unchanged lines hidden (view full) --- 181 182 return 0; 183 184fail: 185 usb_put_function_instance(f_ncm_inst); 186 return status; 187} 188 |
189static int __exit gncm_unbind(struct usb_composite_dev *cdev) | 189static int gncm_unbind(struct usb_composite_dev *cdev) |
190{ 191 if (!IS_ERR_OR_NULL(f_ncm)) 192 usb_put_function(f_ncm); 193 if (!IS_ERR_OR_NULL(f_ncm_inst)) 194 usb_put_function_instance(f_ncm_inst); 195 return 0; 196} 197 | 190{ 191 if (!IS_ERR_OR_NULL(f_ncm)) 192 usb_put_function(f_ncm); 193 if (!IS_ERR_OR_NULL(f_ncm_inst)) 194 usb_put_function_instance(f_ncm_inst); 195 return 0; 196} 197 |
198static __refdata struct usb_composite_driver ncm_driver = { | 198static struct usb_composite_driver ncm_driver = { |
199 .name = "g_ncm", 200 .dev = &device_desc, 201 .strings = dev_strings, 202 .max_speed = USB_SPEED_HIGH, 203 .bind = gncm_bind, | 199 .name = "g_ncm", 200 .dev = &device_desc, 201 .strings = dev_strings, 202 .max_speed = USB_SPEED_HIGH, 203 .bind = gncm_bind, |
204 .unbind = __exit_p(gncm_unbind), | 204 .unbind = gncm_unbind, |
205}; 206 207module_usb_composite_driver(ncm_driver); 208 209MODULE_DESCRIPTION(DRIVER_DESC); 210MODULE_AUTHOR("Yauheni Kaliuta"); 211MODULE_LICENSE("GPL"); | 205}; 206 207module_usb_composite_driver(ncm_driver); 208 209MODULE_DESCRIPTION(DRIVER_DESC); 210MODULE_AUTHOR("Yauheni Kaliuta"); 211MODULE_LICENSE("GPL"); |