aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2012-12-23 15:10:03 -0500
committerFelipe Balbi <balbi@ti.com>2013-01-21 13:52:41 -0500
commit48177cd83792d25a5bab7f887acc47c2c314810e (patch)
tree6a83a8f6d686ab690e97ff2510ee0e2b579994ff /drivers/usb/gadget
parent05c062c571ee19f08deb1c12fc2dd14b92f89eb8 (diff)
usb: gadget: g_serial: split the three possible functions into three bind functions
This patch factors out the three possible functions into three possible bind functions which are passed as an argument to usb_add_config(). This will ease the step by step converting of the individual functions to the new function registration method. 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/serial.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index 44752f531e85..bc23905800d3 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -129,19 +129,33 @@ MODULE_PARM_DESC(n_ports, "number of ports to create, default=1");
129 129
130/*-------------------------------------------------------------------------*/ 130/*-------------------------------------------------------------------------*/
131 131
132static int __init serial_bind_config(struct usb_configuration *c) 132static int __init serial_bind_acm_config(struct usb_configuration *c)
133{ 133{
134 unsigned i; 134 unsigned i;
135 int status = 0; 135 int status = 0;
136 136
137 for (i = 0; i < n_ports && status == 0; i++) { 137 for (i = 0; i < n_ports && status == 0; i++)
138 if (use_acm) 138 status = acm_bind_config(c, i);
139 status = acm_bind_config(c, i); 139 return status;
140 else if (use_obex) 140}
141 status = obex_bind_config(c, i); 141
142 else 142static int __init serial_bind_obex_config(struct usb_configuration *c)
143 status = gser_bind_config(c, i); 143{
144 } 144 unsigned i;
145 int status = 0;
146
147 for (i = 0; i < n_ports && status == 0; i++)
148 status = obex_bind_config(c, i);
149 return status;
150}
151
152static int __init serial_bind_gser_config(struct usb_configuration *c)
153{
154 unsigned i;
155 int status = 0;
156
157 for (i = 0; i < n_ports && status == 0; i++)
158 status = gser_bind_config(c, i);
145 return status; 159 return status;
146} 160}
147 161
@@ -178,8 +192,15 @@ static int __init gs_bind(struct usb_composite_dev *cdev)
178 } 192 }
179 193
180 /* register our configuration */ 194 /* register our configuration */
181 status = usb_add_config(cdev, &serial_config_driver, 195 if (use_acm)
182 serial_bind_config); 196 status = usb_add_config(cdev, &serial_config_driver,
197 serial_bind_acm_config);
198 else if (use_obex)
199 status = usb_add_config(cdev, &serial_config_driver,
200 serial_bind_obex_config);
201 else
202 status = usb_add_config(cdev, &serial_config_driver,
203 serial_bind_gser_config);
183 if (status < 0) 204 if (status < 0)
184 goto fail; 205 goto fail;
185 206