2005-04-17 02:20:36 +04:00
/*
* ether . c - - Ethernet gadget driver , with CDC and non - CDC options
*
2008-06-20 05:20:11 +04:00
* Copyright ( C ) 2003 - 2005 , 2008 David Brownell
2005-04-17 02:20:36 +04:00
* Copyright ( C ) 2003 - 2004 Robert Schwebel , Benedikt Spranger
2008-06-20 05:20:11 +04:00
* Copyright ( C ) 2008 Nokia Corporation
2005-04-17 02:20:36 +04:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License , or
* ( at your option ) any later version .
*/
2007-08-02 11:00:38 +04:00
/* #define VERBOSE_DEBUG */
2005-04-17 02:20:36 +04:00
# include <linux/kernel.h>
2013-05-28 11:15:54 +04:00
# include <linux/netdevice.h>
2009-11-30 12:55:40 +03:00
# if defined USB_ETH_RNDIS
# undef USB_ETH_RNDIS
# endif
# ifdef CONFIG_USB_ETH_RNDIS
# define USB_ETH_RNDIS y
# endif
2008-06-20 05:20:11 +04:00
# include "u_ether.h"
2005-04-17 02:20:36 +04:00
/*
* Ethernet gadget driver - - with CDC and non - CDC options
* Builds on hardware support for a full duplex link .
*
* CDC Ethernet is the standard USB solution for sending Ethernet frames
* using USB . Real hardware tends to use the same framing protocol but look
* different for control features . This driver strongly prefers to use
* this USB - IF standard as its open - systems interoperability solution ;
* most host side USB stacks ( except from Microsoft ) support it .
*
2008-06-20 05:20:11 +04:00
* This is sometimes called " CDC ECM " ( Ethernet Control Model ) to support
* TLA - soup . " CDC ACM " ( Abstract Control Model ) is for modems , and a new
* " CDC EEM " ( Ethernet Emulation Model ) is starting to spread .
*
* There ' s some hardware that can ' t talk CDC ECM . We make that hardware
2005-04-17 02:20:36 +04:00
* implement a " minimalist " vendor - agnostic CDC core : same framing , but
2006-12-12 02:59:04 +03:00
* link - level setup only requires activating the configuration . Only the
* endpoint descriptors , and product / vendor IDs , are relevant ; no control
* operations are available . Linux supports it , but other host operating
* systems may not . ( This is a subset of CDC Ethernet . )
*
* It turns out that if you add a few descriptors to that " CDC Subset " ,
* ( Windows ) host side drivers from MCCI can treat it as one submode of
* a proprietary scheme called " SAFE " . . . without needing to know about
* specific product / vendor IDs . So we do that , making it easier to use
* those MS - Windows drivers . Those added descriptors make it resemble a
* CDC MDLM device , but they don ' t change device behavior at all . ( See
* MCCI Engineering report 950198 " SAFE Networking Functions " . )
2005-04-17 02:20:36 +04:00
*
* A third option is also in use . Rather than CDC Ethernet , or something
* simpler , Microsoft pushes their own approach : RNDIS . The published
* RNDIS specs are ambiguous and appear to be incomplete , and are also
2008-06-20 05:20:11 +04:00
* needlessly complex . They borrow more from CDC ACM than CDC ECM .
2005-04-17 02:20:36 +04:00
*/
# define DRIVER_DESC "Ethernet Gadget"
2008-06-20 05:20:11 +04:00
# define DRIVER_VERSION "Memorial Day 2008"
2005-04-17 02:20:36 +04:00
2009-11-30 12:55:40 +03:00
# ifdef USB_ETH_RNDIS
2008-06-20 05:20:11 +04:00
# define PREFIX "RNDIS / "
# else
# define PREFIX ""
2005-04-17 02:20:36 +04:00
# endif
2008-06-20 05:20:11 +04:00
/*
* This driver aims for interoperability by using CDC ECM unless
*
* can_support_ecm ( )
2005-04-17 02:20:36 +04:00
*
2008-06-20 05:20:11 +04:00
* returns false , in which case it supports the CDC Subset . By default ,
* that returns true ; most hardware has no problems with CDC ECM , that ' s
* a good default . Previous versions of this driver had no default ; this
* version changes that , removing overhead for new controller support .
*
* IF YOUR HARDWARE CAN ' T SUPPORT CDC ECM , UPDATE THAT ROUTINE !
2005-04-17 02:20:36 +04:00
*/
2008-06-20 05:20:11 +04:00
static inline bool has_rndis ( void )
{
2009-11-30 12:55:40 +03:00
# ifdef USB_ETH_RNDIS
2008-06-20 05:20:11 +04:00
return true ;
# else
return false ;
# endif
}
2013-05-24 12:23:02 +04:00
# include <linux/module.h>
2013-05-28 11:15:46 +04:00
# include "u_ecm.h"
2013-05-28 11:15:54 +04:00
# include "u_gether.h"
2009-11-30 12:55:40 +03:00
# ifdef USB_ETH_RNDIS
2013-05-28 11:15:58 +04:00
# include "u_rndis.h"
2013-05-24 12:23:02 +04:00
# include "rndis.h"
2013-05-28 11:15:58 +04:00
# else
# define rndis_borrow_net(...) do {} while (0)
2008-08-19 04:45:07 +04:00
# endif
2013-05-28 11:15:48 +04:00
# include "u_eem.h"
2008-08-19 04:45:07 +04:00
/*-------------------------------------------------------------------------*/
2012-09-10 17:01:53 +04:00
USB_GADGET_COMPOSITE_OPTIONS ( ) ;
2008-08-19 04:45:07 +04:00
usb: gadget: u_ether: convert into module
u_ether.c has been #include'd by all gadgets which implement
USB Ethernet functions. In order to add configfs support,
the f_ecm.c, f_eem.c, f_ncm.c, f_subset.c, f_rndis.c need to be
converted into modules and must not be #include'd. Consequently,
the u_ether.c needs to be a module too, in a manner similar
to u_serial.c. The resulting module should not take any parameters,
so they are pushed to the current users of it, that is ether.c,
g_ffs.c, multi.c, ncm.c, nokia.c.
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
2013-05-23 11:22:03 +04:00
USB_ETHERNET_MODULE_PARAMETERS ( ) ;
2005-04-17 02:20:36 +04:00
/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
* Instead : allocate your own , using normal USB - IF procedures .
*/
/* Thanks to NetChip Technologies for donating this product ID.
* It ' s for devices with only CDC Ethernet configurations .
*/
2008-06-20 05:20:11 +04:00
# define CDC_VENDOR_NUM 0x0525 /* NetChip */
# define CDC_PRODUCT_NUM 0xa4a1 /* Linux-USB Ethernet Gadget */
2005-04-17 02:20:36 +04:00
/* For hardware that can't talk CDC, we use the same vendor ID that
* ARM Linux has used for ethernet - over - usb , both with sa1100 and
* with pxa250 . We ' re protocol - compatible , if the host - side drivers
* use the endpoint descriptors . bcdDevice ( version ) is nonzero , so
* drivers that need to hard - wire endpoint numbers have a hook .
*
* The protocol is a minimal subset of CDC Ether , which works on any bulk
* hardware that ' s not deeply broken . . . even on hardware that can ' t talk
* RNDIS ( like SA - 1100 , with no interrupt endpoint , or anything that
* doesn ' t handle control - OUT ) .
*/
# define SIMPLE_VENDOR_NUM 0x049f
# define SIMPLE_PRODUCT_NUM 0x505a
/* For hardware that can talk RNDIS and either of the above protocols,
* use this ID . . . the windows INF files will know it . Unless it ' s
* used with CDC Ethernet , Linux 2.4 hosts will need updates to choose
* the non - RNDIS configuration .
*/
# define RNDIS_VENDOR_NUM 0x0525 /* NetChip */
# define RNDIS_PRODUCT_NUM 0xa4a2 /* Ethernet/RNDIS Gadget */
2009-08-14 19:04:22 +04:00
/* For EEM gadgets */
2009-10-14 21:04:33 +04:00
# define EEM_VENDOR_NUM 0x1d6b /* Linux Foundation */
# define EEM_PRODUCT_NUM 0x0102 /* EEM Gadget */
2009-08-14 19:04:22 +04:00
2005-04-17 02:20:36 +04:00
/*-------------------------------------------------------------------------*/
2008-06-20 05:20:11 +04:00
static struct usb_device_descriptor device_desc = {
2005-04-17 02:20:36 +04:00
. bLength = sizeof device_desc ,
. bDescriptorType = USB_DT_DEVICE ,
2009-02-12 01:11:36 +03:00
. bcdUSB = cpu_to_le16 ( 0x0200 ) ,
2005-04-17 02:20:36 +04:00
. bDeviceClass = USB_CLASS_COMM ,
. bDeviceSubClass = 0 ,
. bDeviceProtocol = 0 ,
2008-06-20 05:20:11 +04:00
/* .bMaxPacketSize0 = f(hardware) */
2005-04-17 02:20:36 +04:00
2008-06-20 05:20:11 +04:00
/* Vendor and product id defaults change according to what configs
* we support . ( As does bNumConfigurations . ) These values can
* also be overridden by module parameters .
*/
2009-02-12 01:11:36 +03:00
. idVendor = cpu_to_le16 ( CDC_VENDOR_NUM ) ,
. idProduct = cpu_to_le16 ( CDC_PRODUCT_NUM ) ,
2008-06-20 05:20:11 +04:00
/* .bcdDevice = f(hardware) */
/* .iManufacturer = DYNAMIC */
/* .iProduct = DYNAMIC */
/* NO SERIAL NUMBER */
2005-04-17 02:20:36 +04:00
. bNumConfigurations = 1 ,
} ;
2008-06-20 05:20:11 +04:00
static struct usb_otg_descriptor otg_descriptor = {
2005-04-17 02:20:36 +04:00
. bLength = sizeof otg_descriptor ,
. bDescriptorType = USB_DT_OTG ,
2008-06-20 05:20:11 +04:00
/* REVISIT SRP-only hardware is possible, although
* it would not be called " OTG " . . .
*/
. bmAttributes = USB_OTG_SRP | USB_OTG_HNP ,
2005-04-17 02:20:36 +04:00
} ;
2006-06-13 20:54:40 +04:00
2008-06-20 05:20:11 +04:00
static const struct usb_descriptor_header * otg_desc [ ] = {
( struct usb_descriptor_header * ) & otg_descriptor ,
NULL ,
2005-04-17 02:20:36 +04:00
} ;
2008-06-20 05:20:11 +04:00
static struct usb_string strings_dev [ ] = {
2012-09-10 17:01:58 +04:00
[ USB_GADGET_MANUFACTURER_IDX ] . s = " " ,
2012-09-06 22:11:21 +04:00
[ USB_GADGET_PRODUCT_IDX ] . s = PREFIX DRIVER_DESC ,
[ USB_GADGET_SERIAL_IDX ] . s = " " ,
2008-06-20 05:20:11 +04:00
{ } /* end of list */
2005-04-17 02:20:36 +04:00
} ;
2008-06-20 05:20:11 +04:00
static struct usb_gadget_strings stringtab_dev = {
. language = 0x0409 , /* en-us */
. strings = strings_dev ,
2005-04-17 02:20:36 +04:00
} ;
2008-06-20 05:20:11 +04:00
static struct usb_gadget_strings * dev_strings [ ] = {
& stringtab_dev ,
NULL ,
2005-04-17 02:20:36 +04:00
} ;
2013-05-28 11:15:46 +04:00
static struct usb_function_instance * fi_ecm ;
static struct usb_function * f_ecm ;
2013-05-28 11:15:48 +04:00
static struct usb_function_instance * fi_eem ;
static struct usb_function * f_eem ;
2013-05-28 11:15:54 +04:00
static struct usb_function_instance * fi_geth ;
static struct usb_function * f_geth ;
2013-05-28 11:15:58 +04:00
static struct usb_function_instance * fi_rndis ;
static struct usb_function * f_rndis ;
2008-06-20 05:20:11 +04:00
/*-------------------------------------------------------------------------*/
2006-12-12 02:59:04 +03:00
2008-06-20 05:20:11 +04:00
/*
* We may not have an RNDIS configuration , but if we do it needs to be
* the first one present . That ' s to make Microsoft ' s drivers happy ,
* and to follow DOCSIS 1.0 ( cable modem standard ) .
2006-12-12 02:59:04 +03:00
*/
2010-08-12 19:43:52 +04:00
static int __init rndis_do_config ( struct usb_configuration * c )
2008-06-20 05:20:11 +04:00
{
2013-05-28 11:15:58 +04:00
int status ;
2008-06-20 05:20:11 +04:00
/* FIXME alloc iConfiguration string, set it in c->strings */
2006-12-12 02:59:04 +03:00
2008-06-20 05:20:11 +04:00
if ( gadget_is_otg ( c - > cdev - > gadget ) ) {
c - > descriptors = otg_desc ;
c - > bmAttributes | = USB_CONFIG_ATT_WAKEUP ;
}
2005-04-17 02:20:36 +04:00
2013-05-28 11:15:58 +04:00
f_rndis = usb_get_function ( fi_rndis ) ;
if ( IS_ERR ( f_rndis ) )
return PTR_ERR ( f_rndis ) ;
status = usb_add_function ( c , f_rndis ) ;
if ( status < 0 )
usb_put_function ( f_rndis ) ;
return status ;
2008-06-20 05:20:11 +04:00
}
2005-04-17 02:20:36 +04:00
2008-06-20 05:20:11 +04:00
static struct usb_configuration rndis_config_driver = {
. label = " RNDIS " ,
. bConfigurationValue = 2 ,
/* .iConfiguration = DYNAMIC */
. bmAttributes = USB_CONFIG_ATT_SELFPOWER ,
2005-04-17 02:20:36 +04:00
} ;
2008-06-20 05:20:11 +04:00
/*-------------------------------------------------------------------------*/
2005-04-17 02:20:36 +04:00
2009-12-28 14:31:08 +03:00
# ifdef CONFIG_USB_ETH_EEM
2012-01-13 03:02:20 +04:00
static bool use_eem = 1 ;
2009-08-14 19:04:22 +04:00
# else
2012-01-13 03:02:20 +04:00
static bool use_eem ;
2009-08-14 19:04:22 +04:00
# endif
module_param ( use_eem , bool , 0 ) ;
MODULE_PARM_DESC ( use_eem , " use CDC EEM mode " ) ;
2008-06-20 05:20:11 +04:00
/*
2009-08-14 19:04:22 +04:00
* We _always_ have an ECM , CDC Subset , or EEM configuration .
2005-04-17 02:20:36 +04:00
*/
2010-08-12 19:43:52 +04:00
static int __init eth_do_config ( struct usb_configuration * c )
2008-06-20 05:20:11 +04:00
{
2013-05-28 11:15:46 +04:00
int status = 0 ;
2008-06-20 05:20:11 +04:00
/* FIXME alloc iConfiguration string, set it in c->strings */
2006-06-13 20:54:40 +04:00
2008-06-20 05:20:11 +04:00
if ( gadget_is_otg ( c - > cdev - > gadget ) ) {
c - > descriptors = otg_desc ;
c - > bmAttributes | = USB_CONFIG_ATT_WAKEUP ;
}
2005-04-17 02:20:36 +04:00
2013-05-28 11:15:48 +04:00
if ( use_eem ) {
f_eem = usb_get_function ( fi_eem ) ;
if ( IS_ERR ( f_eem ) )
return PTR_ERR ( f_eem ) ;
status = usb_add_function ( c , f_eem ) ;
if ( status < 0 )
usb_put_function ( f_eem ) ;
return status ;
} else if ( can_support_ecm ( c - > cdev - > gadget ) ) {
2013-05-28 11:15:46 +04:00
f_ecm = usb_get_function ( fi_ecm ) ;
if ( IS_ERR ( f_ecm ) )
return PTR_ERR ( f_ecm ) ;
status = usb_add_function ( c , f_ecm ) ;
if ( status < 0 )
usb_put_function ( f_ecm ) ;
return status ;
2013-05-28 11:15:54 +04:00
} else {
f_geth = usb_get_function ( fi_geth ) ;
if ( IS_ERR ( f_geth ) )
return PTR_ERR ( f_geth ) ;
status = usb_add_function ( c , f_geth ) ;
if ( status < 0 )
usb_put_function ( f_geth ) ;
return status ;
}
2013-05-28 11:15:46 +04:00
2008-06-20 05:20:11 +04:00
}
2005-04-17 02:20:36 +04:00
2008-06-20 05:20:11 +04:00
static struct usb_configuration eth_config_driver = {
/* .label = f(hardware) */
. bConfigurationValue = 1 ,
/* .iConfiguration = DYNAMIC */
. bmAttributes = USB_CONFIG_ATT_SELFPOWER ,
2005-04-17 02:20:36 +04:00
} ;
2008-06-20 05:20:11 +04:00
/*-------------------------------------------------------------------------*/
2005-04-17 02:20:36 +04:00
2010-08-12 19:43:52 +04:00
static int __init eth_bind ( struct usb_composite_dev * cdev )
2008-06-20 05:20:11 +04:00
{
struct usb_gadget * gadget = cdev - > gadget ;
2013-05-28 11:15:48 +04:00
struct f_eem_opts * eem_opts = NULL ;
2013-05-28 11:15:46 +04:00
struct f_ecm_opts * ecm_opts = NULL ;
2013-05-28 11:15:54 +04:00
struct f_gether_opts * geth_opts = NULL ;
struct net_device * net ;
2008-06-20 05:20:11 +04:00
int status ;
2005-04-17 02:20:36 +04:00
2008-06-20 05:20:11 +04:00
/* set up main config label and device descriptor */
2009-08-14 19:04:22 +04:00
if ( use_eem ) {
/* EEM */
2013-05-28 11:15:48 +04:00
fi_eem = usb_get_function_instance ( " eem " ) ;
if ( IS_ERR ( fi_eem ) )
return PTR_ERR ( fi_eem ) ;
eem_opts = container_of ( fi_eem , struct f_eem_opts , func_inst ) ;
2013-05-28 11:15:54 +04:00
net = eem_opts - > net ;
2013-05-28 11:15:48 +04:00
2009-08-14 19:04:22 +04:00
eth_config_driver . label = " CDC Ethernet (EEM) " ;
device_desc . idVendor = cpu_to_le16 ( EEM_VENDOR_NUM ) ;
device_desc . idProduct = cpu_to_le16 ( EEM_PRODUCT_NUM ) ;
2013-05-28 11:15:46 +04:00
} else if ( can_support_ecm ( gadget ) ) {
2008-06-20 05:20:11 +04:00
/* ECM */
2013-05-28 11:15:46 +04:00
fi_ecm = usb_get_function_instance ( " ecm " ) ;
if ( IS_ERR ( fi_ecm ) )
return PTR_ERR ( fi_ecm ) ;
ecm_opts = container_of ( fi_ecm , struct f_ecm_opts , func_inst ) ;
2013-05-28 11:15:54 +04:00
net = ecm_opts - > net ;
2013-05-28 11:15:46 +04:00
2008-06-20 05:20:11 +04:00
eth_config_driver . label = " CDC Ethernet (ECM) " ;
} else {
/* CDC Subset */
2013-05-28 11:15:54 +04:00
fi_geth = usb_get_function_instance ( " geth " ) ;
if ( IS_ERR ( fi_geth ) )
return PTR_ERR ( fi_geth ) ;
geth_opts = container_of ( fi_geth , struct f_gether_opts ,
func_inst ) ;
net = geth_opts - > net ;
2008-06-20 05:20:11 +04:00
eth_config_driver . label = " CDC Subset/SAFE " ;
2005-04-17 02:20:36 +04:00
2009-06-19 14:09:04 +04:00
device_desc . idVendor = cpu_to_le16 ( SIMPLE_VENDOR_NUM ) ;
device_desc . idProduct = cpu_to_le16 ( SIMPLE_PRODUCT_NUM ) ;
if ( ! has_rndis ( ) )
device_desc . bDeviceClass = USB_CLASS_VENDOR_SPEC ;
2008-06-20 05:20:11 +04:00
}
2005-04-17 02:20:36 +04:00
2013-05-28 11:15:54 +04:00
gether_set_qmult ( net , qmult ) ;
if ( ! gether_set_host_addr ( net , host_addr ) )
pr_info ( " using host ethernet address: %s " , host_addr ) ;
if ( ! gether_set_dev_addr ( net , dev_addr ) )
pr_info ( " using self ethernet address: %s " , dev_addr ) ;
2008-06-20 05:20:11 +04:00
if ( has_rndis ( ) ) {
/* RNDIS plus ECM-or-Subset */
2013-05-28 11:15:54 +04:00
gether_set_gadget ( net , cdev - > gadget ) ;
status = gether_register_netdev ( net ) ;
if ( status )
goto fail ;
if ( use_eem )
2013-05-28 11:15:48 +04:00
eem_opts - > bound = true ;
2013-05-28 11:15:54 +04:00
else if ( can_support_ecm ( gadget ) )
2013-05-28 11:15:46 +04:00
ecm_opts - > bound = true ;
2013-05-28 11:15:54 +04:00
else
geth_opts - > bound = true ;
2013-05-28 11:15:46 +04:00
2013-05-28 11:15:58 +04:00
fi_rndis = usb_get_function_instance ( " rndis " ) ;
if ( IS_ERR ( fi_rndis ) ) {
status = PTR_ERR ( fi_rndis ) ;
goto fail ;
}
rndis_borrow_net ( fi_rndis , net ) ;
2009-06-19 14:09:04 +04:00
device_desc . idVendor = cpu_to_le16 ( RNDIS_VENDOR_NUM ) ;
device_desc . idProduct = cpu_to_le16 ( RNDIS_PRODUCT_NUM ) ;
2008-06-20 05:20:11 +04:00
device_desc . bNumConfigurations = 2 ;
}
2005-04-17 02:20:36 +04:00
2008-06-20 05:20:11 +04:00
/* Allocate string descriptor numbers ... note that string
* contents can be overridden by the composite_dev glue .
*/
2005-04-17 02:20:36 +04:00
2012-09-06 22:11:16 +04:00
status = usb_string_ids_tab ( cdev , strings_dev ) ;
2008-06-20 05:20:11 +04:00
if ( status < 0 )
2013-05-28 11:15:58 +04:00
goto fail1 ;
2012-09-06 22:11:21 +04:00
device_desc . iManufacturer = strings_dev [ USB_GADGET_MANUFACTURER_IDX ] . id ;
device_desc . iProduct = strings_dev [ USB_GADGET_PRODUCT_IDX ] . id ;
2005-04-17 02:20:36 +04:00
2008-06-20 05:20:11 +04:00
/* register our configuration(s); RNDIS first, if it's used */
if ( has_rndis ( ) ) {
2010-08-12 19:43:55 +04:00
status = usb_add_config ( cdev , & rndis_config_driver ,
rndis_do_config ) ;
2008-06-20 05:20:11 +04:00
if ( status < 0 )
2013-05-28 11:15:58 +04:00
goto fail1 ;
2008-06-20 05:20:11 +04:00
}
2005-04-17 02:20:36 +04:00
2010-08-12 19:43:55 +04:00
status = usb_add_config ( cdev , & eth_config_driver , eth_do_config ) ;
2008-06-20 05:20:11 +04:00
if ( status < 0 )
2013-05-28 11:15:58 +04:00
goto fail1 ;
2005-04-17 02:20:36 +04:00
2012-09-10 17:01:53 +04:00
usb_composite_overwrite_options ( cdev , & coverwrite ) ;
2008-08-19 04:45:07 +04:00
dev_info ( & gadget - > dev , " %s, version: " DRIVER_VERSION " \n " ,
DRIVER_DESC ) ;
2005-04-17 02:20:36 +04:00
2008-06-20 05:20:11 +04:00
return 0 ;
2005-04-17 02:20:36 +04:00
2013-05-28 11:15:58 +04:00
fail1 :
if ( has_rndis ( ) )
usb_put_function_instance ( fi_rndis ) ;
2008-06-20 05:20:11 +04:00
fail :
2013-05-28 11:15:54 +04:00
if ( use_eem )
2013-05-28 11:15:48 +04:00
usb_put_function_instance ( fi_eem ) ;
2013-05-28 11:15:54 +04:00
else if ( can_support_ecm ( gadget ) )
2013-05-28 11:15:46 +04:00
usb_put_function_instance ( fi_ecm ) ;
2013-05-28 11:15:54 +04:00
else
usb_put_function_instance ( fi_geth ) ;
2008-06-20 05:20:11 +04:00
return status ;
}
2005-04-17 02:20:36 +04:00
2008-06-20 05:20:11 +04:00
static int __exit eth_unbind ( struct usb_composite_dev * cdev )
{
2013-07-24 14:47:46 +04:00
if ( has_rndis ( ) ) {
usb_put_function ( f_rndis ) ;
2013-05-28 11:15:58 +04:00
usb_put_function_instance ( fi_rndis ) ;
2013-07-24 14:47:46 +04:00
}
if ( use_eem ) {
usb_put_function ( f_eem ) ;
2013-05-28 11:15:48 +04:00
usb_put_function_instance ( fi_eem ) ;
2013-07-24 14:47:46 +04:00
} else if ( can_support_ecm ( cdev - > gadget ) ) {
usb_put_function ( f_ecm ) ;
2013-05-28 11:15:46 +04:00
usb_put_function_instance ( fi_ecm ) ;
2013-07-24 14:47:46 +04:00
} else {
usb_put_function ( f_geth ) ;
2013-05-28 11:15:54 +04:00
usb_put_function_instance ( fi_geth ) ;
2013-07-24 14:47:46 +04:00
}
2008-06-20 05:20:11 +04:00
return 0 ;
}
2005-04-17 02:20:36 +04:00
2012-09-06 22:11:03 +04:00
static __refdata struct usb_composite_driver eth_driver = {
2008-06-20 05:20:11 +04:00
. name = " g_ether " ,
. dev = & device_desc ,
. strings = dev_strings ,
2011-06-28 01:13:18 +04:00
. max_speed = USB_SPEED_SUPER ,
2012-09-06 22:11:04 +04:00
. bind = eth_bind ,
2008-06-20 05:20:11 +04:00
. unbind = __exit_p ( eth_unbind ) ,
2005-04-17 02:20:36 +04:00
} ;
2008-06-20 05:20:11 +04:00
MODULE_DESCRIPTION ( PREFIX DRIVER_DESC ) ;
MODULE_AUTHOR ( " David Brownell, Benedikt Spanger " ) ;
MODULE_LICENSE ( " GPL " ) ;
2005-04-17 02:20:36 +04:00
2008-06-20 05:20:11 +04:00
static int __init init ( void )
2005-04-17 02:20:36 +04:00
{
2012-09-06 22:11:04 +04:00
return usb_composite_probe ( & eth_driver ) ;
2005-04-17 02:20:36 +04:00
}
2008-06-20 05:20:11 +04:00
module_init ( init ) ;
2005-04-17 02:20:36 +04:00
2008-06-20 05:20:11 +04:00
static void __exit cleanup ( void )
2005-04-17 02:20:36 +04:00
{
2008-06-20 05:20:11 +04:00
usb_composite_unregister ( & eth_driver ) ;
2005-04-17 02:20:36 +04:00
}
2008-06-20 05:20:11 +04:00
module_exit ( cleanup ) ;