diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2012-12-23 20:10:03 (GMT) |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2013-01-21 18:52:41 (GMT) |
commit | 48177cd83792d25a5bab7f887acc47c2c314810e (patch) | |
tree | 6a83a8f6d686ab690e97ff2510ee0e2b579994ff /drivers | |
parent | 05c062c571ee19f08deb1c12fc2dd14b92f89eb8 (diff) | |
download | linux-48177cd83792d25a5bab7f887acc47c2c314810e.tar.xz |
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')
-rw-r--r-- | drivers/usb/gadget/serial.c | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 44752f5..bc23905 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"); /*-------------------------------------------------------------------------*/ -static int __init serial_bind_config(struct usb_configuration *c) +static int __init serial_bind_acm_config(struct usb_configuration *c) { unsigned i; int status = 0; - for (i = 0; i < n_ports && status == 0; i++) { - if (use_acm) - status = acm_bind_config(c, i); - else if (use_obex) - status = obex_bind_config(c, i); - else - status = gser_bind_config(c, i); - } + for (i = 0; i < n_ports && status == 0; i++) + status = acm_bind_config(c, i); + return status; +} + +static int __init serial_bind_obex_config(struct usb_configuration *c) +{ + unsigned i; + int status = 0; + + for (i = 0; i < n_ports && status == 0; i++) + status = obex_bind_config(c, i); + return status; +} + +static int __init serial_bind_gser_config(struct usb_configuration *c) +{ + unsigned i; + int status = 0; + + for (i = 0; i < n_ports && status == 0; i++) + status = gser_bind_config(c, i); return status; } @@ -178,8 +192,15 @@ static int __init gs_bind(struct usb_composite_dev *cdev) } /* register our configuration */ - status = usb_add_config(cdev, &serial_config_driver, - serial_bind_config); + if (use_acm) + status = usb_add_config(cdev, &serial_config_driver, + serial_bind_acm_config); + else if (use_obex) + status = usb_add_config(cdev, &serial_config_driver, + serial_bind_obex_config); + else + status = usb_add_config(cdev, &serial_config_driver, + serial_bind_gser_config); if (status < 0) goto fail; |