Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@xxxxxxxxxxx> Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx> --- drivers/usb/gadget/Kconfig | 1 + drivers/usb/gadget/nokia.c | 52 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 1f522fe..814f794 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -871,6 +871,7 @@ config USB_G_NOKIA select USB_U_SERIAL select USB_U_ETHER select USB_F_ACM + select USB_F_ECM help The Nokia composite gadget provides support for acm, obex and phonet in only one composite gadget driver. diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c index b27f3a3..5b98239 100644 --- a/drivers/usb/gadget/nokia.c +++ b/drivers/usb/gadget/nokia.c @@ -21,6 +21,7 @@ #include "u_serial.h" #include "u_ether.h" #include "u_phonet.h" +#include "u_ecm.h" #include "gadget_chips.h" /* Defines */ @@ -37,12 +38,9 @@ * the runtime footprint, and giving us at least some parts of what * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ -#define USB_FECM_INCLUDED -#include "f_ecm.c" #include "f_obex.c" #include "f_serial.c" #include "f_phonet.c" -#include "u_ether.h" /*-------------------------------------------------------------------------*/ USB_GADGET_COMPOSITE_OPTIONS(); @@ -99,6 +97,8 @@ MODULE_LICENSE("GPL"); /*-------------------------------------------------------------------------*/ static struct usb_function *f_acm_cfg1; static struct usb_function *f_acm_cfg2; +static struct usb_function *f_ecm_cfg1; +static struct usb_function *f_ecm_cfg2; static u8 hostaddr[ETH_ALEN]; static struct eth_dev *the_dev; @@ -127,10 +127,13 @@ static struct usb_configuration nokia_config_100ma_driver = { }; static struct usb_function_instance *fi_acm; +static struct usb_function_instance *fi_ecm; static int __init nokia_bind_config(struct usb_configuration *c) { struct usb_function *f_acm; + struct usb_function *f_ecm; + struct f_ecm_opts *ecm_opts; int status = 0; status = phonet_bind_config(c); @@ -149,24 +152,39 @@ static int __init nokia_bind_config(struct usb_configuration *c) if (IS_ERR(f_acm)) return PTR_ERR(f_acm); + ecm_opts = container_of(fi_ecm, struct f_ecm_opts, func_inst); + ecm_opts->ethaddr = hostaddr; + ecm_opts->dev = the_dev; + + f_ecm = usb_get_function(fi_ecm); + if (IS_ERR(f_ecm)) { + status = PTR_ERR(f_ecm); + goto err_get_ecm; + } + status = usb_add_function(c, f_acm); if (status) goto err_conf; - status = ecm_bind_config(c, hostaddr, the_dev); + status = usb_add_function(c, f_ecm); if (status) { pr_debug("could not bind ecm config %d\n", status); goto err_ecm; } - if (c == &nokia_config_500ma_driver) + if (c == &nokia_config_500ma_driver) { f_acm_cfg1 = f_acm; - else + f_ecm_cfg1 = f_ecm; + } else { f_acm_cfg2 = f_acm; + f_ecm_cfg2 = f_ecm; + } return status; err_ecm: usb_remove_function(c, f_acm); err_conf: + usb_put_function(f_ecm); +err_get_ecm: usb_put_function(f_acm); return status; } @@ -202,18 +220,28 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) nokia_config_500ma_driver.iConfiguration = status; nokia_config_100ma_driver.iConfiguration = status; - if (!gadget_supports_altsettings(gadget)) + if (!gadget_supports_altsettings(gadget)) { + status = -ENODEV; goto err_usb; + } fi_acm = usb_get_function_instance("acm"); - if (IS_ERR(fi_acm)) + if (IS_ERR(fi_acm)) { + status = PTR_ERR(fi_acm); goto err_usb; + } + + fi_ecm = usb_get_function_instance("ecm"); + if (IS_ERR(fi_ecm)) { + status = PTR_ERR(fi_ecm); + goto err_acm_inst; + } /* finally register the configuration */ status = usb_add_config(cdev, &nokia_config_500ma_driver, nokia_bind_config); if (status < 0) - goto err_acm_inst; + goto err_ecm_inst; status = usb_add_config(cdev, &nokia_config_100ma_driver, nokia_bind_config); @@ -227,6 +255,9 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) err_put_cfg1: usb_put_function(f_acm_cfg1); + usb_put_function(f_ecm_cfg1); +err_ecm_inst: + usb_put_function_instance(fi_ecm); err_acm_inst: usb_put_function_instance(fi_acm); err_usb: @@ -247,7 +278,10 @@ static int __exit nokia_unbind(struct usb_composite_dev *cdev) usb_put_function(f_acm_cfg1); usb_put_function(f_acm_cfg2); + usb_put_function(f_ecm_cfg1); + usb_put_function(f_ecm_cfg2); usb_put_function_instance(fi_acm); + usb_put_function_instance(fi_ecm); gphonet_cleanup(); for (i = 0; i < TTY_PORTS_MAX; i++) -- 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