static struct fsg_common fsg_common;
/*-------------------------------------------------------------------------*/
-static unsigned char tty_line;
static struct usb_function *f_acm;
static struct usb_function_instance *f_acm_inst;
/*
*/
static int __init acm_ms_do_config(struct usb_configuration *c)
{
- struct f_serial_opts *opts;
int status;
if (gadget_is_otg(c->cdev->gadget)) {
if (IS_ERR(f_acm_inst))
return PTR_ERR(f_acm_inst);
- opts = container_of(f_acm_inst, struct f_serial_opts, func_inst);
- opts->port_num = tty_line;
-
f_acm = usb_get_function(f_acm_inst);
if (IS_ERR(f_acm)) {
status = PTR_ERR(f_acm);
int status;
void *retp;
- /* set up serial link layer */
- status = gserial_alloc_line(&tty_line);
- if (status < 0)
- return status;
-
/* set up mass storage function */
retp = fsg_common_from_params(&fsg_common, cdev, &fsg_mod_data);
if (IS_ERR(retp)) {
status = PTR_ERR(retp);
- goto fail0;
+ return PTR_ERR(retp);
}
/*
/* error recovery */
fail1:
fsg_common_put(&fsg_common);
-fail0:
- gserial_free_line(tty_line);
return status;
}
{
usb_put_function(f_acm);
usb_put_function_instance(f_acm_inst);
- gserial_free_line(tty_line);
return 0;
}
static struct usb_function *f_acm;
static struct usb_function_instance *fi_serial;
-static unsigned char tty_line;
/*
* We _always_ have both CDC ECM and CDC ACM functions.
*/
static int __init cdc_do_config(struct usb_configuration *c)
{
- struct f_serial_opts *opts;
int status;
if (gadget_is_otg(c->cdev->gadget)) {
if (IS_ERR(fi_serial))
return PTR_ERR(fi_serial);
- opts = container_of(fi_serial, struct f_serial_opts, func_inst);
- opts->port_num = tty_line;
-
f_acm = usb_get_function(fi_serial);
if (IS_ERR(f_acm))
goto err_func_acm;
if (IS_ERR(the_dev))
return PTR_ERR(the_dev);
- /* set up serial link layer */
- status = gserial_alloc_line(&tty_line);
- if (status < 0)
- goto fail0;
-
/* Allocate string descriptor numbers ... note that string
* contents can be overridden by the composite_dev glue.
*/
return 0;
fail1:
- gserial_free_line(tty_line);
-fail0:
gether_cleanup(the_dev);
return status;
}
{
usb_put_function(f_acm);
usb_put_function_instance(fi_serial);
- gserial_free_line(tty_line);
gether_cleanup(the_dev);
return 0;
}
struct f_serial_opts *opts;
opts = container_of(fi, struct f_serial_opts, func_inst);
+ gserial_free_line(opts->port_num);
kfree(opts);
}
static struct usb_function_instance *acm_alloc_instance(void)
{
struct f_serial_opts *opts;
+ int ret;
opts = kzalloc(sizeof(*opts), GFP_KERNEL);
if (!opts)
return ERR_PTR(-ENOMEM);
opts->func_inst.free_func_inst = acm_free_instance;
+ ret = gserial_alloc_line(&opts->port_num);
+ if (ret) {
+ kfree(opts);
+ return ERR_PTR(ret);
+ }
return &opts->func_inst;
}
DECLARE_USB_FUNCTION_INIT(acm, acm_alloc_instance, acm_alloc_func);
static u8 hostaddr[ETH_ALEN];
-static unsigned char tty_line;
static struct usb_function_instance *fi_acm;
static struct eth_dev *the_dev;
static int __ref multi_bind(struct usb_composite_dev *cdev)
{
struct usb_gadget *gadget = cdev->gadget;
- struct f_serial_opts *opts;
int status;
if (!can_support_ecm(cdev->gadget)) {
return PTR_ERR(the_dev);
/* set up serial link layer */
- status = gserial_alloc_line(&tty_line);
- if (status < 0)
- goto fail0;
-
fi_acm = usb_get_function_instance("acm");
if (IS_ERR(fi_acm)) {
status = PTR_ERR(fi_acm);
- goto fail0dot5;
+ goto fail0;
}
- opts = container_of(fi_acm, struct f_serial_opts, func_inst);
- opts->port_num = tty_line;
-
/* set up mass storage function */
{
void *retp;
fsg_common_put(&fsg_common);
fail1:
usb_put_function_instance(fi_acm);
-fail0dot5:
- gserial_free_line(tty_line);
fail0:
gether_cleanup(the_dev);
return status;
usb_put_function(f_acm_rndis);
#endif
usb_put_function_instance(fi_acm);
- gserial_free_line(tty_line);
gether_cleanup(the_dev);
return 0;
}
enum {
TTY_PORT_OBEX0,
TTY_PORT_OBEX1,
- TTY_PORT_ACM,
TTY_PORTS_MAX,
};
static int __init nokia_bind(struct usb_composite_dev *cdev)
{
struct usb_gadget *gadget = cdev->gadget;
- struct f_serial_opts *opts;
int status;
int cur_line;
fi_acm = usb_get_function_instance("acm");
if (IS_ERR(fi_acm))
goto err_usb;
- opts = container_of(fi_acm, struct f_serial_opts, func_inst);
- opts->port_num = tty_lines[TTY_PORT_ACM];
/* finally register the configuration */
status = usb_add_config(cdev, &nokia_config_500ma_driver,
goto out;
for (i = 0; i < n_ports; i++) {
- struct f_serial_opts *opts;
fi_serial[i] = usb_get_function_instance(f_name);
if (IS_ERR(fi_serial[i])) {
ret = PTR_ERR(fi_serial[i]);
goto fail;
}
- opts = container_of(fi_serial[i], struct f_serial_opts, func_inst);
- opts->port_num = tty_lines[i];
f_serial[i] = usb_get_function(fi_serial[i]);
if (IS_ERR(f_serial[i])) {
static int __init gs_bind(struct usb_composite_dev *cdev)
{
int status;
- int cur_line;
+ int cur_line = 0;
- for (cur_line = 0; cur_line < n_ports; cur_line++) {
- status = gserial_alloc_line(&tty_lines[cur_line]);
- if (status)
- goto fail;
+ if (!use_acm) {
+ for (cur_line = 0; cur_line < n_ports; cur_line++) {
+ status = gserial_alloc_line(&tty_lines[cur_line]);
+ if (status)
+ goto fail;
+ }
}
/* Allocate string descriptor numbers ... note that string
fail:
cur_line--;
- while (cur_line >= 0)
+ while (cur_line >= 0 && !use_acm)
gserial_free_line(tty_lines[cur_line--]);
return status;
}
for (i = 0; i < n_ports; i++) {
usb_put_function(f_serial[i]);
usb_put_function_instance(fi_serial[i]);
- gserial_free_line(tty_lines[i]);
+ if (!use_acm)
+ gserial_free_line(tty_lines[i]);
}
return 0;
}