| .. | .. |
|---|
| 10 | 10 | * This driver was originally based on the ACM driver by Armin Fuerst (which was |
|---|
| 11 | 11 | * based on a driver by Brad Keryan) |
|---|
| 12 | 12 | * |
|---|
| 13 | | - * See Documentation/usb/usb-serial.txt for more information on using this |
|---|
| 13 | + * See Documentation/usb/usb-serial.rst for more information on using this |
|---|
| 14 | 14 | * driver |
|---|
| 15 | 15 | */ |
|---|
| 16 | 16 | |
|---|
| .. | .. |
|---|
| 164 | 164 | * @driver: the driver (USB in our case) |
|---|
| 165 | 165 | * @tty: the tty being created |
|---|
| 166 | 166 | * |
|---|
| 167 | | - * Create the termios objects for this tty. We use the default |
|---|
| 167 | + * Initialise the termios structure for this tty. We use the default |
|---|
| 168 | 168 | * USB serial settings but permit them to be overridden by |
|---|
| 169 | | - * serial->type->init_termios. |
|---|
| 169 | + * serial->type->init_termios on first open. |
|---|
| 170 | 170 | * |
|---|
| 171 | 171 | * This is the first place a new tty gets used. Hence this is where we |
|---|
| 172 | 172 | * acquire references to the usb_serial structure and the driver module, |
|---|
| .. | .. |
|---|
| 178 | 178 | int idx = tty->index; |
|---|
| 179 | 179 | struct usb_serial *serial; |
|---|
| 180 | 180 | struct usb_serial_port *port; |
|---|
| 181 | + bool init_termios; |
|---|
| 181 | 182 | int retval = -ENODEV; |
|---|
| 182 | 183 | |
|---|
| 183 | 184 | port = usb_serial_port_get_by_minor(idx); |
|---|
| .. | .. |
|---|
| 192 | 193 | if (retval) |
|---|
| 193 | 194 | goto error_get_interface; |
|---|
| 194 | 195 | |
|---|
| 196 | + init_termios = (driver->termios[idx] == NULL); |
|---|
| 197 | + |
|---|
| 195 | 198 | retval = tty_standard_install(driver, tty); |
|---|
| 196 | 199 | if (retval) |
|---|
| 197 | 200 | goto error_init_termios; |
|---|
| 198 | 201 | |
|---|
| 199 | 202 | mutex_unlock(&serial->disc_mutex); |
|---|
| 200 | 203 | |
|---|
| 201 | | - /* allow the driver to update the settings */ |
|---|
| 202 | | - if (serial->type->init_termios) |
|---|
| 204 | + /* allow the driver to update the initial settings */ |
|---|
| 205 | + if (init_termios && serial->type->init_termios) |
|---|
| 203 | 206 | serial->type->init_termios(tty); |
|---|
| 204 | 207 | |
|---|
| 205 | 208 | tty->driver_data = port; |
|---|
| .. | .. |
|---|
| 251 | 254 | * |
|---|
| 252 | 255 | * Shut down a USB serial port. Serialized against activate by the |
|---|
| 253 | 256 | * tport mutex and kept to matching open/close pairs |
|---|
| 254 | | - * of calls by the initialized flag. |
|---|
| 257 | + * of calls by the tty-port initialized flag. |
|---|
| 255 | 258 | * |
|---|
| 256 | 259 | * Not called if tty is console. |
|---|
| 257 | 260 | */ |
|---|
| .. | .. |
|---|
| 285 | 288 | |
|---|
| 286 | 289 | /** |
|---|
| 287 | 290 | * serial_cleanup - free resources post close/hangup |
|---|
| 288 | | - * @port: port to free up |
|---|
| 291 | + * @tty: tty to clean up |
|---|
| 289 | 292 | * |
|---|
| 290 | 293 | * Do the resource freeing and refcount dropping for the port. |
|---|
| 291 | 294 | * Avoid freeing the console. |
|---|
| .. | .. |
|---|
| 391 | 394 | |
|---|
| 392 | 395 | if (port->serial->type->unthrottle) |
|---|
| 393 | 396 | port->serial->type->unthrottle(tty); |
|---|
| 397 | +} |
|---|
| 398 | + |
|---|
| 399 | +static int serial_get_serial(struct tty_struct *tty, struct serial_struct *ss) |
|---|
| 400 | +{ |
|---|
| 401 | + struct usb_serial_port *port = tty->driver_data; |
|---|
| 402 | + |
|---|
| 403 | + if (port->serial->type->get_serial) |
|---|
| 404 | + return port->serial->type->get_serial(tty, ss); |
|---|
| 405 | + return -ENOTTY; |
|---|
| 406 | +} |
|---|
| 407 | + |
|---|
| 408 | +static int serial_set_serial(struct tty_struct *tty, struct serial_struct *ss) |
|---|
| 409 | +{ |
|---|
| 410 | + struct usb_serial_port *port = tty->driver_data; |
|---|
| 411 | + |
|---|
| 412 | + if (port->serial->type->set_serial) |
|---|
| 413 | + return port->serial->type->set_serial(tty, ss); |
|---|
| 414 | + return -ENOTTY; |
|---|
| 394 | 415 | } |
|---|
| 395 | 416 | |
|---|
| 396 | 417 | static int serial_ioctl(struct tty_struct *tty, |
|---|
| .. | .. |
|---|
| 1174 | 1195 | .tiocmget = serial_tiocmget, |
|---|
| 1175 | 1196 | .tiocmset = serial_tiocmset, |
|---|
| 1176 | 1197 | .get_icount = serial_get_icount, |
|---|
| 1198 | + .set_serial = serial_set_serial, |
|---|
| 1199 | + .get_serial = serial_get_serial, |
|---|
| 1177 | 1200 | .cleanup = serial_cleanup, |
|---|
| 1178 | 1201 | .install = serial_install, |
|---|
| 1179 | 1202 | .proc_show = serial_proc_show, |
|---|