This patch converts the acm_ms gadget to make use of the function
framework to request the ACM function.

Signed-off-by: Sebastian Andrzej Siewior <bige...@linutronix.de>
---
 drivers/usb/gadget/Kconfig |    1 +
 drivers/usb/gadget/cdc2.c  |   25 ++++++++++++++++++++-----
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 967ea01..2401595 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -846,6 +846,7 @@ config USB_CDC_COMPOSITE
        depends on NET
        select USB_LIBCOMPOSITE
        select USB_U_SERIAL
+       select USB_F_ACM
        help
          This driver provides two functions in one configuration:
          a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link.
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index fa7a26c..3e8d331 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -42,8 +42,6 @@ USB_GADGET_COMPOSITE_OPTIONS();
  * 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_FACM_INCLUDED
-#include "f_acm.c"
 #include "f_ecm.c"
 #include "u_ether.c"
 
@@ -107,12 +105,19 @@ static struct usb_gadget_strings *dev_strings[] = {
 static u8 hostaddr[ETH_ALEN];
 
 /*-------------------------------------------------------------------------*/
+static struct usb_function *f_acm;
 
 /*
  * We _always_ have both CDC ECM and CDC ACM functions.
  */
 static int __init cdc_do_config(struct usb_configuration *c)
 {
+       struct usbf_option f_options[] = {
+               {
+                       .name = "port_num",
+                       .val.o_int = 0,
+               },
+       };
        int     status;
 
        if (gadget_is_otg(c->cdev->gadget)) {
@@ -124,11 +129,20 @@ static int __init cdc_do_config(struct usb_configuration 
*c)
        if (status < 0)
                return status;
 
-       status = acm_bind_config(c, 0);
-       if (status < 0)
-               return status;
+       f_acm = usb_get_function("acm");
+       if (IS_ERR(f_acm))
+               return PTR_ERR(f_acm);
 
+       status = usbf_configure(f_acm, f_options);
+       if (status)
+               goto err_conf;
+       status = usb_add_function(c, f_acm);
+       if (status)
+               goto err_conf;
        return 0;
+err_conf:
+       usb_put_function(f_acm);
+       return status;
 }
 
 static struct usb_configuration cdc_config_driver = {
@@ -191,6 +205,7 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
 
 static int __exit cdc_unbind(struct usb_composite_dev *cdev)
 {
+       usb_put_function(f_acm);
        gserial_cleanup();
        gether_cleanup();
        return 0;
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to