Signed-off-by: Andrzej Pietrasiewicz <[email protected]>
Signed-off-by: Kyungmin Park <[email protected]>
---
drivers/usb/gadget/Kconfig | 1 +
drivers/usb/gadget/ether.c | 44 ++++++++++++++++++++++++++++++++++++++------
2 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 92fa9ae..8dda6e2 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -664,6 +664,7 @@ config USB_ETH
select USB_LIBCOMPOSITE
select USB_U_ETHER
select USB_U_RNDIS
+ select USB_F_EEM
select CRC32
help
This driver implements Ethernet style communication, in one of
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 9bf537e..41e3867 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -23,6 +23,7 @@
#endif
#include "u_ether.h"
+#include "u_eem.h"
/*
@@ -109,9 +110,6 @@ static inline bool has_rndis(void)
#include "rndis.h"
#endif
-#define USB_FEEM_INCLUDED
-#include "f_eem.c"
-
/*-------------------------------------------------------------------------*/
USB_GADGET_COMPOSITE_OPTIONS();
@@ -211,6 +209,10 @@ static struct usb_gadget_strings *dev_strings[] = {
static u8 hostaddr[ETH_ALEN];
static struct eth_dev *the_dev;
+
+static struct usb_function_instance *f_eem_inst;
+static struct usb_function *f_eem;
+
/*-------------------------------------------------------------------------*/
/*
@@ -259,9 +261,35 @@ static int __init eth_do_config(struct usb_configuration
*c)
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
- if (use_eem)
- return eem_bind_config(c, the_dev);
- else if (can_support_ecm(c->cdev->gadget))
+ if (use_eem) {
+ struct f_eem_opts *eem_opts;
+ int status;
+
+ f_eem_inst = usb_get_function_instance("eem");
+ if (IS_ERR(f_eem_inst))
+ return PTR_ERR(f_eem_inst);
+
+ eem_opts = container_of(f_eem_inst, struct f_eem_opts,
+ func_inst);
+ eem_opts->dev = the_dev;
+
+ f_eem = usb_get_function(f_eem_inst);
+ if (IS_ERR(f_eem)) {
+ status = PTR_ERR(f_eem);
+ usb_put_function_instance(f_eem_inst);
+ return status;
+ }
+
+ status = usb_add_function(c, f_eem);
+ if (status < 0) {
+ usb_put_function(f_eem);
+ usb_put_function_instance(f_eem_inst);
+ return status;
+ }
+
+ return 0;
+
+ } else if (can_support_ecm(c->cdev->gadget))
return ecm_bind_config(c, hostaddr, the_dev);
else
return geth_bind_config(c, hostaddr, the_dev);
@@ -348,6 +376,10 @@ fail:
static int __exit eth_unbind(struct usb_composite_dev *cdev)
{
gether_cleanup(the_dev);
+ if (!IS_ERR_OR_NULL(f_eem))
+ usb_put_function(f_eem);
+ if (!IS_ERR_OR_NULL(f_eem_inst))
+ usb_put_function_instance(f_eem_inst);
return 0;
}
--
1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html