Commit 5f72bbfd authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Felipe Balbi

usb: gadget: acm_ms: use function framework for ACM

This patch converts the acm_ms gadget to make use of the function
framework to request the ACM function.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent ff47f594
...@@ -844,6 +844,7 @@ config USB_G_ACM_MS ...@@ -844,6 +844,7 @@ config USB_G_ACM_MS
depends on BLOCK depends on BLOCK
select USB_LIBCOMPOSITE select USB_LIBCOMPOSITE
select USB_U_SERIAL select USB_U_SERIAL
select USB_F_ACM
help help
This driver provides two functions in one configuration: This driver provides two functions in one configuration:
a mass storage, and a CDC ACM (serial port) link. a mass storage, and a CDC ACM (serial port) link.
......
...@@ -40,8 +40,6 @@ ...@@ -40,8 +40,6 @@
* the runtime footprint, and giving us at least some parts of what * the runtime footprint, and giving us at least some parts of what
* a "gcc --combine ... part1.c part2.c part3.c ... " build would. * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
*/ */
#define USB_FACM_INCLUDED
#include "f_acm.c"
#include "f_mass_storage.c" #include "f_mass_storage.c"
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
...@@ -112,12 +110,14 @@ static struct fsg_common fsg_common; ...@@ -112,12 +110,14 @@ static struct fsg_common fsg_common;
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static unsigned char tty_line; static unsigned char tty_line;
static struct usb_function *f_acm;
static struct usb_function_instance *f_acm_inst;
/* /*
* We _always_ have both ACM and mass storage functions. * We _always_ have both ACM and mass storage functions.
*/ */
static int __init acm_ms_do_config(struct usb_configuration *c) static int __init acm_ms_do_config(struct usb_configuration *c)
{ {
struct f_serial_opts *opts;
int status; int status;
if (gadget_is_otg(c->cdev->gadget)) { if (gadget_is_otg(c->cdev->gadget)) {
...@@ -125,16 +125,35 @@ static int __init acm_ms_do_config(struct usb_configuration *c) ...@@ -125,16 +125,35 @@ static int __init acm_ms_do_config(struct usb_configuration *c)
c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
} }
f_acm_inst = usb_get_function_instance("acm");
if (IS_ERR(f_acm_inst))
return PTR_ERR(f_acm_inst);
opts = container_of(f_acm_inst, struct f_serial_opts, func_inst);
opts->port_num = tty_line;
f_acm = usb_get_function(f_acm_inst);
if (IS_ERR(f_acm)) {
status = PTR_ERR(f_acm);
goto err_func;
}
status = acm_bind_config(c, tty_line); status = usb_add_function(c, f_acm);
if (status < 0) if (status < 0)
return status; goto err_conf;
status = fsg_bind_config(c->cdev, c, &fsg_common); status = fsg_bind_config(c->cdev, c, &fsg_common);
if (status < 0) if (status < 0)
return status; goto err_fsg;
return 0; return 0;
err_fsg:
usb_remove_function(c, f_acm);
err_conf:
usb_put_function(f_acm);
err_func:
usb_put_function_instance(f_acm_inst);
return status;
} }
static struct usb_configuration acm_ms_config_driver = { static struct usb_configuration acm_ms_config_driver = {
...@@ -195,6 +214,8 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev) ...@@ -195,6 +214,8 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev)
static int __exit acm_ms_unbind(struct usb_composite_dev *cdev) static int __exit acm_ms_unbind(struct usb_composite_dev *cdev)
{ {
usb_put_function(f_acm);
usb_put_function_instance(f_acm_inst);
gserial_free_line(tty_line); gserial_free_line(tty_line);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment