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/acm_ms.c |   30 +++++++++++++++++++++++-------
 2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index 66bc3ab..967ea01 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -874,6 +874,7 @@ config USB_G_ACM_MS
        depends on BLOCK
        select USB_LIBCOMPOSITE
        select USB_U_SERIAL
+       select USB_F_ACM
        help
          This driver provides two functions in one configuration:
          a mass storage, and a CDC ACM (serial port) link.
diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index 4c5f116..da4a8ca 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -40,8 +40,6 @@
  * 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_mass_storage.c"
 
 /*-------------------------------------------------------------------------*/
@@ -111,29 +109,47 @@ FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data);
 static struct fsg_common fsg_common;
 
 /*-------------------------------------------------------------------------*/
-
+static struct usb_function *f_acm;
 /*
  * We _always_ have both ACM and mass storage functions.
  */
 static int __init acm_ms_do_config(struct usb_configuration *c)
 {
        int     status;
+       struct usbf_option f_options[] = {
+               {
+                       .name = "port_num",
+                       .val.o_int = 0,
+               },
+       };
 
        if (gadget_is_otg(c->cdev->gadget)) {
                c->descriptors = otg_desc;
                c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
        }
 
+       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 = acm_bind_config(c, 0);
+       status = usb_add_function(c, f_acm);
        if (status < 0)
-               return status;
+               goto err_conf;
 
        status = fsg_bind_config(c->cdev, c, &fsg_common);
        if (status < 0)
-               return status;
+               goto err_fsg;
 
        return 0;
+err_fsg:
+       usb_remove_function(c, f_acm);
+err_conf:
+       usb_put_function(f_acm);
+       return status;
 }
 
 static struct usb_configuration acm_ms_config_driver = {
@@ -194,8 +210,8 @@ static int __init acm_ms_bind(struct usb_composite_dev 
*cdev)
 
 static int __exit acm_ms_unbind(struct usb_composite_dev *cdev)
 {
+       usb_put_function(f_acm);
        gserial_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