Commit 9c62ce83 authored by Andrzej Pietrasiewicz's avatar Andrzej Pietrasiewicz Committed by Felipe Balbi

usb: gadget: ether: convert to new interface of f_ecm

moving to new interface so we can remove the older one.
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 bf4277c7
...@@ -622,6 +622,7 @@ config USB_ETH ...@@ -622,6 +622,7 @@ config USB_ETH
select USB_LIBCOMPOSITE select USB_LIBCOMPOSITE
select USB_U_ETHER select USB_U_ETHER
select USB_U_RNDIS select USB_U_RNDIS
select USB_F_ECM
select CRC32 select CRC32
help help
This driver implements Ethernet style communication, in one of This driver implements Ethernet style communication, in one of
......
...@@ -102,8 +102,7 @@ static inline bool has_rndis(void) ...@@ -102,8 +102,7 @@ static inline bool has_rndis(void)
* the runtime footprint, and giving us at least some parts of what * the runtime footprint, and giving us at least some parts of what
* a "gcc --combine ... part1.c part2.c part3.c ... " build would. * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
*/ */
#define USBF_ECM_INCLUDED #include "u_ecm.h"
#include "f_ecm.c"
#include "f_subset.c" #include "f_subset.c"
#ifdef USB_ETH_RNDIS #ifdef USB_ETH_RNDIS
#include "f_rndis.c" #include "f_rndis.c"
...@@ -212,6 +211,10 @@ static struct usb_gadget_strings *dev_strings[] = { ...@@ -212,6 +211,10 @@ static struct usb_gadget_strings *dev_strings[] = {
static u8 host_mac[ETH_ALEN]; static u8 host_mac[ETH_ALEN];
static struct eth_dev *the_dev; static struct eth_dev *the_dev;
static struct usb_function_instance *fi_ecm;
static struct usb_function *f_ecm;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* /*
...@@ -253,6 +256,8 @@ MODULE_PARM_DESC(use_eem, "use CDC EEM mode"); ...@@ -253,6 +256,8 @@ MODULE_PARM_DESC(use_eem, "use CDC EEM mode");
*/ */
static int __init eth_do_config(struct usb_configuration *c) static int __init eth_do_config(struct usb_configuration *c)
{ {
int status = 0;
/* FIXME alloc iConfiguration string, set it in c->strings */ /* FIXME alloc iConfiguration string, set it in c->strings */
if (gadget_is_otg(c->cdev->gadget)) { if (gadget_is_otg(c->cdev->gadget)) {
...@@ -262,10 +267,19 @@ static int __init eth_do_config(struct usb_configuration *c) ...@@ -262,10 +267,19 @@ static int __init eth_do_config(struct usb_configuration *c)
if (use_eem) if (use_eem)
return eem_bind_config(c, the_dev); return eem_bind_config(c, the_dev);
else if (can_support_ecm(c->cdev->gadget)) else if (can_support_ecm(c->cdev->gadget)) {
return ecm_bind_config(c, host_mac, the_dev); f_ecm = usb_get_function(fi_ecm);
else 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;
} else
return geth_bind_config(c, host_mac, the_dev); return geth_bind_config(c, host_mac, the_dev);
} }
static struct usb_configuration eth_config_driver = { static struct usb_configuration eth_config_driver = {
...@@ -280,13 +294,16 @@ static struct usb_configuration eth_config_driver = { ...@@ -280,13 +294,16 @@ static struct usb_configuration eth_config_driver = {
static int __init eth_bind(struct usb_composite_dev *cdev) static int __init eth_bind(struct usb_composite_dev *cdev)
{ {
struct usb_gadget *gadget = cdev->gadget; struct usb_gadget *gadget = cdev->gadget;
struct f_ecm_opts *ecm_opts = NULL;
int status; int status;
if (use_eem || !can_support_ecm(gadget)) {
/* set up network link layer */ /* set up network link layer */
the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac, the_dev = gether_setup(cdev->gadget, dev_addr, host_addr,
qmult); host_mac, qmult);
if (IS_ERR(the_dev)) if (IS_ERR(the_dev))
return PTR_ERR(the_dev); return PTR_ERR(the_dev);
}
/* set up main config label and device descriptor */ /* set up main config label and device descriptor */
if (use_eem) { if (use_eem) {
...@@ -294,8 +311,23 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -294,8 +311,23 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
eth_config_driver.label = "CDC Ethernet (EEM)"; eth_config_driver.label = "CDC Ethernet (EEM)";
device_desc.idVendor = cpu_to_le16(EEM_VENDOR_NUM); device_desc.idVendor = cpu_to_le16(EEM_VENDOR_NUM);
device_desc.idProduct = cpu_to_le16(EEM_PRODUCT_NUM); device_desc.idProduct = cpu_to_le16(EEM_PRODUCT_NUM);
} else if (can_support_ecm(cdev->gadget)) { } else if (can_support_ecm(gadget)) {
/* ECM */ /* ECM */
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);
gether_set_qmult(ecm_opts->net, qmult);
if (!gether_set_host_addr(ecm_opts->net, host_addr))
pr_info("using host ethernet address: %s", host_addr);
if (!gether_set_dev_addr(ecm_opts->net, dev_addr))
pr_info("using self ethernet address: %s", dev_addr);
the_dev = netdev_priv(ecm_opts->net);
eth_config_driver.label = "CDC Ethernet (ECM)"; eth_config_driver.label = "CDC Ethernet (ECM)";
} else { } else {
/* CDC Subset */ /* CDC Subset */
...@@ -309,6 +341,15 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -309,6 +341,15 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
if (has_rndis()) { if (has_rndis()) {
/* RNDIS plus ECM-or-Subset */ /* RNDIS plus ECM-or-Subset */
if (!use_eem && can_support_ecm(gadget)) {
gether_set_gadget(ecm_opts->net, cdev->gadget);
status = gether_register_netdev(ecm_opts->net);
if (status)
goto fail;
ecm_opts->bound = true;
gether_get_host_addr_u8(ecm_opts->net, host_mac);
}
device_desc.idVendor = cpu_to_le16(RNDIS_VENDOR_NUM); device_desc.idVendor = cpu_to_le16(RNDIS_VENDOR_NUM);
device_desc.idProduct = cpu_to_le16(RNDIS_PRODUCT_NUM); device_desc.idProduct = cpu_to_le16(RNDIS_PRODUCT_NUM);
device_desc.bNumConfigurations = 2; device_desc.bNumConfigurations = 2;
...@@ -343,13 +384,19 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -343,13 +384,19 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
return 0; return 0;
fail: fail:
if (use_eem || !can_support_ecm(gadget))
gether_cleanup(the_dev); gether_cleanup(the_dev);
else
usb_put_function_instance(fi_ecm);
return status; return status;
} }
static int __exit eth_unbind(struct usb_composite_dev *cdev) static int __exit eth_unbind(struct usb_composite_dev *cdev)
{ {
if (use_eem || !can_support_ecm(cdev->gadget))
gether_cleanup(the_dev); gether_cleanup(the_dev);
else
usb_put_function_instance(fi_ecm);
return 0; return 0;
} }
......
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