Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1a1823f authored by Andrzej Pietrasiewicz's avatar Andrzej Pietrasiewicz Committed by Felipe Balbi
Browse files

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: default avatarAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent d68c277b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -499,6 +499,9 @@ config USB_F_SS_LB
config USB_U_SERIAL
	tristate

config USB_U_ETHER
	tristate

config USB_F_SERIAL
	tristate

@@ -595,6 +598,7 @@ config USB_ETH
	tristate "Ethernet Gadget (with CDC Ethernet support)"
	depends on NET
	select USB_LIBCOMPOSITE
	select USB_U_ETHER
	select CRC32
	help
	  This driver implements Ethernet style communication, in one of
@@ -667,6 +671,7 @@ config USB_G_NCM
	tristate "Network Control Model (NCM) support"
	depends on NET
	select USB_LIBCOMPOSITE
	select USB_U_ETHER
	select CRC32
	help
	  This driver implements USB CDC NCM subclass standard. NCM is
@@ -710,6 +715,7 @@ config USB_FUNCTIONFS
config USB_FUNCTIONFS_ETH
	bool "Include configuration with CDC ECM (Ethernet)"
	depends on USB_FUNCTIONFS && NET
	select USB_U_ETHER
	help
	  Include a configuration with CDC ECM function (Ethernet) and the
	  Function Filesystem.
@@ -717,6 +723,7 @@ config USB_FUNCTIONFS_ETH
config USB_FUNCTIONFS_RNDIS
	bool "Include configuration with RNDIS (Ethernet)"
	depends on USB_FUNCTIONFS && NET
	select USB_U_ETHER
	help
	  Include a configuration with RNDIS function (Ethernet) and the Filesystem.

@@ -817,6 +824,7 @@ config USB_CDC_COMPOSITE
	depends on NET
	select USB_LIBCOMPOSITE
	select USB_U_SERIAL
	select USB_U_ETHER
	select USB_F_ACM
	help
	  This driver provides two functions in one configuration:
@@ -834,6 +842,7 @@ config USB_G_NOKIA
	depends on PHONET
	select USB_LIBCOMPOSITE
	select USB_U_SERIAL
	select USB_U_ETHER
	select USB_F_ACM
	help
	  The Nokia composite gadget provides support for acm, obex
@@ -861,6 +870,7 @@ config USB_G_MULTI
	select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS
	select USB_LIBCOMPOSITE
	select USB_U_SERIAL
	select USB_U_ETHER
	select USB_F_ACM
	help
	  The Multifunction Composite Gadget provides Ethernet (RNDIS
+1 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ usb_f_serial-y := f_serial.o
obj-$(CONFIG_USB_F_SERIAL)	+= usb_f_serial.o
usb_f_obex-y			:= f_obex.o
obj-$(CONFIG_USB_F_OBEX)	+= usb_f_obex.o
obj-$(CONFIG_USB_U_ETHER)	+= u_ether.o

#
# USB gadget drivers
+6 −4
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@
/*-------------------------------------------------------------------------*/
USB_GADGET_COMPOSITE_OPTIONS();

USB_ETHERNET_MODULE_PARAMETERS();

/*
 * Kbuild is not very cooperative with respect to linking separately
 * compiled library objects into one module.  So for now we won't use
@@ -43,7 +45,6 @@ USB_GADGET_COMPOSITE_OPTIONS();
 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
 */
#include "f_ecm.c"
#include "u_ether.c"

/*-------------------------------------------------------------------------*/

@@ -102,7 +103,7 @@ static struct usb_gadget_strings *dev_strings[] = {
	NULL,
};

static u8 hostaddr[ETH_ALEN];
static u8 host_mac[ETH_ALEN];
static struct eth_dev *the_dev;
/*-------------------------------------------------------------------------*/
static struct usb_function *f_acm;
@@ -120,7 +121,7 @@ static int __init cdc_do_config(struct usb_configuration *c)
		c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
	}

	status = ecm_bind_config(c, hostaddr, the_dev);
	status = ecm_bind_config(c, host_mac, the_dev);
	if (status < 0)
		return status;

@@ -166,7 +167,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
	}

	/* set up network link layer */
	the_dev = gether_setup(cdev->gadget, hostaddr);
	the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
			       qmult);
	if (IS_ERR(the_dev))
		return PTR_ERR(the_dev);

+8 −6
Original line number Diff line number Diff line
@@ -107,11 +107,12 @@ static inline bool has_rndis(void)
#include "rndis.c"
#endif
#include "f_eem.c"
#include "u_ether.c"

/*-------------------------------------------------------------------------*/
USB_GADGET_COMPOSITE_OPTIONS();

USB_ETHERNET_MODULE_PARAMETERS();

/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!!  Ever!!
 * Instead:  allocate your own, using normal USB-IF procedures.
 */
@@ -206,7 +207,7 @@ static struct usb_gadget_strings *dev_strings[] = {
	NULL,
};

static u8 hostaddr[ETH_ALEN];
static u8 host_mac[ETH_ALEN];
static struct eth_dev *the_dev;
/*-------------------------------------------------------------------------*/

@@ -224,7 +225,7 @@ static int __init rndis_do_config(struct usb_configuration *c)
		c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
	}

	return rndis_bind_config(c, hostaddr, the_dev);
	return rndis_bind_config(c, host_mac, the_dev);
}

static struct usb_configuration rndis_config_driver = {
@@ -259,9 +260,9 @@ static int __init eth_do_config(struct usb_configuration *c)
	if (use_eem)
		return eem_bind_config(c, the_dev);
	else if (can_support_ecm(c->cdev->gadget))
		return ecm_bind_config(c, hostaddr, the_dev);
		return ecm_bind_config(c, host_mac, the_dev);
	else
		return geth_bind_config(c, hostaddr, the_dev);
		return geth_bind_config(c, host_mac, the_dev);
}

static struct usb_configuration eth_config_driver = {
@@ -279,7 +280,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
	int			status;

	/* set up network link layer */
	the_dev = gether_setup(cdev->gadget, hostaddr);
	the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
			       qmult);
	if (IS_ERR(the_dev))
		return PTR_ERR(the_dev);

+8 −5
Original line number Diff line number Diff line
@@ -34,9 +34,9 @@
#    include "f_rndis.c"
#    include "rndis.c"
#  endif
#  include "u_ether.c"
#  include "u_ether.h"

static u8 gfs_hostaddr[ETH_ALEN];
static u8 gfs_host_mac[ETH_ALEN];
static struct eth_dev *the_dev;
#  ifdef CONFIG_USB_FUNCTIONFS_ETH
static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
@@ -45,7 +45,7 @@ static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
#else
#  define the_dev	NULL
#  define gether_cleanup(dev) do { } while (0)
#  define gfs_hostaddr NULL
#  define gfs_host_mac NULL
struct eth_dev;
#endif

@@ -73,6 +73,8 @@ struct gfs_ffs_obj {

USB_GADGET_COMPOSITE_OPTIONS();

USB_ETHERNET_MODULE_PARAMETERS();

static struct usb_device_descriptor gfs_dev_desc = {
	.bLength		= sizeof gfs_dev_desc,
	.bDescriptorType	= USB_DT_DEVICE,
@@ -350,7 +352,8 @@ static int gfs_bind(struct usb_composite_dev *cdev)
	if (missing_funcs)
		return -ENODEV;
#if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
	the_dev = gether_setup(cdev->gadget, gfs_hostaddr);
	the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, gfs_host_mac,
			       qmult);
#endif
	if (IS_ERR(the_dev)) {
		ret = PTR_ERR(the_dev);
@@ -446,7 +449,7 @@ static int gfs_do_config(struct usb_configuration *c)
	}

	if (gc->eth) {
		ret = gc->eth(c, gfs_hostaddr, the_dev);
		ret = gc->eth(c, gfs_host_mac, the_dev);
		if (unlikely(ret < 0))
			return ret;
	}
Loading