Commit da741b8c authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

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: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 8a40819e
......@@ -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
......
This diff is collapsed.
......@@ -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 */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment