• Home
  • Raw
  • Download

Lines Matching full:serial

3  * USB Serial Converter driver
13 * See Documentation/usb/usb-serial.rst for more information on using this
33 #include <linux/serial.h>
35 #include <linux/usb/serial.h>
40 #define DRIVER_DESC "USB Serial Driver core"
46 the MODULE_DEVICE_TABLE declarations in each serial driver
48 via modprobe, and modprobe will load usbserial because the serial
57 * Look up the serial port structure. If it is found and it hasn't been
63 struct usb_serial *serial; in usb_serial_port_get_by_minor() local
71 serial = port->serial; in usb_serial_port_get_by_minor()
72 mutex_lock(&serial->disc_mutex); in usb_serial_port_get_by_minor()
73 if (serial->disconnected) { in usb_serial_port_get_by_minor()
74 mutex_unlock(&serial->disc_mutex); in usb_serial_port_get_by_minor()
77 kref_get(&serial->kref); in usb_serial_port_get_by_minor()
84 static int allocate_minors(struct usb_serial *serial, int num_ports) in allocate_minors() argument
90 dev_dbg(&serial->interface->dev, "%s %d\n", __func__, num_ports); in allocate_minors()
94 port = serial->port[i]; in allocate_minors()
102 serial->minors_reserved = 1; in allocate_minors()
108 idr_remove(&serial_minors, serial->port[j]->minor); in allocate_minors()
113 static void release_minors(struct usb_serial *serial) in release_minors() argument
118 for (i = 0; i < serial->num_ports; ++i) in release_minors()
119 idr_remove(&serial_minors, serial->port[i]->minor); in release_minors()
121 serial->minors_reserved = 0; in release_minors()
126 struct usb_serial *serial; in destroy_serial() local
130 serial = to_usb_serial(kref); in destroy_serial()
133 if (serial->minors_reserved) in destroy_serial()
134 release_minors(serial); in destroy_serial()
136 if (serial->attached && serial->type->release) in destroy_serial()
137 serial->type->release(serial); in destroy_serial()
140 for (i = 0; i < serial->num_port_pointers; ++i) { in destroy_serial()
141 port = serial->port[i]; in destroy_serial()
143 port->serial = NULL; in destroy_serial()
148 usb_put_intf(serial->interface); in destroy_serial()
149 usb_put_dev(serial->dev); in destroy_serial()
150 kfree(serial); in destroy_serial()
153 void usb_serial_put(struct usb_serial *serial) in usb_serial_put() argument
155 kref_put(&serial->kref, destroy_serial); in usb_serial_put()
168 * USB serial settings but permit them to be overridden by
169 * serial->type->init_termios on first open.
179 struct usb_serial *serial; in serial_install() local
188 serial = port->serial; in serial_install()
189 if (!try_module_get(serial->type->driver.owner)) in serial_install()
192 retval = usb_autopm_get_interface(serial->interface); in serial_install()
202 mutex_unlock(&serial->disc_mutex); in serial_install()
205 if (init_termios && serial->type->init_termios) in serial_install()
206 serial->type->init_termios(tty); in serial_install()
213 usb_autopm_put_interface(serial->interface); in serial_install()
215 module_put(serial->type->driver.owner); in serial_install()
217 usb_serial_put(serial); in serial_install()
218 mutex_unlock(&serial->disc_mutex); in serial_install()
226 struct usb_serial *serial = port->serial; in serial_port_activate() local
229 mutex_lock(&serial->disc_mutex); in serial_port_activate()
230 if (serial->disconnected) in serial_port_activate()
233 retval = port->serial->type->open(tty, port); in serial_port_activate()
234 mutex_unlock(&serial->disc_mutex); in serial_port_activate()
255 * Shut down a USB serial port. Serialized against activate by the
265 struct usb_serial_driver *drv = port->serial->type; in serial_port_shutdown()
301 struct usb_serial *serial; in serial_cleanup() local
314 serial = port->serial; in serial_cleanup()
315 owner = serial->type->driver.owner; in serial_cleanup()
317 usb_autopm_put_interface(serial->interface); in serial_cleanup()
319 usb_serial_put(serial); in serial_cleanup()
329 if (port->serial->dev->state == USB_STATE_NOTATTACHED) in serial_write()
334 retval = port->serial->type->write(tty, port, buf, count); in serial_write()
347 return port->serial->type->write_room(tty); in serial_write_room()
353 struct usb_serial *serial = port->serial; in serial_chars_in_buffer() local
357 if (serial->disconnected) in serial_chars_in_buffer()
360 return serial->type->chars_in_buffer(tty); in serial_chars_in_buffer()
366 struct usb_serial *serial = port->serial; in serial_wait_until_sent() local
370 if (!port->serial->type->wait_until_sent) in serial_wait_until_sent()
373 mutex_lock(&serial->disc_mutex); in serial_wait_until_sent()
374 if (!serial->disconnected) in serial_wait_until_sent()
375 port->serial->type->wait_until_sent(tty, timeout); in serial_wait_until_sent()
376 mutex_unlock(&serial->disc_mutex); in serial_wait_until_sent()
385 if (port->serial->type->throttle) in serial_throttle()
386 port->serial->type->throttle(tty); in serial_throttle()
395 if (port->serial->type->unthrottle) in serial_unthrottle()
396 port->serial->type->unthrottle(tty); in serial_unthrottle()
403 if (port->serial->type->get_serial) in serial_get_serial()
404 return port->serial->type->get_serial(tty, ss); in serial_get_serial()
412 if (port->serial->type->set_serial) in serial_set_serial()
413 return port->serial->type->set_serial(tty, ss); in serial_set_serial()
427 if (port->serial->type->tiocmiwait) in serial_ioctl()
428 retval = port->serial->type->tiocmiwait(tty, arg); in serial_ioctl()
431 if (port->serial->type->ioctl) in serial_ioctl()
432 retval = port->serial->type->ioctl(tty, cmd, arg); in serial_ioctl()
444 if (port->serial->type->set_termios) in serial_set_termios()
445 port->serial->type->set_termios(tty, port, old); in serial_set_termios()
456 if (port->serial->type->break_ctl) in serial_break()
457 port->serial->type->break_ctl(tty, break_state); in serial_break()
464 struct usb_serial *serial; in serial_proc_show() local
474 serial = port->serial; in serial_proc_show()
477 if (serial->type->driver.owner) in serial_proc_show()
479 module_name(serial->type->driver.owner)); in serial_proc_show()
481 serial->type->description); in serial_proc_show()
483 le16_to_cpu(serial->dev->descriptor.idVendor), in serial_proc_show()
484 le16_to_cpu(serial->dev->descriptor.idProduct)); in serial_proc_show()
485 seq_printf(m, " num_ports:%d", serial->num_ports); in serial_proc_show()
487 usb_make_path(serial->dev, tmp, sizeof(tmp)); in serial_proc_show()
491 usb_serial_put(serial); in serial_proc_show()
492 mutex_unlock(&serial->disc_mutex); in serial_proc_show()
503 if (port->serial->type->tiocmget) in serial_tiocmget()
504 return port->serial->type->tiocmget(tty); in serial_tiocmget()
515 if (port->serial->type->tiocmset) in serial_tiocmset()
516 return port->serial->type->tiocmset(tty, set, clear); in serial_tiocmset()
527 if (port->serial->type->get_icount) in serial_get_icount()
528 return port->serial->type->get_icount(tty, icount); in serial_get_icount()
605 struct usb_serial *serial; in create_serial() local
607 serial = kzalloc(sizeof(*serial), GFP_KERNEL); in create_serial()
608 if (!serial) in create_serial()
610 serial->dev = usb_get_dev(dev); in create_serial()
611 serial->type = driver; in create_serial()
612 serial->interface = usb_get_intf(interface); in create_serial()
613 kref_init(&serial->kref); in create_serial()
614 mutex_init(&serial->disc_mutex); in create_serial()
615 serial->minors_reserved = 0; in create_serial()
617 return serial; in create_serial()
675 struct usb_serial_driver *drv = p->serial->type; in serial_port_carrier_raised()
686 struct usb_serial_driver *drv = p->serial->type; in serial_port_dtr_rts()
714 static void find_endpoints(struct usb_serial *serial, in find_endpoints() argument
717 struct device *dev = &serial->interface->dev; in find_endpoints()
727 iface_desc = serial->interface->cur_altsetting; in find_endpoints()
750 struct usb_serial_driver *type = port->serial->type; in setup_port_bulk_in()
751 struct usb_device *udev = port->serial->dev; in setup_port_bulk_in()
782 struct usb_serial_driver *type = port->serial->type; in setup_port_bulk_out()
783 struct usb_device *udev = port->serial->dev; in setup_port_bulk_out()
819 struct usb_serial_driver *type = port->serial->type; in setup_port_interrupt_in()
820 struct usb_device *udev = port->serial->dev; in setup_port_interrupt_in()
843 struct usb_serial_driver *type = port->serial->type; in setup_port_interrupt_out()
844 struct usb_device *udev = port->serial->dev; in setup_port_interrupt_out()
870 struct usb_serial *serial = NULL; in usb_serial_probe() local
894 serial = create_serial(dev, interface, type); in usb_serial_probe()
895 if (!serial) { in usb_serial_probe()
905 retval = type->probe(serial, id); in usb_serial_probe()
920 find_endpoints(serial, epds); in usb_serial_probe()
932 retval = type->calc_num_ports(serial, epds); in usb_serial_probe()
946 serial->num_ports = (unsigned char)num_ports; in usb_serial_probe()
947 serial->num_bulk_in = epds->num_bulk_in; in usb_serial_probe()
948 serial->num_bulk_out = epds->num_bulk_out; in usb_serial_probe()
949 serial->num_interrupt_in = epds->num_interrupt_in; in usb_serial_probe()
950 serial->num_interrupt_out = epds->num_interrupt_out; in usb_serial_probe()
961 max_endpoints = max(max_endpoints, serial->num_ports); in usb_serial_probe()
962 serial->num_port_pointers = max_endpoints; in usb_serial_probe()
973 port->serial = serial; in usb_serial_probe()
978 serial->port[i] = port; in usb_serial_probe()
989 retval = setup_port_bulk_in(serial->port[i], epds->bulk_in[i]); in usb_serial_probe()
995 retval = setup_port_bulk_out(serial->port[i], in usb_serial_probe()
1001 if (serial->type->read_int_callback) { in usb_serial_probe()
1003 retval = setup_port_interrupt_in(serial->port[i], in usb_serial_probe()
1012 if (serial->type->write_int_callback) { in usb_serial_probe()
1014 retval = setup_port_interrupt_out(serial->port[i], in usb_serial_probe()
1023 usb_set_intfdata(interface, serial); in usb_serial_probe()
1027 retval = type->attach(serial); in usb_serial_probe()
1030 serial->attached = 1; in usb_serial_probe()
1033 serial port as it's about to disappear */ in usb_serial_probe()
1034 serial->num_ports = 0; in usb_serial_probe()
1038 serial->attached = 1; in usb_serial_probe()
1041 retval = allocate_minors(serial, num_ports); in usb_serial_probe()
1043 dev_err(ddev, "No more free serial minor numbers\n"); in usb_serial_probe()
1049 port = serial->port[i]; in usb_serial_probe()
1060 usb_serial_console_init(serial->port[0]->minor); in usb_serial_probe()
1069 usb_serial_put(serial); in usb_serial_probe()
1079 struct usb_serial *serial = usb_get_intfdata(interface); in usb_serial_disconnect() local
1084 usb_serial_console_disconnect(serial); in usb_serial_disconnect()
1086 mutex_lock(&serial->disc_mutex); in usb_serial_disconnect()
1088 serial->disconnected = 1; in usb_serial_disconnect()
1089 mutex_unlock(&serial->disc_mutex); in usb_serial_disconnect()
1091 for (i = 0; i < serial->num_ports; ++i) { in usb_serial_disconnect()
1092 port = serial->port[i]; in usb_serial_disconnect()
1104 if (serial->type->disconnect) in usb_serial_disconnect()
1105 serial->type->disconnect(serial); in usb_serial_disconnect()
1108 usb_serial_put(serial); in usb_serial_disconnect()
1114 struct usb_serial *serial = usb_get_intfdata(intf); in usb_serial_suspend() local
1117 serial->suspending = 1; in usb_serial_suspend()
1120 * serial->type->suspend() MUST return 0 in system sleep context, in usb_serial_suspend()
1124 if (serial->type->suspend) { in usb_serial_suspend()
1125 r = serial->type->suspend(serial, message); in usb_serial_suspend()
1127 serial->suspending = 0; in usb_serial_suspend()
1132 for (i = 0; i < serial->num_ports; ++i) in usb_serial_suspend()
1133 usb_serial_port_poison_urbs(serial->port[i]); in usb_serial_suspend()
1139 static void usb_serial_unpoison_port_urbs(struct usb_serial *serial) in usb_serial_unpoison_port_urbs() argument
1143 for (i = 0; i < serial->num_ports; ++i) in usb_serial_unpoison_port_urbs()
1144 usb_serial_port_unpoison_urbs(serial->port[i]); in usb_serial_unpoison_port_urbs()
1149 struct usb_serial *serial = usb_get_intfdata(intf); in usb_serial_resume() local
1152 usb_serial_unpoison_port_urbs(serial); in usb_serial_resume()
1154 serial->suspending = 0; in usb_serial_resume()
1155 if (serial->type->resume) in usb_serial_resume()
1156 rv = serial->type->resume(serial); in usb_serial_resume()
1158 rv = usb_serial_generic_resume(serial); in usb_serial_resume()
1166 struct usb_serial *serial = usb_get_intfdata(intf); in usb_serial_reset_resume() local
1169 usb_serial_unpoison_port_urbs(serial); in usb_serial_reset_resume()
1171 serial->suspending = 0; in usb_serial_reset_resume()
1172 if (serial->type->reset_resume) { in usb_serial_reset_resume()
1173 rv = serial->type->reset_resume(serial); in usb_serial_reset_resume()
1315 WARN(1, "Serial driver %s has no usb_driver\n", in usb_serial_register()
1334 pr_info("USB Serial support registered for %s\n", driver->description); in usb_serial_register()
1342 pr_info("USB Serial deregistering driver %s\n", device->description); in usb_serial_deregister()
1352 * usb_serial_register_drivers - register drivers for a usb-serial module
1369 * udriver must be registered before any of the serial drivers, in usb_serial_register_drivers()
1370 * because the store_new_id() routine for the serial drivers (in in usb_serial_register_drivers()
1374 * the serial drivers are registered, because the probe would in usb_serial_register_drivers()
1375 * simply fail for lack of a matching serial driver. in usb_serial_register_drivers()
1378 * Suspend/resume support is implemented in the usb-serial core, in usb_serial_register_drivers()
1428 * usb_serial_deregister_drivers - deregister drivers for a usb-serial module