Commit 94b5573e authored by Andrzej Pietrasiewicz's avatar Andrzej Pietrasiewicz Committed by Felipe Balbi

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

use new interface so old one can be removed.
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 b29002a1
...@@ -681,6 +681,7 @@ config USB_ETH_EEM ...@@ -681,6 +681,7 @@ config USB_ETH_EEM
bool "Ethernet Emulation Model (EEM) support" bool "Ethernet Emulation Model (EEM) support"
depends on USB_ETH depends on USB_ETH
select USB_LIBCOMPOSITE select USB_LIBCOMPOSITE
select USB_F_EEM
default n default n
help help
CDC EEM is a newer USB standard that is somewhat simpler than CDC ECM CDC EEM is a newer USB standard that is somewhat simpler than CDC ECM
......
...@@ -109,8 +109,7 @@ static inline bool has_rndis(void) ...@@ -109,8 +109,7 @@ static inline bool has_rndis(void)
#include "rndis.h" #include "rndis.h"
#endif #endif
#define USB_FEEM_INCLUDED #include "u_eem.h"
#include "f_eem.c"
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
USB_GADGET_COMPOSITE_OPTIONS(); USB_GADGET_COMPOSITE_OPTIONS();
...@@ -217,6 +216,9 @@ static struct eth_dev *the_dev; ...@@ -217,6 +216,9 @@ static struct eth_dev *the_dev;
static struct usb_function_instance *fi_ecm; static struct usb_function_instance *fi_ecm;
static struct usb_function *f_ecm; static struct usb_function *f_ecm;
static struct usb_function_instance *fi_eem;
static struct usb_function *f_eem;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* /*
...@@ -267,9 +269,17 @@ static int __init eth_do_config(struct usb_configuration *c) ...@@ -267,9 +269,17 @@ static int __init eth_do_config(struct usb_configuration *c)
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
} }
if (use_eem) if (use_eem) {
return eem_bind_config(c, the_dev); f_eem = usb_get_function(fi_eem);
else if (can_support_ecm(c->cdev->gadget)) { 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)) {
f_ecm = usb_get_function(fi_ecm); f_ecm = usb_get_function(fi_ecm);
if (IS_ERR(f_ecm)) if (IS_ERR(f_ecm))
return PTR_ERR(f_ecm); return PTR_ERR(f_ecm);
...@@ -296,10 +306,11 @@ static struct usb_configuration eth_config_driver = { ...@@ -296,10 +306,11 @@ 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_eem_opts *eem_opts = NULL;
struct f_ecm_opts *ecm_opts = NULL; struct f_ecm_opts *ecm_opts = NULL;
int status; int status;
if (use_eem || !can_support_ecm(gadget)) { 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, the_dev = gether_setup(cdev->gadget, dev_addr, host_addr,
host_mac, qmult); host_mac, qmult);
...@@ -310,6 +321,20 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -310,6 +321,20 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
/* set up main config label and device descriptor */ /* set up main config label and device descriptor */
if (use_eem) { if (use_eem) {
/* EEM */ /* EEM */
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);
gether_set_qmult(eem_opts->net, qmult);
if (!gether_set_host_addr(eem_opts->net, host_addr))
pr_info("using host ethernet address: %s", host_addr);
if (!gether_set_dev_addr(eem_opts->net, dev_addr))
pr_info("using self ethernet address: %s", dev_addr);
the_dev = netdev_priv(eem_opts->net);
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);
...@@ -343,7 +368,14 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -343,7 +368,14 @@ 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)) { if (use_eem) {
gether_set_gadget(eem_opts->net, cdev->gadget);
status = gether_register_netdev(eem_opts->net);
if (status)
goto fail;
eem_opts->bound = true;
gether_get_host_addr_u8(eem_opts->net, host_mac);
} else if (can_support_ecm(gadget)) {
gether_set_gadget(ecm_opts->net, cdev->gadget); gether_set_gadget(ecm_opts->net, cdev->gadget);
status = gether_register_netdev(ecm_opts->net); status = gether_register_netdev(ecm_opts->net);
if (status) if (status)
...@@ -386,8 +418,10 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -386,8 +418,10 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
return 0; return 0;
fail: fail:
if (use_eem || !can_support_ecm(gadget)) if (!use_eem && !can_support_ecm(gadget))
gether_cleanup(the_dev); gether_cleanup(the_dev);
else if (use_eem)
usb_put_function_instance(fi_eem);
else else
usb_put_function_instance(fi_ecm); usb_put_function_instance(fi_ecm);
return status; return status;
...@@ -395,8 +429,10 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -395,8 +429,10 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
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)) if (!use_eem && !can_support_ecm(cdev->gadget))
gether_cleanup(the_dev); gether_cleanup(the_dev);
else if (use_eem)
usb_put_function_instance(fi_eem);
else else
usb_put_function_instance(fi_ecm); 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