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

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

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 f466c635
...@@ -694,6 +694,7 @@ config USB_ETH_RNDIS ...@@ -694,6 +694,7 @@ config USB_ETH_RNDIS
bool "RNDIS support" bool "RNDIS support"
depends on USB_ETH depends on USB_ETH
select USB_LIBCOMPOSITE select USB_LIBCOMPOSITE
select USB_F_RNDIS
default y default y
help help
Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol, Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol,
......
...@@ -94,23 +94,14 @@ static inline bool has_rndis(void) ...@@ -94,23 +94,14 @@ static inline bool has_rndis(void)
#include <linux/module.h> #include <linux/module.h>
/*-------------------------------------------------------------------------*/
/*
* Kbuild is not very cooperative with respect to linking separately
* compiled library objects into one module. So for now we won't use
* separate compilation ... ensuring init/exit sections work to shrink
* the runtime footprint, and giving us at least some parts of what
* a "gcc --combine ... part1.c part2.c part3.c ... " build would.
*/
#include "u_ecm.h" #include "u_ecm.h"
#include "u_gether.h" #include "u_gether.h"
#ifdef USB_ETH_RNDIS #ifdef USB_ETH_RNDIS
#define USB_FRNDIS_INCLUDED #include "u_rndis.h"
#include "f_rndis.c"
#include "rndis.h" #include "rndis.h"
#else
#define rndis_borrow_net(...) do {} while (0)
#endif #endif
#include "u_eem.h" #include "u_eem.h"
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -212,9 +203,6 @@ static struct usb_gadget_strings *dev_strings[] = { ...@@ -212,9 +203,6 @@ static struct usb_gadget_strings *dev_strings[] = {
NULL, NULL,
}; };
static u8 host_mac[ETH_ALEN];
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;
...@@ -224,6 +212,9 @@ static struct usb_function *f_eem; ...@@ -224,6 +212,9 @@ static struct usb_function *f_eem;
static struct usb_function_instance *fi_geth; static struct usb_function_instance *fi_geth;
static struct usb_function *f_geth; static struct usb_function *f_geth;
static struct usb_function_instance *fi_rndis;
static struct usb_function *f_rndis;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* /*
...@@ -233,6 +224,8 @@ static struct usb_function *f_geth; ...@@ -233,6 +224,8 @@ static struct usb_function *f_geth;
*/ */
static int __init rndis_do_config(struct usb_configuration *c) static int __init rndis_do_config(struct usb_configuration *c)
{ {
int status;
/* 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)) {
...@@ -240,7 +233,15 @@ static int __init rndis_do_config(struct usb_configuration *c) ...@@ -240,7 +233,15 @@ static int __init rndis_do_config(struct usb_configuration *c)
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
} }
return rndis_bind_config(c, host_mac, the_dev); f_rndis = usb_get_function(fi_rndis);
if (IS_ERR(f_rndis))
return PTR_ERR(f_rndis);
status = usb_add_function(c, f_rndis);
if (status < 0)
usb_put_function(f_rndis);
return status;
} }
static struct usb_configuration rndis_config_driver = { static struct usb_configuration rndis_config_driver = {
...@@ -336,7 +337,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -336,7 +337,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
eem_opts = container_of(fi_eem, struct f_eem_opts, func_inst); eem_opts = container_of(fi_eem, struct f_eem_opts, func_inst);
net = eem_opts->net; net = eem_opts->net;
the_dev = netdev_priv(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);
...@@ -351,7 +351,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -351,7 +351,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst); ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst);
net = ecm_opts->net; net = ecm_opts->net;
the_dev = netdev_priv(net);
eth_config_driver.label = "CDC Ethernet (ECM)"; eth_config_driver.label = "CDC Ethernet (ECM)";
} else { } else {
...@@ -365,7 +364,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -365,7 +364,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
func_inst); func_inst);
net = geth_opts->net; net = geth_opts->net;
the_dev = netdev_priv(net);
eth_config_driver.label = "CDC Subset/SAFE"; eth_config_driver.label = "CDC Subset/SAFE";
...@@ -387,7 +385,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -387,7 +385,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
status = gether_register_netdev(net); status = gether_register_netdev(net);
if (status) if (status)
goto fail; goto fail;
gether_get_host_addr_u8(net, host_mac);
if (use_eem) if (use_eem)
eem_opts->bound = true; eem_opts->bound = true;
...@@ -396,6 +393,14 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -396,6 +393,14 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
else else
geth_opts->bound = true; geth_opts->bound = true;
fi_rndis = usb_get_function_instance("rndis");
if (IS_ERR(fi_rndis)) {
status = PTR_ERR(fi_rndis);
goto fail;
}
rndis_borrow_net(fi_rndis, net);
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;
...@@ -407,7 +412,7 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -407,7 +412,7 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
status = usb_string_ids_tab(cdev, strings_dev); status = usb_string_ids_tab(cdev, strings_dev);
if (status < 0) if (status < 0)
goto fail; goto fail1;
device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id; device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id; device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
...@@ -416,12 +421,12 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -416,12 +421,12 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
status = usb_add_config(cdev, &rndis_config_driver, status = usb_add_config(cdev, &rndis_config_driver,
rndis_do_config); rndis_do_config);
if (status < 0) if (status < 0)
goto fail; goto fail1;
} }
status = usb_add_config(cdev, &eth_config_driver, eth_do_config); status = usb_add_config(cdev, &eth_config_driver, eth_do_config);
if (status < 0) if (status < 0)
goto fail; goto fail1;
usb_composite_overwrite_options(cdev, &coverwrite); usb_composite_overwrite_options(cdev, &coverwrite);
dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
...@@ -429,6 +434,9 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -429,6 +434,9 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
return 0; return 0;
fail1:
if (has_rndis())
usb_put_function_instance(fi_rndis);
fail: fail:
if (use_eem) if (use_eem)
usb_put_function_instance(fi_eem); usb_put_function_instance(fi_eem);
...@@ -441,6 +449,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) ...@@ -441,6 +449,8 @@ 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 (has_rndis())
usb_put_function_instance(fi_rndis);
if (use_eem) if (use_eem)
usb_put_function_instance(fi_eem); usb_put_function_instance(fi_eem);
else if (can_support_ecm(cdev->gadget)) else if (can_support_ecm(cdev->gadget))
......
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