linux/drivers/usb/serial/usb-serial.c

// SPDX-License-Identifier: GPL-2.0
/*
 * USB Serial Converter driver
 *
 * Copyright (C) 2009 - 2013 Johan Hovold ([email protected])
 * Copyright (C) 1999 - 2012 Greg Kroah-Hartman ([email protected])
 * Copyright (C) 2000 Peter Berger ([email protected])
 * Copyright (C) 2000 Al Borchers ([email protected])
 *
 * 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.rst for more information on using this
 * driver
 */

#define pr_fmt(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
#define DRIVER_DESC

#define USB_SERIAL_TTY_MAJOR
#define USB_SERIAL_TTY_MINORS

/* 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.
*/

static DEFINE_IDR(serial_minors);
static DEFINE_MUTEX(table_lock);
static LIST_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.
 */
struct usb_serial_port *usb_serial_port_get_by_minor(unsigned minor)
{}

static int allocate_minors(struct usb_serial *serial, int num_ports)
{}

static void release_minors(struct usb_serial *serial)
{}

int usb_serial_claim_interface(struct usb_serial *serial, struct usb_interface *intf)
{}
EXPORT_SYMBOL_GPL();

static void release_sibling(struct usb_serial *serial, struct usb_interface *intf)
{}

static void destroy_serial(struct kref *kref)
{}

void usb_serial_put(struct usb_serial *serial)
{}

/*****************************************************************************
 * Driver tty interface functions
 *****************************************************************************/

/**
 * serial_install - install tty
 * @driver: the driver (USB in our case)
 * @tty: the tty being created
 *
 * Initialise the termios structure for this tty.  We use the default
 * USB serial settings but permit them to be overridden by
 * serial->type->init_termios on first open.
 *
 * This is the first place a new tty gets used.  Hence this is where we
 * acquire references to the usb_serial structure and the driver module,
 * where we store a pointer to the port.  All these actions are reversed
 * in serial_cleanup().
 */
static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
{}

static int serial_port_activate(struct tty_port *tport, struct tty_struct *tty)
{}

static int serial_open(struct tty_struct *tty, struct file *filp)
{}

/**
 * serial_port_shutdown - shut down hardware
 * @tport: tty port to shut down
 *
 * Shut down a USB serial port. Serialized against activate by the
 * tport mutex and kept to matching open/close pairs
 * of calls by the tty-port initialized flag.
 *
 * Not called if tty is console.
 */
static void serial_port_shutdown(struct tty_port *tport)
{}

static void serial_hangup(struct tty_struct *tty)
{}

static void serial_close(struct tty_struct *tty, struct file *filp)
{}

/**
 * serial_cleanup - free resources post close/hangup
 * @tty: tty to clean up
 *
 * Do the resource freeing and refcount dropping for the port.
 * Avoid freeing the console.
 *
 * Called asynchronously after the last tty kref is dropped.
 */
static void serial_cleanup(struct tty_struct *tty)
{}

static ssize_t serial_write(struct tty_struct *tty, const u8 *buf, size_t count)
{}

static unsigned int serial_write_room(struct tty_struct *tty)
{}

static unsigned int serial_chars_in_buffer(struct tty_struct *tty)
{}

static void serial_wait_until_sent(struct tty_struct *tty, int timeout)
{}

static void serial_throttle(struct tty_struct *tty)
{}

static void serial_unthrottle(struct tty_struct *tty)
{}

static int serial_get_serial(struct tty_struct *tty, struct serial_struct *ss)
{}

static int serial_set_serial(struct tty_struct *tty, struct serial_struct *ss)
{}

static int serial_ioctl(struct tty_struct *tty,
					unsigned int cmd, unsigned long arg)
{}

static void serial_set_termios(struct tty_struct *tty,
		               const struct ktermios *old)
{}

static int serial_break(struct tty_struct *tty, int break_state)
{}

static int serial_proc_show(struct seq_file *m, void *v)
{}

static int serial_tiocmget(struct tty_struct *tty)
{}

static int serial_tiocmset(struct tty_struct *tty,
			    unsigned int set, unsigned int clear)
{}

static int serial_get_icount(struct tty_struct *tty,
				struct serial_icounter_struct *icount)
{}

