/* * Look up an ACM structure by index. If found and not disconnected, increment * its refcount and return it with its mutex held. */ static struct acm *acm_get_by_index(unsigned index) { struct acm *acm; mutex_lock(&acm_table_lock); acm = acm_table[index]; if (acm) { mutex_lock(&acm->mutex); if (acm->disconnected) { mutex_unlock(&acm->mutex); acm = NULL; } else { tty_port_get(&acm->port); mutex_unlock(&acm->mutex); } } mutex_unlock(&acm_table_lock); return acm; }
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; }