// SPDX-License-Identifier: GPL-2.0/* * USB Serial Converter driver * * Copyright (C) 2009 - 2013 Johan Hovold (jhovold@gmail.com) * Copyright (C) 1999 - 2012 Greg Kroah-Hartman (greg@kroah.com) * Copyright (C) 2000 Peter Berger (pberger@brimson.com) * Copyright (C) 2000 Al Borchers (borchers@steinerpoint.com) * * This driver was originally based on the ACM driver by Armin Fuerst (which was * based on a driver by Brad Keryan) * * See Documentation/usb/usb-serial.txt for more information on using this * driver */#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt#include<linux/kernel.h>#include<linux/errno.h>#include<linux/init.h>#include<linux/slab.h>#include<linux/tty.h>#include<linux/tty_driver.h>#include<linux/tty_flip.h>#include<linux/module.h>#include<linux/moduleparam.h>#include<linux/seq_file.h>#include<linux/spinlock.h>#include<linux/mutex.h>#include<linux/list.h>#include<linux/uaccess.h>#include<linux/serial.h>#include<linux/usb.h>#include<linux/usb/serial.h>#include<linux/kfifo.h>#include<linux/idr.h>#define DRIVER_AUTHOR "Greg Kroah-Hartman <gregkh@linuxfoundation.org>"#define DRIVER_DESC "USB Serial Driver core"#define USB_SERIAL_TTY_MAJOR 188#define USB_SERIAL_TTY_MINORS 512 /* should be enough for a while *//* There is no MODULE_DEVICE_TABLE for usbserial.c. Instead the MODULE_DEVICE_TABLE declarations in each serial driver cause the "hotplug" program to pull in whatever module is necessary via modprobe, and modprobe will load usbserial because the serial drivers depend on it.*/staticDEFINE_IDR(serial_minors);staticDEFINE_MUTEX(table_lock);staticLIST_HEAD(usb_serial_driver_list);/* * Look up the serial port structure. If it is found and it hasn't been * disconnected, return with the parent usb_serial structure's disc_mutex held * and its refcount incremented. Otherwise return NULL. */structusb_serial_port*usb_serial_port_get_by_minor(unsignedminor){structusb_serial*serial;structusb_serial_port*port;mutex_lock(&table_lock);port=idr_find(&serial_minors,minor);if(!port)gotoexit;serial=port->serial;mutex_lock(&serial->disc_mutex);<