usb: gadget: ether: convert to new interface of f_rndis
use new interface so old one can be removed. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
parent
f466c63538
commit
9bd4a10e1b
|
@ -694,6 +694,7 @@ config USB_ETH_RNDIS
|
|||
bool "RNDIS support"
|
||||
depends on USB_ETH
|
||||
select USB_LIBCOMPOSITE
|
||||
select USB_F_RNDIS
|
||||
default y
|
||||
help
|
||||
Microsoft Windows XP bundles the "Remote NDIS" (RNDIS) protocol,
|
||||
|
|
|
@ -94,23 +94,14 @@ static inline bool has_rndis(void)
|
|||
|
||||
#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_gether.h"
|
||||
#ifdef USB_ETH_RNDIS
|
||||
#define USB_FRNDIS_INCLUDED
|
||||
#include "f_rndis.c"
|
||||
#include "u_rndis.h"
|
||||
#include "rndis.h"
|
||||
#else
|
||||
#define rndis_borrow_net(...) do {} while (0)
|
||||
#endif
|
||||
|
||||
#include "u_eem.h"
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
@ -212,9 +203,6 @@ static struct usb_gadget_strings *dev_strings[] = {
|
|||
NULL,
|
||||
};
|
||||
|
||||
static u8 host_mac[ETH_ALEN];
|
||||
static struct eth_dev *the_dev;
|
||||
|
||||
static struct usb_function_instance *fi_ecm;
|
||||
static struct usb_function *f_ecm;
|
||||
|
||||
|
@ -224,6 +212,9 @@ static struct usb_function *f_eem;
|
|||
static struct usb_function_instance *fi_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;
|
|||
*/
|
||||
static int __init rndis_do_config(struct usb_configuration *c)
|
||||
{
|
||||
int status;
|
||||
|
||||
/* FIXME alloc iConfiguration string, set it in c->strings */
|
||||
|
||||
if (gadget_is_otg(c->cdev->gadget)) {
|
||||
|
@ -240,7 +233,15 @@ static int __init rndis_do_config(struct usb_configuration *c)
|
|||
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 = {
|
||||
|
@ -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);
|
||||
|
||||
net = eem_opts->net;
|
||||
the_dev = netdev_priv(net);
|
||||
|
||||
eth_config_driver.label = "CDC Ethernet (EEM)";
|
||||
device_desc.idVendor = cpu_to_le16(EEM_VENDOR_NUM);
|
||||
|
@ -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);
|
||||
|
||||
net = ecm_opts->net;
|
||||
the_dev = netdev_priv(net);
|
||||
|
||||
eth_config_driver.label = "CDC Ethernet (ECM)";
|
||||
} else {
|
||||
|
@ -365,7 +364,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
|
|||
func_inst);
|
||||
|
||||
net = geth_opts->net;
|
||||
the_dev = netdev_priv(net);
|
||||
|
||||
eth_config_driver.label = "CDC Subset/SAFE";
|
||||
|
||||
|
@ -387,7 +385,6 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
|
|||
status = gether_register_netdev(net);
|
||||
if (status)
|
||||
goto fail;
|
||||
gether_get_host_addr_u8(net, host_mac);
|
||||
|
||||
if (use_eem)
|
||||
eem_opts->bound = true;
|
||||
|
@ -396,6 +393,14 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
|
|||
else
|
||||
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.idProduct = cpu_to_le16(RNDIS_PRODUCT_NUM);
|
||||
device_desc.bNumConfigurations = 2;
|
||||
|
@ -407,7 +412,7 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
|
|||
|
||||
status = usb_string_ids_tab(cdev, strings_dev);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
goto fail1;
|
||||
device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_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)
|
|||
status = usb_add_config(cdev, &rndis_config_driver,
|
||||
rndis_do_config);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
goto fail1;
|
||||
}
|
||||
|
||||
status = usb_add_config(cdev, ð_config_driver, eth_do_config);
|
||||
if (status < 0)
|
||||
goto fail;
|
||||
goto fail1;
|
||||
|
||||
usb_composite_overwrite_options(cdev, &coverwrite);
|
||||
dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
|
||||
|
@ -429,6 +434,9 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
|
|||
|
||||
return 0;
|
||||
|
||||
fail1:
|
||||
if (has_rndis())
|
||||
usb_put_function_instance(fi_rndis);
|
||||
fail:
|
||||
if (use_eem)
|
||||
usb_put_function_instance(fi_eem);
|
||||
|
@ -441,6 +449,8 @@ fail:
|
|||
|
||||
static int __exit eth_unbind(struct usb_composite_dev *cdev)
|
||||
{
|
||||
if (has_rndis())
|
||||
usb_put_function_instance(fi_rndis);
|
||||
if (use_eem)
|
||||
usb_put_function_instance(fi_eem);
|
||||
else if (can_support_ecm(cdev->gadget))
|
||||
|
|
Loading…
Reference in New Issue