Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx> Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx> --- drivers/usb/gadget/Kconfig | 1 + drivers/usb/gadget/g_ffs.c | 51 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 7310538..46cef77 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -806,6 +806,7 @@ config USB_FUNCTIONFS_RNDIS depends on USB_FUNCTIONFS && NET select USB_U_ETHER select USB_U_RNDIS + select USB_F_RNDIS help Include a configuration with RNDIS function (Ethernet) and the Filesystem. diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c index 664e685..deaa11a 100644 --- a/drivers/usb/gadget/g_ffs.c +++ b/drivers/usb/gadget/g_ffs.c @@ -31,8 +31,7 @@ # 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" # endif # include "u_ether.h" @@ -43,6 +42,11 @@ static struct eth_dev *the_dev; static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN], struct eth_dev *dev); # endif +# ifdef CONFIG_USB_FUNCTIONFS_RNDIS + +static int rndis_new_bind_config(struct usb_configuration *c, + u8 ethaddr[ETH_ALEN], struct eth_dev *dev); +# endif #else # define the_dev NULL # define gether_cleanup(dev) do { } while (0) @@ -147,7 +151,7 @@ static struct gfs_configuration { } gfs_configurations[] = { #ifdef CONFIG_USB_FUNCTIONFS_RNDIS { - .eth = rndis_bind_config, + .eth = rndis_new_bind_config, }, #endif @@ -574,3 +578,44 @@ static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN], } #endif + +#ifdef CONFIG_USB_FUNCTIONFS_RNDIS + +static int rndis_new_bind_config(struct usb_configuration *c, + u8 ethaddr[ETH_ALEN], struct eth_dev *dev) +{ + struct gfs_configuration *gfs_conf; + struct usb_function_instance *f_rndis_inst; + struct usb_function *f_rndis; + struct f_rndis_opts *rndis_opts; + int status; + + gfs_conf = to_gfs_configuration(c); + gfs_conf->fi = 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 = ethaddr; + rndis_opts->vendor_id = 0; + rndis_opts->manufacturer = NULL; + rndis_opts->dev = dev; + + gfs_conf->f = 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; +} + +#endif -- 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