aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/f_acm.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2013-01-25 08:09:17 -0500
committerFelipe Balbi <balbi@ti.com>2013-04-03 07:43:20 -0400
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:
715 return status; 715 return status;
716} 716}
717 717
718static struct f_acm *acm_alloc_basic_func(void)
719{
720 struct f_acm *acm;
721
722 acm = kzalloc(sizeof(*acm), GFP_KERNEL);
723 if (!acm)
724 return NULL;
725
726 spin_lock_init(&acm->lock);
727
728 acm->port.connect = acm_connect;
729 acm->port.disconnect = acm_disconnect;
730 acm->port.send_break = acm_send_break;
731
732 acm->port.func.name = "acm";
733 /* descriptors are per-instance copies */
734 acm->port.func.bind = acm_bind;
735 acm->port.func.set_alt = acm_set_alt;
736 acm->port.func.setup = acm_setup;
737 acm->port.func.disable = acm_disable;
738
739 return acm;
740}
741
742#ifdef USB_FACM_INCLUDED
743static void
744acm_old_unbind(struct usb_configuration *c, struct usb_function *f)
745{
746 struct f_acm *acm = func_to_acm(f);
747
748 usb_free_all_descriptors(f);
749 if (acm->notify_req)
750 gs_free_req(acm->notify, acm->notify_req);
751 kfree(acm);
752}
753
754/**
755 * acm_bind_config - add a CDC ACM function to a configuration
756 * @c: the configuration to support the CDC ACM instance
757 * @port_num: /dev/ttyGS* port this interface will use
758 * Context: single threaded during gadget setup
759 *
760 * Returns zero on success, else negative errno.
761 *
762 */
763int acm_bind_config(struct usb_configuration *c, u8 port_num)
764{
765 struct f_acm *acm;
766 int status;
767
768 /* allocate and initialize one new instance */
769 acm = acm_alloc_basic_func();
770 if (!acm)
771 return -ENOMEM;
772
773 acm->port_num = port_num;
774 acm->port.func.unbind = acm_old_unbind;
775
776 status = usb_add_function(c, &acm->port.func);
777 if (status)
778 kfree(acm);
779 return status;
780}
781
782#else
783
784static void acm_unbind(struct usb_configuration *c, struct usb_function *f) 718static void acm_unbind(struct usb_configuration *c, struct usb_function *f)
785{ 719{
786 struct f_acm *acm = func_to_acm(f); 720 struct f_acm *acm = func_to_acm(f);
@@ -803,10 +737,24 @@ static struct usb_function *acm_alloc_func(struct usb_function_instance *fi)
803 struct f_serial_opts *opts; 737 struct f_serial_opts *opts;
804 struct f_acm *acm; 738 struct f_acm *acm;
805 739
806 acm = acm_alloc_basic_func(); 740 acm = kzalloc(sizeof(*acm), GFP_KERNEL);
807 if (!acm) 741 if (!acm)
808 return ERR_PTR(-ENOMEM); 742 return ERR_PTR(-ENOMEM);
809 743
744 spin_lock_init(&acm->lock);
745
746 acm->port.connect = acm_connect;
747 acm->port.disconnect = acm_disconnect;
748 acm->port.send_break = acm_send_break;
749
750 acm->port.func.name = "acm";
751 acm->port.func.strings = acm_strings;
752 /* descriptors are per-instance copies */
753 acm->port.func.bind = acm_bind;
754 acm->port.func.set_alt = acm_set_alt;
755 acm->port.func.setup = acm_setup;
756 acm->port.func.disable = acm_disable;
757
810 opts = container_of(fi, struct f_serial_opts, func_inst); 758 opts = container_of(fi, struct f_serial_opts, func_inst);
811 acm->port_num = opts->port_num; 759 acm->port_num = opts->port_num;
812 acm->port.func.unbind = acm_unbind; 760 acm->port.func.unbind = acm_unbind;
@@ -835,4 +783,3 @@ static struct usb_function_instance *acm_alloc_instance(void)
835} 783}
836DECLARE_USB_FUNCTION_INIT(acm, acm_alloc_instance, acm_alloc_func); 784DECLARE_USB_FUNCTION_INIT(acm, acm_alloc_instance, acm_alloc_func);
837MODULE_LICENSE("GPL"); 785MODULE_LICENSE("GPL");
838#endif