/*
 * We would be calling tty_wakeup here, but unfortunately some line
 * disciplines have an annoying habit of calling tty->write from
 * the write wakeup callback (e.g. n_hdlc.c).
 */
void usb_serial_port_softint(struct usb_serial_port *port)
{}
EXPORT_SYMBOL_GPL();

static void usb_serial_port_work(struct work_struct *work)
{}

static void usb_serial_port_poison_urbs(struct usb_serial_port *port)
{}

static void usb_serial_port_unpoison_urbs(struct usb_serial_port *port)
{}

static void usb_serial_port_release(struct device *dev)
{}

static struct usb_serial *create_serial(struct usb_device *dev,
					struct usb_interface *interface,
					struct usb_serial_driver *driver)
{}

static const struct usb_device_id *match_dynamic_id(struct usb_interface *intf,
					    struct usb_serial_driver *drv)
{}

static const struct usb_device_id *get_iface_id(struct usb_serial_driver *drv,
						struct usb_interface *intf)
{}

/* Caller must hold table_lock */
static struct usb_serial_driver *search_serial_device(
					struct usb_interface *iface)
{}

static bool serial_port_carrier_raised(struct tty_port *port)
{}

static void serial_port_dtr_rts(struct tty_port *port, bool on)
{}

static ssize_t port_number_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(port_number);

static struct attribute *usb_serial_port_attrs[] =;
ATTRIBUTE_GROUPS();

static const struct tty_port_operations serial_port_ops =;

static void store_endpoint(struct usb_serial *serial,
					struct usb_serial_endpoints *epds,
					struct usb_endpoint_descriptor *epd)
{}

static void find_endpoints(struct usb_serial *serial,
					struct usb_serial_endpoints *epds,
					struct usb_interface *intf)
{}

static int setup_port_bulk_in(struct usb_serial_port *port,
					struct usb_endpoint_descriptor *epd)
{}

static int setup_port_bulk_out(struct usb_serial_port *port,
					struct usb_endpoint_descriptor *epd)
{}

static int setup_port_interrupt_in(struct usb_serial_port *port,
					struct usb_endpoint_descriptor *epd)
{}

static int setup_port_interrupt_out(struct usb_serial_port *port,
					struct usb_endpoint_descriptor *epd)
{}

static int usb_serial_probe(struct usb_interface *interface,
			       const struct usb_device_id *id)
{}

static void usb_serial_disconnect(struct usb_interface *interface)
{}

int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
{}
EXPORT_SYMBOL();

static void usb_serial_unpoison_port_urbs(struct usb_serial *serial)
{}

int usb_serial_resume(struct usb_interface *intf)
{}
EXPORT_SYMBOL();

static int usb_serial_reset_resume(struct usb_interface *intf)
{}

static const struct tty_operations serial_ops =;


struct tty_driver *usb_serial_tty_driver;

static int __init usb_serial_init(void)
{}


static void __exit usb_serial_exit(void)
{}


module_init();
module_exit(usb_serial_exit);

#define set_to_generic_if_null(type, function)

static void usb_serial_operations_init(struct usb_serial_driver *device)
{}

static int usb_serial_register(struct usb_serial_driver *driver)
{}

static void usb_serial_deregister(struct usb_serial_driver *device)
{}

/**
 * usb_serial_register_drivers - register drivers for a usb-serial module
 * @serial_drivers: NULL-terminated array of pointers to drivers to be registered
 * @name: name of the usb_driver for this set of @serial_drivers
 * @id_table: list of all devices this @serial_drivers set binds to
 *
 * Registers all the drivers in the @serial_drivers array, and dynamically
 * creates a struct usb_driver with the name @name and id_table of @id_table.
 */
int usb_serial_register_drivers(struct usb_serial_driver *const serial_drivers[],
				const char *name,
				const struct usb_device_id *id_table)
{}
EXPORT_SYMBOL_GPL();

/**
 * usb_serial_deregister_drivers - deregister drivers for a usb-serial module
 * @serial_drivers: NULL-terminated array of pointers to drivers to be deregistered
 *
 * Deregisters all the drivers in the @serial_drivers array and deregisters and
 * frees the struct usb_driver that was created by the call to
 * usb_serial_register_drivers().
 */
void usb_serial_deregister_drivers(struct usb_serial_driver *const serial_drivers[])
{}
EXPORT_SYMBOL_GPL();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();