ether.c (b10778a00d40b3d9fdaaf5891e802794781ff71c) ether.c (c94e289f195e0e13cf34d27f9338d28221a85751)
1/*
2 * ether.c -- Ethernet gadget driver, with CDC and non-CDC options
3 *
4 * Copyright (C) 2003-2005,2008 David Brownell
5 * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger
6 * Copyright (C) 2008 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 208 unchanged lines hidden (view full) ---

217
218/*-------------------------------------------------------------------------*/
219
220/*
221 * We may not have an RNDIS configuration, but if we do it needs to be
222 * the first one present. That's to make Microsoft's drivers happy,
223 * and to follow DOCSIS 1.0 (cable modem standard).
224 */
1/*
2 * ether.c -- Ethernet gadget driver, with CDC and non-CDC options
3 *
4 * Copyright (C) 2003-2005,2008 David Brownell
5 * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger
6 * Copyright (C) 2008 Nokia Corporation
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 208 unchanged lines hidden (view full) ---

217
218/*-------------------------------------------------------------------------*/
219
220/*
221 * We may not have an RNDIS configuration, but if we do it needs to be
222 * the first one present. That's to make Microsoft's drivers happy,
223 * and to follow DOCSIS 1.0 (cable modem standard).
224 */
225static int __init rndis_do_config(struct usb_configuration *c)
225static int rndis_do_config(struct usb_configuration *c)
226{
227 int status;
228
229 /* FIXME alloc iConfiguration string, set it in c->strings */
230
231 if (gadget_is_otg(c->cdev->gadget)) {
232 c->descriptors = otg_desc;
233 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;

--- 25 unchanged lines hidden (view full) ---

259static bool use_eem;
260#endif
261module_param(use_eem, bool, 0);
262MODULE_PARM_DESC(use_eem, "use CDC EEM mode");
263
264/*
265 * We _always_ have an ECM, CDC Subset, or EEM configuration.
266 */
226{
227 int status;
228
229 /* FIXME alloc iConfiguration string, set it in c->strings */
230
231 if (gadget_is_otg(c->cdev->gadget)) {
232 c->descriptors = otg_desc;
233 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;

--- 25 unchanged lines hidden (view full) ---

259static bool use_eem;
260#endif
261module_param(use_eem, bool, 0);
262MODULE_PARM_DESC(use_eem, "use CDC EEM mode");
263
264/*
265 * We _always_ have an ECM, CDC Subset, or EEM configuration.
266 */
267static int __init eth_do_config(struct usb_configuration *c)
267static int eth_do_config(struct usb_configuration *c)
268{
269 int status = 0;
270
271 /* FIXME alloc iConfiguration string, set it in c->strings */
272
273 if (gadget_is_otg(c->cdev->gadget)) {
274 c->descriptors = otg_desc;
275 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;

--- 37 unchanged lines hidden (view full) ---

313 /* .label = f(hardware) */
314 .bConfigurationValue = 1,
315 /* .iConfiguration = DYNAMIC */
316 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
317};
318
319/*-------------------------------------------------------------------------*/
320
268{
269 int status = 0;
270
271 /* FIXME alloc iConfiguration string, set it in c->strings */
272
273 if (gadget_is_otg(c->cdev->gadget)) {
274 c->descriptors = otg_desc;
275 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;

--- 37 unchanged lines hidden (view full) ---

313 /* .label = f(hardware) */
314 .bConfigurationValue = 1,
315 /* .iConfiguration = DYNAMIC */
316 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
317};
318
319/*-------------------------------------------------------------------------*/
320
321static int __init eth_bind(struct usb_composite_dev *cdev)
321static int eth_bind(struct usb_composite_dev *cdev)
322{
323 struct usb_gadget *gadget = cdev->gadget;
324 struct f_eem_opts *eem_opts = NULL;
325 struct f_ecm_opts *ecm_opts = NULL;
326 struct f_gether_opts *geth_opts = NULL;
327 struct net_device *net;
328 int status;
329

--- 112 unchanged lines hidden (view full) ---

442 usb_put_function_instance(fi_eem);
443 else if (can_support_ecm(gadget))
444 usb_put_function_instance(fi_ecm);
445 else
446 usb_put_function_instance(fi_geth);
447 return status;
448}
449
322{
323 struct usb_gadget *gadget = cdev->gadget;
324 struct f_eem_opts *eem_opts = NULL;
325 struct f_ecm_opts *ecm_opts = NULL;
326 struct f_gether_opts *geth_opts = NULL;
327 struct net_device *net;
328 int status;
329

--- 112 unchanged lines hidden (view full) ---

442 usb_put_function_instance(fi_eem);
443 else if (can_support_ecm(gadget))
444 usb_put_function_instance(fi_ecm);
445 else
446 usb_put_function_instance(fi_geth);
447 return status;
448}
449
450static int __exit eth_unbind(struct usb_composite_dev *cdev)
450static int eth_unbind(struct usb_composite_dev *cdev)
451{
452 if (has_rndis()) {
453 usb_put_function(f_rndis);
454 usb_put_function_instance(fi_rndis);
455 }
456 if (use_eem) {
457 usb_put_function(f_eem);
458 usb_put_function_instance(fi_eem);
459 } else if (can_support_ecm(cdev->gadget)) {
460 usb_put_function(f_ecm);
461 usb_put_function_instance(fi_ecm);
462 } else {
463 usb_put_function(f_geth);
464 usb_put_function_instance(fi_geth);
465 }
466 return 0;
467}
468
451{
452 if (has_rndis()) {
453 usb_put_function(f_rndis);
454 usb_put_function_instance(fi_rndis);
455 }
456 if (use_eem) {
457 usb_put_function(f_eem);
458 usb_put_function_instance(fi_eem);
459 } else if (can_support_ecm(cdev->gadget)) {
460 usb_put_function(f_ecm);
461 usb_put_function_instance(fi_ecm);
462 } else {
463 usb_put_function(f_geth);
464 usb_put_function_instance(fi_geth);
465 }
466 return 0;
467}
468
469static __refdata struct usb_composite_driver eth_driver = {
469static struct usb_composite_driver eth_driver = {
470 .name = "g_ether",
471 .dev = &device_desc,
472 .strings = dev_strings,
473 .max_speed = USB_SPEED_SUPER,
474 .bind = eth_bind,
470 .name = "g_ether",
471 .dev = &device_desc,
472 .strings = dev_strings,
473 .max_speed = USB_SPEED_SUPER,
474 .bind = eth_bind,
475 .unbind = __exit_p(eth_unbind),
475 .unbind = eth_unbind,
476};
477
478module_usb_composite_driver(eth_driver);
479
480MODULE_DESCRIPTION(PREFIX DRIVER_DESC);
481MODULE_AUTHOR("David Brownell, Benedikt Spanger");
482MODULE_LICENSE("GPL");
476};
477
478module_usb_composite_driver(eth_driver);
479
480MODULE_DESCRIPTION(PREFIX DRIVER_DESC);
481MODULE_AUTHOR("David Brownell, Benedikt Spanger");
482MODULE_LICENSE("GPL");