[PATCH v4 32/46] usb/gadget: ether: convert to new interface of f_rndis

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx>
Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>
---
 drivers/usb/gadget/Kconfig |    1 +
 drivers/usb/gadget/ether.c |   39 ++++++++++++++++++++++++++++++++++++---
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 5e2a769..7310538 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -676,6 +676,7 @@ config USB_ETH
 	select USB_F_EEM
 	select USB_F_ECM
 	select USB_F_SUBSET
+	select USB_F_RNDIS
 	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 ebe8323..3833ea7 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -105,8 +105,7 @@ static inline bool has_rndis(void)
  * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
  */
 #ifdef	USB_ETH_RNDIS
-#define USB_FRNDIS_INCLUDED
-#include "f_rndis.c"
+#include "u_rndis.h"
 #include "rndis.h"
 #endif
 
@@ -219,6 +218,9 @@ static struct usb_function *f_ecm;
 static struct usb_function_instance *f_gether_inst;
 static struct usb_function *f_gether;
 
+static struct usb_function_instance *f_rndis_inst;
+static struct usb_function *f_rndis;
+
 /*-------------------------------------------------------------------------*/
 
 /*
@@ -228,6 +230,9 @@ static struct usb_function *f_gether;
  */
 static int __init rndis_do_config(struct usb_configuration *c)
 {
+	struct f_rndis_opts *rndis_opts;
+	int status;
+
 	/* FIXME alloc iConfiguration string, set it in c->strings */
 
 	if (gadget_is_otg(c->cdev->gadget)) {
@@ -235,7 +240,31 @@ static int __init rndis_do_config(struct usb_configuration *c)
 		c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
 	}
 
-	return rndis_bind_config(c, hostaddr, the_dev);
+	f_rndis_inst = usb_get_function_instance("rndis");
+	if (IS_ERR(f_rndis_inst))
+		return PTR_ERR(f_rndis_inst);
+
+	rndis_opts = container_of(f_rndis_inst, struct f_rndis_opts, func_inst);
+	rndis_opts->ethaddr = hostaddr;
+	rndis_opts->vendor_id = 0;
+	rndis_opts->manufacturer = NULL;
+	rndis_opts->dev = the_dev;
+
+	f_rndis = usb_get_function(f_rndis_inst);
+	if (IS_ERR(f_rndis)) {
+		status = PTR_ERR(f_rndis);
+		usb_put_function_instance(f_rndis_inst);
+		return status;
+	}
+
+	status = usb_add_function(c, f_rndis);
+	if (status < 0) {
+		usb_put_function(f_rndis);
+		usb_put_function_instance(f_rndis_inst);
+		return status;
+	}
+
+	return 0;
 }
 
 static struct usb_configuration rndis_config_driver = {
@@ -445,6 +474,10 @@ static int __exit eth_unbind(struct usb_composite_dev *cdev)
 		usb_put_function(f_gether);
 	if (!IS_ERR_OR_NULL(f_gether_inst))
 		usb_put_function_instance(f_gether_inst);
+	if (!IS_ERR_OR_NULL(f_rndis))
+		usb_put_function(f_rndis);
+	if (!IS_ERR_OR_NULL(f_rndis_inst))
+		usb_put_function_instance(f_rndis_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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux