/* Look up the serial structure. If it is found and it hasn't been disconnected, return with its disc_mutex held and its refcount incremented. Otherwise return NULL.  */
struct usb_serial* usb_serial_get_by_index(unsigned index)
/* Look up the serial structure. If it is found and it hasn't been disconnected, return with its disc_mutex held and its refcount incremented. Otherwise return NULL.  */
struct usb_serial* usb_serial_get_by_index(unsigned index)
{
	struct usb_serial *serial;
	mutex_lock(&table_lock);
	serial = serial_table[index];
	if (serial) {
		mutex_lock(&serial->disc_mutex);
		if (serial->disconnected) {
			mutex_unlock(&serial->disc_mutex);
			serial = NULL;
		} else {
			kref_get(&serial->kref);
		}
	}
	mutex_unlock(&table_lock);
	return serial;
}