summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/f_acm.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2013-01-25 14:09:17 +0100
committerFelipe Balbi <balbi@ti.com>2013-04-03 14:43:20 +0300
commit15761826eecda192f4d1527e08c32193a03e94b7 (patch)
tree5347a1009b229921d762458a95d480c429cac798 /drivers/usb/gadget/f_acm.c
parent588233733804aeaf16335a32904aaa4d15b9bddd (diff)
usb: gadget: nokia: use function framework for ACM
This patch converts the acm_ms gadget to make use of the function framework to request the ACM function. The "old" include interface for acm is now removed since nokia was the last user of it (for ACM). Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/f_acm.c')
-rw-r--r--drivers/usb/gadget/f_acm.c83
1 files changed, 15 insertions, 68 deletions
diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
index 1ae180baa597..61b33d23be72 100644
--- a/drivers/usb/gadget/f_acm.c
+++ b/drivers/usb/gadget/f_acm.c
@@ -715,72 +715,6 @@ fail:
return status;
}
-static struct f_acm *acm_alloc_basic_func(void)
-{
- struct f_acm *acm;
-
- acm = kzalloc(sizeof(*acm), GFP_KERNEL);
- if (!acm)
- return NULL;
-
- spin_lock_init(&acm->lock);
-
- acm->port.connect = acm_connect;
- acm->port.disconnect = acm_disconnect;
- acm->port.send_break = acm_send_break;
-
- acm->port.func.name = "acm";
- /* descriptors are per-instance copies */
- acm->port.func.bind = acm_bind;
- acm->port.func.set_alt = acm_set_alt;
- acm->port.func.setup = acm_setup;
- acm->port.func.disable = acm_disable;
-
- return acm;
-}
-
-#ifdef USB_FACM_INCLUDED
-static void
-acm_old_unbind(struct usb_configuration *c, struct usb_function *f)
-{
- struct f_acm *acm = func_to_acm(f);
-
- usb_free_all_descriptors(f);
- if (acm->notify_req)
- gs_free_req(acm->notify, acm->notify_req);
- kfree(acm);
-}
-
-/**
- * acm_bind_config - add a CDC ACM function to a configuration
- * @c: the configuration to support the CDC ACM instance
- * @port_num: /dev/ttyGS* port this interface will use
- * Context: single threaded during gadget setup
- *
- * Returns zero on success, else negative errno.
- *
- */
-int acm_bind_config(struct usb_configuration *c, u8 port_num)
-{
- struct f_acm *acm;
- int status;
-
- /* allocate and initialize one new instance */
- acm = acm_alloc_basic_func();
- if (!acm)
- return -ENOMEM;
-
- acm->port_num = port_num;
- acm->port.func.unbind = acm_old_unbind;
-
- status = usb_add_function(c, &acm->port.func);
- if (status)
- kfree(acm);
- return status;
-}
-
-#else
-
static void acm_unbind(struct usb_configuration *c, struct usb_function *f)
{
struct f_acm *acm = func_to_acm(f);
@@ -803,10 +737,24 @@ static struct usb_function *acm_alloc_func(struct usb_function_instance *fi)
struct f_serial_opts *opts;
struct f_acm *acm;
- acm = acm_alloc_basic_func();
+ acm = kzalloc(sizeof(*acm), GFP_KERNEL);
if (!acm)
return ERR_PTR(-ENOMEM);
+ spin_lock_init(&acm->lock);
+
+ acm->port.connect = acm_connect;
+ acm->port.disconnect = acm_disconnect;
+ acm->port.send_break = acm_send_break;
+
+ acm->port.func.name = "acm";
+ acm->port.func.strings = acm_strings;
+ /* descriptors are per-instance copies */
+ acm->port.func.bind = acm_bind;
+ acm->port.func.set_alt = acm_set_alt;
+ acm->port.func.setup = acm_setup;
+ acm->port.func.disable = acm_disable;
+
opts = container_of(fi, struct f_serial_opts, func_inst);
acm->port_num = opts->port_num;
acm->port.func.unbind = acm_unbind;
@@ -835,4 +783,3 @@ static struct usb_function_instance *acm_alloc_instance(void)
}
DECLARE_USB_FUNCTION_INIT(acm, acm_alloc_instance, acm_alloc_func);
MODULE_LICENSE("GPL");
-#endif