mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
usb ethernet gadget: split CDC Ethernet function
This is a "CDC Ethernet" (ECM) function driver, extracted from the all-in-one Ethernet gadget driver. This is a good example of how to implement interface altsettings. In fact it's currently the only such example in the gadget stack, pending addition of OBEX support. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
8a40819e97
commit
da741b8c56
@@ -25,7 +25,7 @@ obj-$(CONFIG_USB_M66592) += m66592-udc.o
|
||||
C_UTILS = composite.o usbstring.o config.o epautoconf.o
|
||||
|
||||
g_zero-objs := zero.o f_sourcesink.o f_loopback.o $(C_UTILS)
|
||||
g_ether-objs := ether.o u_ether.o f_subset.o $(C_UTILS)
|
||||
g_ether-objs := ether.o u_ether.o f_subset.o f_ecm.o $(C_UTILS)
|
||||
g_serial-objs := serial.o u_serial.o f_acm.o f_serial.o $(C_UTILS)
|
||||
g_midi-objs := gmidi.o usbstring.o config.o epautoconf.o
|
||||
gadgetfs-objs := inode.o
|
||||
|
||||
833
drivers/usb/gadget/f_ecm.c
Normal file
833
drivers/usb/gadget/f_ecm.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -214,3 +214,26 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget)
|
||||
return 0x21;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gadget_supports_altsettings - return true if altsettings work
|
||||
* @gadget: the gadget in question
|
||||
*/
|
||||
static inline bool gadget_supports_altsettings(struct usb_gadget *gadget)
|
||||
{
|
||||
/* PXA 21x/25x/26x has no altsettings at all */
|
||||
if (gadget_is_pxa(gadget))
|
||||
return false;
|
||||
|
||||
/* PXA 27x and 3xx have *broken* altsetting support */
|
||||
if (gadget_is_pxa27x(gadget))
|
||||
return false;
|
||||
|
||||
/* SH3 hardware just doesn't do altsettings */
|
||||
if (gadget_is_sh(gadget))
|
||||
return false;
|
||||
|
||||
/* Everything else is *presumably* fine ... */
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@
|
||||
#include <linux/usb/composite.h>
|
||||
#include <linux/usb/cdc.h>
|
||||
|
||||
#include "gadget_chips.h"
|
||||
|
||||
|
||||
/*
|
||||
* This represents the USB side of an "ethernet" link, managed by a USB
|
||||
* function which provides control and (maybe) framing. Two functions
|
||||
@@ -80,7 +83,28 @@ void gether_cleanup(void);
|
||||
struct net_device *gether_connect(struct gether *);
|
||||
void gether_disconnect(struct gether *);
|
||||
|
||||
/* Some controllers can't support CDC Ethernet (ECM) ... */
|
||||
static inline bool can_support_ecm(struct usb_gadget *gadget)
|
||||
{
|
||||
if (!gadget_supports_altsettings(gadget))
|
||||
return false;
|
||||
|
||||
/* SA1100 can do ECM, *without* status endpoint ... but we'll
|
||||
* only use it in non-ECM mode for backwards compatibility
|
||||
* (and since we currently require a status endpoint)
|
||||
*/
|
||||
if (gadget_is_sa1100(gadget))
|
||||
return false;
|
||||
|
||||
/* Everything else is *presumably* fine ... but this is a bit
|
||||
* chancy, so be **CERTAIN** there are no hardware issues with
|
||||
* your controller. Add it above if it can't handle CDC.
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/* each configuration may bind one instance of an ethernet link */
|
||||
int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]);
|
||||
int ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN]);
|
||||
|
||||
#endif /* __U_ETHER_H */
|
||||
|
||||
Reference in New Issue
Block a user