diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2012-12-23 15:10:09 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-01-21 13:52:45 -0500 |
commit | 29a6645f7c0a7f1ff09d45e820f0433bd5a5610f (patch) | |
tree | a467a8c4043854385aed84667863380ac89af73e /drivers/usb/gadget | |
parent | 5f72bbfd9f427565c85e71a63d47b3448e79a466 (diff) |
usb: gadget: cdc2: 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: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/Kconfig | 1 | ||||
-rw-r--r-- | drivers/usb/gadget/cdc2.c | 28 |
2 files changed, 24 insertions, 5 deletions
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 8dad2ce8521f..dfe3e2d66f91 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig | |||
@@ -816,6 +816,7 @@ config USB_CDC_COMPOSITE | |||
816 | depends on NET | 816 | depends on NET |
817 | select USB_LIBCOMPOSITE | 817 | select USB_LIBCOMPOSITE |
818 | select USB_U_SERIAL | 818 | select USB_U_SERIAL |
819 | select USB_F_ACM | ||
819 | help | 820 | help |
820 | This driver provides two functions in one configuration: | 821 | This driver provides two functions in one configuration: |
821 | a CDC Ethernet (ECM) link, and a CDC ACM (serial port) link. | 822 | 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 13b17f0b2da1..a7d6f7026757 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c | |||
@@ -42,8 +42,6 @@ USB_GADGET_COMPOSITE_OPTIONS(); | |||
42 | * the runtime footprint, and giving us at least some parts of what | 42 | * the runtime footprint, and giving us at least some parts of what |
43 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. | 43 | * a "gcc --combine ... part1.c part2.c part3.c ... " build would. |
44 | */ | 44 | */ |
45 | #define USB_FACM_INCLUDED | ||
46 | #include "f_acm.c" | ||
47 | #include "f_ecm.c" | 45 | #include "f_ecm.c" |
48 | #include "u_ether.c" | 46 | #include "u_ether.c" |
49 | 47 | ||
@@ -107,6 +105,8 @@ static struct usb_gadget_strings *dev_strings[] = { | |||
107 | static u8 hostaddr[ETH_ALEN]; | 105 | static u8 hostaddr[ETH_ALEN]; |
108 | 106 | ||
109 | /*-------------------------------------------------------------------------*/ | 107 | /*-------------------------------------------------------------------------*/ |
108 | static struct usb_function *f_acm; | ||
109 | static struct usb_function_instance *fi_serial; | ||
110 | 110 | ||
111 | static unsigned char tty_line; | 111 | static unsigned char tty_line; |
112 | /* | 112 | /* |
@@ -114,6 +114,7 @@ static unsigned char tty_line; | |||
114 | */ | 114 | */ |
115 | static int __init cdc_do_config(struct usb_configuration *c) | 115 | static int __init cdc_do_config(struct usb_configuration *c) |
116 | { | 116 | { |
117 | struct f_serial_opts *opts; | ||
117 | int status; | 118 | int status; |
118 | 119 | ||
119 | if (gadget_is_otg(c->cdev->gadget)) { | 120 | if (gadget_is_otg(c->cdev->gadget)) { |
@@ -125,11 +126,26 @@ static int __init cdc_do_config(struct usb_configuration *c) | |||
125 | if (status < 0) | 126 | if (status < 0) |
126 | return status; | 127 | return status; |
127 | 128 | ||
128 | status = acm_bind_config(c, tty_line); | 129 | fi_serial = usb_get_function_instance("acm"); |
129 | if (status < 0) | 130 | if (IS_ERR(fi_serial)) |
130 | return status; | 131 | return PTR_ERR(fi_serial); |
132 | |||
133 | opts = container_of(fi_serial, struct f_serial_opts, func_inst); | ||
134 | opts->port_num = tty_line; | ||
131 | 135 | ||
136 | f_acm = usb_get_function(fi_serial); | ||
137 | if (IS_ERR(f_acm)) | ||
138 | goto err_func_acm; | ||
139 | |||
140 | status = usb_add_function(c, f_acm); | ||
141 | if (status) | ||
142 | goto err_conf; | ||
132 | return 0; | 143 | return 0; |
144 | err_conf: | ||
145 | usb_put_function(f_acm); | ||
146 | err_func_acm: | ||
147 | usb_put_function_instance(fi_serial); | ||
148 | return status; | ||
133 | } | 149 | } |
134 | 150 | ||
135 | static struct usb_configuration cdc_config_driver = { | 151 | static struct usb_configuration cdc_config_driver = { |
@@ -192,6 +208,8 @@ fail0: | |||
192 | 208 | ||
193 | static int __exit cdc_unbind(struct usb_composite_dev *cdev) | 209 | static int __exit cdc_unbind(struct usb_composite_dev *cdev) |
194 | { | 210 | { |
211 | usb_put_function(f_acm); | ||
212 | usb_put_function_instance(fi_serial); | ||
195 | gserial_free_line(tty_line); | 213 | gserial_free_line(tty_line); |
196 | gether_cleanup(); | 214 | gether_cleanup(); |
197 | return 0; | 215 | return 0; |