static int acm_tty_install(struct tty_driver *driver, struct tty_struct *tty) { struct acm *acm; int retval; dev_dbg(tty->dev, "%s\n", __func__); acm = acm_get_by_index(tty->index); if (!acm) return -ENODEV; retval = tty_init_termios(tty); if (retval) goto error_init_termios; tty->driver_data = acm; /* Final install (we use the default method) */ tty_driver_kref_get(driver); tty->count++; driver->ttys[tty->index] = tty; return 0; error_init_termios: tty_port_put(&acm->port); return retval; }
void unregister_lte_tty_device(struct tty_dev *tty_dev) { struct gdm *gdm; struct tty_struct *tty; int i; for (i = 0; i < TTY_MAX_COUNT; i++) { gdm = tty_dev->gdm[i]; if (!gdm) continue; mutex_lock(&gdm_table_lock); gdm_table[gdm->index][gdm->minor] = NULL; mutex_unlock(&gdm_table_lock); tty = tty_port_tty_get(&gdm->port); if (tty) { tty_vhangup(tty); tty_kref_put(tty); } tty_unregister_device(gdm_driver[i], gdm->minor); tty_port_put(&gdm->port); } }
static void acm_disconnect(struct usb_interface *intf) { struct acm *acm = usb_get_intfdata(intf); struct usb_device *usb_dev = interface_to_usbdev(intf); struct tty_struct *tty; int i; dev_dbg(&intf->dev, "%s\n", __func__); /* sibling interface is already cleaning up */ if (!acm) return; mutex_lock(&acm->mutex); acm->disconnected = true; if (acm->country_codes) { device_remove_file(&acm->control->dev, &dev_attr_wCountryCodes); device_remove_file(&acm->control->dev, &dev_attr_iCountryCodeRelDate); kfree(acm->country_codes); } device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities); usb_set_intfdata(acm->control, NULL); usb_set_intfdata(acm->data, NULL); mutex_unlock(&acm->mutex); tty = tty_port_tty_get(&acm->port); if (tty) { tty_vhangup(tty); tty_kref_put(tty); } stop_data_traffic(acm); tty_unregister_device(acm_tty_driver, acm->minor); usb_free_urb(acm->ctrlurb); for (i = 0; i < ACM_NW; i++) usb_free_urb(acm->wb[i].urb); for (i = 0; i < acm->rx_buflimit; i++) usb_free_urb(acm->read_urbs[i]); acm_write_buffers_free(acm); usb_free_coherent(usb_dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); acm_read_buffers_free(acm); if (!acm->combined_interfaces) usb_driver_release_interface(&acm_driver, intf == acm->control ? acm->data : acm->control); tty_port_put(&acm->port); }
static int gdm_tty_install(struct tty_driver *driver, struct tty_struct *tty) { struct gdm *gdm = NULL; int ret; int i; int j; j = GDM_TTY_MINOR; for (i = 0; i < TTY_MAX_COUNT; i++) { if (!strcmp(tty->driver->driver_name, DRIVER_STRING[i])) { j = tty->index; break; } } if (j == GDM_TTY_MINOR) return -ENODEV; mutex_lock(&gdm_table_lock); gdm = gdm_table[i][j]; if (gdm == NULL) { mutex_unlock(&gdm_table_lock); return -ENODEV; } tty_port_get(&gdm->port); ret = tty_standard_install(driver, tty); if (ret) { tty_port_put(&gdm->port); mutex_unlock(&gdm_table_lock); return ret; } tty->driver_data = gdm; mutex_unlock(&gdm_table_lock); return 0; }
static int acm_tty_install(struct tty_driver *driver, struct tty_struct *tty) { struct acm *acm; int retval; dev_dbg(tty->dev, "%s\n", __func__); acm = acm_get_by_index(tty->index); if (!acm) return -ENODEV; retval = tty_standard_install(driver, tty); if (retval) goto error_init_termios; tty->driver_data = acm; return 0; error_init_termios: tty_port_put(&acm->port); return retval; }
static void pty_cleanup(struct tty_struct *tty) { tty_port_put(tty->port); }
static void acm_tty_cleanup(struct tty_struct *tty) { struct acm *acm = tty->driver_data; dev_dbg(&acm->control->dev, "%s\n", __func__); tty_port_put(&acm->port); }
static void gdm_tty_cleanup(struct tty_struct *tty) { struct gdm *gdm = tty->driver_data; tty_port_put(&gdm->port); }