aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/acm_ms.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2012-12-23 15:10:08 -0500
committerFelipe Balbi <balbi@ti.com>2013-01-21 13:52:44 -0500
commit5f72bbfd9f427565c85e71a63d47b3448e79a466 (patch)
treea870acabe3e7427a71fa8e338f78915578a73427 /drivers/usb/gadget/acm_ms.c
parentff47f59467388104d369a441aa6996d257343775 (diff)
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: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/acm_ms.c')
-rw-r--r--drivers/usb/gadget/acm_ms.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c
index 4105a06582f8..8f2b0e391534 100644
--- a/drivers/usb/gadget/acm_ms.c
+++ b/drivers/usb/gadget/acm_ms.c
@@ -40,8 +40,6 @@
40 * the runtime footprint, and giving us at least some parts of what 40 * the runtime footprint, and giving us at least some parts of what
41 * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 41 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
42 */ 42 */
43#define USB_FACM_INCLUDED
44#include "f_acm.c"
45#include "f_mass_storage.c" 43#include "f_mass_storage.c"
46 44
47/*-------------------------------------------------------------------------*/ 45/*-------------------------------------------------------------------------*/
@@ -112,12 +110,14 @@ static struct fsg_common fsg_common;
112 110
113/*-------------------------------------------------------------------------*/ 111/*-------------------------------------------------------------------------*/
114static unsigned char tty_line; 112static unsigned char tty_line;
115 113static struct usb_function *f_acm;
114static struct usb_function_instance *f_acm_inst;
116/* 115/*
117 * We _always_ have both ACM and mass storage functions. 116 * We _always_ have both ACM and mass storage functions.
118 */ 117 */
119static int __init acm_ms_do_config(struct usb_configuration *c) 118static int __init acm_ms_do_config(struct usb_configuration *c)
120{ 119{
120 struct f_serial_opts *opts;
121 int status; 121 int status;
122 122
123 if (gadget_is_otg(c->cdev->gadget)) { 123 if (gadget_is_otg(c->cdev->gadget)) {
@@ -125,16 +125,35 @@ static int __init acm_ms_do_config(struct usb_configuration *c)
125 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; 125 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
126 } 126 }
127 127
128 f_acm_inst = usb_get_function_instance("acm");
129 if (IS_ERR(f_acm_inst))
130 return PTR_ERR(f_acm_inst);
131
132 opts = container_of(f_acm_inst, struct f_serial_opts, func_inst);
133 opts->port_num = tty_line;
134
135 f_acm = usb_get_function(f_acm_inst);
136 if (IS_ERR(f_acm)) {
137 status = PTR_ERR(f_acm);
138 goto err_func;
139 }
128 140
129 status = acm_bind_config(c, tty_line); 141 status = usb_add_function(c, f_acm);
130 if (status < 0) 142 if (status < 0)
131 return status; 143 goto err_conf;
132 144
133 status = fsg_bind_config(c->cdev, c, &fsg_common); 145 status = fsg_bind_config(c->cdev, c, &fsg_common);
134 if (status < 0) 146 if (status < 0)
135 return status; 147 goto err_fsg;
136 148
137 return 0; 149 return 0;
150err_fsg:
151 usb_remove_function(c, f_acm);
152err_conf:
153 usb_put_function(f_acm);
154err_func:
155 usb_put_function_instance(f_acm_inst);
156 return status;
138} 157}
139 158
140static struct usb_configuration acm_ms_config_driver = { 159static struct usb_configuration acm_ms_config_driver = {
@@ -195,6 +214,8 @@ fail0:
195 214
196static int __exit acm_ms_unbind(struct usb_composite_dev *cdev) 215static int __exit acm_ms_unbind(struct usb_composite_dev *cdev)
197{ 216{
217 usb_put_function(f_acm);
218 usb_put_function_instance(f_acm_inst);
198 gserial_free_line(tty_line); 219 gserial_free_line(tty_line);
199 return 0; 220 return 0;
200} 221}