Lines Matching refs:driver
254 if (!tty || !tty->driver)
256 return tty->driver->name;
284 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
285 tty->driver->subtype == PTY_TYPE_SLAVE &&
302 * This routine returns a tty driver structure, given a device number and also
328 * (4, 64) or (188, 1). If no corresponding driver is registered then the
364 /* if here then driver wasn't found */
379 * This routine returns a tty driver structure, given a name and the condition
380 * that the tty driver is capable of polled operation.
512 * line discipline if present that the driver is ready to receive more output
655 * We don't want to have driver/ldisc interactions beyond the ones
656 * we did here. The driver layer expects no calls after ->hangup()
762 * Perform flow control to the driver. May be called on an already stopped
766 * flow and by the driver. It may therefore be called from any context, may be
1102 * Writes to the tty driver are serialized by the atomic_write_lock
1171 * @driver: the tty driver in use
1175 * Generate a name from a @driver reference and write it to the output buffer
1180 static void pty_line_name(struct tty_driver *driver, int index, char *p)
1183 int i = index + driver->name_base;
1186 driver->subtype == PTY_TYPE_SLAVE ? "tty" : driver->name,
1192 * @driver: the tty driver in use
1196 * Generate a name from a @driver reference and write it to the output buffer
1201 static ssize_t tty_line_name(struct tty_driver *driver, int index, char *p)
1203 if (driver->flags & TTY_DRIVER_UNNUMBERED_NODE)
1204 return sprintf(p, "%s", driver->name);
1206 return sprintf(p, "%s%d", driver->name,
1207 index + driver->name_base);
1212 * @driver: the driver for the tty
1217 * driver lookup() method returns an error.
1221 static struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver,
1226 if (driver->ops->lookup) {
1230 tty = driver->ops->lookup(driver, file, idx);
1232 if (idx >= driver->num)
1234 tty = driver->ttys[idx];
1253 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS)
1254 tty->termios = tty->driver->init_termios;
1257 tp = tty->driver->termios[idx];
1260 tty->termios.c_line = tty->driver->init_termios.c_line;
1262 tty->termios = tty->driver->init_termios;
1272 * @driver: the driver for the tty
1275 * If the @driver overrides @tty->ops->install, it still can call this function
1278 int tty_standard_install(struct tty_driver *driver, struct tty_struct *tty)
1281 tty_driver_kref_get(driver);
1283 driver->ttys[tty->index] = tty;
1289 * tty_driver_install_tty() - install a tty entry in the driver
1290 * @driver: the driver for the tty
1293 * Install a tty object into the driver tables. The @tty->index field will be
1299 static int tty_driver_install_tty(struct tty_driver *driver,
1302 return driver->ops->install ? driver->ops->install(driver, tty) :
1303 tty_standard_install(driver, tty);
1307 * tty_driver_remove_tty() - remove a tty from the driver tables
1308 * @driver: the driver for the tty
1311 * Remove a tty object from the driver tables. The tty->index field will be set
1316 static void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct *tty)
1318 if (driver->ops->remove)
1319 driver->ops->remove(driver, tty);
1321 driver->ttys[tty->index] = NULL;
1335 struct tty_driver *driver = tty->driver;
1339 if (driver->type == TTY_DRIVER_TYPE_PTY &&
1340 driver->subtype == PTY_TYPE_MASTER)
1370 * @driver: tty driver we are opening a device on
1378 * tty struct or driver itself going away.
1391 struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx)
1404 if (!try_module_get(driver->owner))
1407 tty = alloc_tty_struct(driver, idx);
1414 retval = tty_driver_install_tty(driver, tty);
1419 tty->port = driver->ports[idx];
1422 "%s: %s driver does not set tty->port. This would crash the kernel. Fix the driver!\n",
1423 __func__, tty->driver->name)) {
1449 module_put(driver->owner);
1464 * tty_save_termios() - save tty termios data in driver table
1475 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS)
1479 tp = tty->driver->termios[idx];
1484 tty->driver->termios[idx] = tp;
1511 * driver table slots. This function is called when a device is no longer
1516 * that the driver keeps.
1518 * This method gets called from a work queue so that the driver private
1525 struct tty_driver *driver = tty->driver;
1526 struct module *owner = driver->owner;
1531 tty_driver_kref_put(driver);
1579 * that the driver keeps.
1589 tty_driver_remove_tty(tty->driver, tty);
1614 if (idx < 0 || idx >= tty->driver->num) {
1620 if (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM)
1623 if (tty != tty->driver->ttys[idx]) {
1624 tty_debug(tty, "bad driver table[%d] = %p\n",
1625 idx, tty->driver->ttys[idx]);
1628 if (tty->driver->other) {
1631 if (o_tty != tty->driver->other->ttys[idx]) {
1633 idx, tty->driver->other->ttys[idx]);
1740 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
1741 tty->driver->subtype == PTY_TYPE_MASTER)
1871 * We cannot return driver and index like for the other nodes because devpts
1900 * tty_lookup_driver - lookup a tty driver for a given device file
1903 * @index: index for the device in the @return driver
1910 * Return: driver for this inode (with increased refcount)
1915 struct tty_driver *driver = NULL;
1922 driver = tty_driver_kref_get(console_driver);
1931 driver = tty_driver_kref_get(console_driver);
1932 if (driver && filp) {
1938 if (driver)
1939 tty_driver_kref_put(driver);
1943 driver = get_tty_driver(device, index);
1944 if (!driver)
1948 return driver;
1954 struct tty_driver *driver;
1958 driver = tty_lookup_driver(device, NULL, &index);
1959 if (IS_ERR(driver)) {
1961 return ERR_CAST(driver);
1965 tty = tty_driver_lookup_tty(driver, NULL, index);
1974 tty = tty_init_dev(driver, index);
1981 tty_driver_kref_put(driver);
1989 * Opens tty exclusively for kernel. Performs the driver lookup, makes sure
1994 * * concurrent tty driver removal w/ lookup
1995 * * concurrent tty removal from driver table
2025 * Performs the driver lookup, checks for a reopen, or otherwise performs the
2031 * * concurrent tty driver removal w/ lookup
2032 * * concurrent tty removal from driver table
2040 struct tty_driver *driver = NULL;
2045 driver = tty_lookup_driver(device, filp, &index);
2046 if (IS_ERR(driver)) {
2048 return ERR_CAST(driver);
2052 tty = tty_driver_lookup_tty(driver, filp, index);
2080 tty = tty_init_dev(driver, index);
2084 tty_driver_kref_put(driver);
2173 (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
2174 tty->driver->subtype == PTY_TYPE_MASTER);
2354 * just advisory information but for the Linux console it actually has driver
2464 * Perform a timed break on hardware that lacks its own driver level timed
2477 if (tty->driver->flags & TTY_DRIVER_HARDWARE_BREAK)
2505 * Obtain the modem status bits from the tty driver if the feature is
2508 * Locking: none (up to the driver)
2529 * Set the modem status bits from the tty driver if the feature
2532 * Locking: none (up to the driver)
2571 * Locking: none (up to the driver)
2646 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
2647 tty->driver->subtype == PTY_TYPE_MASTER)
3081 * @driver: driver which will handle the returned tty
3088 struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)
3118 tty->driver = driver;
3119 tty->ops = driver->ops;
3121 tty_line_name(driver, idx, tty->name);
3135 * Note: the specific put_char operation in the driver layer may go
3148 static int tty_cdev_add(struct tty_driver *driver, dev_t dev,
3154 driver->cdevs[index] = cdev_alloc();
3155 if (!driver->cdevs[index])
3157 driver->cdevs[index]->ops = &tty_fops;
3158 driver->cdevs[index]->owner = driver->owner;
3159 err = cdev_add(driver->cdevs[index], dev, count);
3161 kobject_put(&driver->cdevs[index]->kobj);
3167 * @driver: the tty driver that describes the tty device
3168 * @index: the index in the tty driver for this tty device
3174 * if the tty driver's flags have the %TTY_DRIVER_DYNAMIC_DEV bit set. If
3176 * driver.
3183 struct device *tty_register_device(struct tty_driver *driver, unsigned index,
3186 return tty_register_device_attr(driver, index, device, NULL, NULL);
3198 * @driver: the tty driver that describes the tty device
3199 * @index: the index in the tty driver for this tty device
3207 * tty driver's flags have the %TTY_DRIVER_DYNAMIC_DEV bit set. If that bit is
3208 * not set, this function should not be called by a tty driver.
3215 struct device *tty_register_device_attr(struct tty_driver *driver,
3221 dev_t devt = MKDEV(driver->major, driver->minor_start) + index;
3226 if (index >= driver->num) {
3228 driver->name, index);
3232 if (driver->type == TTY_DRIVER_TYPE_PTY)
3233 pty_line_name(driver, index, name);
3235 tty_line_name(driver, index, name);
3255 if (!(driver->flags & TTY_DRIVER_DYNAMIC_ALLOC)) {
3260 tp = driver->termios[index];
3262 driver->termios[index] = NULL;
3266 retval = tty_cdev_add(driver, devt, index, 1);
3287 * @driver: the tty driver that describes the tty device
3288 * @index: the index in the tty driver for this tty device
3295 void tty_unregister_device(struct tty_driver *driver, unsigned index)
3297 device_destroy(&tty_class, MKDEV(driver->major, driver->minor_start) + index);
3298 if (!(driver->flags & TTY_DRIVER_DYNAMIC_ALLOC)) {
3299 cdev_del(driver->cdevs[index]);
3300 driver->cdevs[index] = NULL;
3306 * __tty_alloc_driver -- allocate tty driver
3307 * @lines: count of lines this driver can handle at most
3308 * @owner: module which is responsible for this driver
3309 * @flags: some of %TTY_DRIVER_ flags, will be set in driver->flags
3317 struct tty_driver *driver;
3324 driver = kzalloc(sizeof(*driver), GFP_KERNEL);
3325 if (!driver)
3328 kref_init(&driver->kref);
3329 driver->num = lines;
3330 driver->owner = owner;
3331 driver->flags = flags;
3334 driver->ttys = kcalloc(lines, sizeof(*driver->ttys),
3336 driver->termios = kcalloc(lines, sizeof(*driver->termios),
3338 if (!driver->ttys || !driver->termios) {
3345 driver->ports = kcalloc(lines, sizeof(*driver->ports),
3347 if (!driver->ports) {
3354 driver->cdevs = kcalloc(cdevs, sizeof(*driver->cdevs), GFP_KERNEL);
3355 if (!driver->cdevs) {
3360 return driver;
3362 kfree(driver->ports);
3363 kfree(driver->ttys);
3364 kfree(driver->termios);
3365 kfree(driver->cdevs);
3366 kfree(driver);
3373 struct tty_driver *driver = container_of(kref, struct tty_driver, kref);
3377 if (driver->flags & TTY_DRIVER_INSTALLED) {
3378 for (i = 0; i < driver->num; i++) {
3379 tp = driver->termios[i];
3381 driver->termios[i] = NULL;
3384 if (!(driver->flags & TTY_DRIVER_DYNAMIC_DEV))
3385 tty_unregister_device(driver, i);
3387 proc_tty_unregister_driver(driver);
3388 if (driver->flags & TTY_DRIVER_DYNAMIC_ALLOC)
3389 cdev_del(driver->cdevs[0]);
3391 kfree(driver->cdevs);
3392 kfree(driver->ports);
3393 kfree(driver->termios);
3394 kfree(driver->ttys);
3395 kfree(driver);
3399 * tty_driver_kref_put -- drop a reference to a tty driver
3400 * @driver: driver of which to drop the reference
3402 * The final put will destroy and free up the driver.
3404 void tty_driver_kref_put(struct tty_driver *driver)
3406 kref_put(&driver->kref, destruct_tty_driver);
3411 * tty_register_driver -- register a tty driver
3412 * @driver: driver to register
3414 * Called by a tty driver to register itself.
3416 int tty_register_driver(struct tty_driver *driver)
3423 if (!driver->major) {
3424 error = alloc_chrdev_region(&dev, driver->minor_start,
3425 driver->num, driver->name);
3427 driver->major = MAJOR(dev);
3428 driver->minor_start = MINOR(dev);
3431 dev = MKDEV(driver->major, driver->minor_start);
3432 error = register_chrdev_region(dev, driver->num, driver->name);
3437 if (driver->flags & TTY_DRIVER_DYNAMIC_ALLOC) {
3438 error = tty_cdev_add(driver, dev, 0, driver->num);
3444 list_add(&driver->tty_drivers, &tty_drivers);
3447 if (!(driver->flags & TTY_DRIVER_DYNAMIC_DEV)) {
3448 for (i = 0; i < driver->num; i++) {
3449 d = tty_register_device(driver, i, NULL);
3456 proc_tty_register_driver(driver);
3457 driver->flags |= TTY_DRIVER_INSTALLED;
3462 tty_unregister_device(driver, i);
3465 list_del(&driver->tty_drivers);
3469 unregister_chrdev_region(dev, driver->num);
3476 * tty_unregister_driver -- unregister a tty driver
3477 * @driver: driver to unregister
3479 * Called by a tty driver to unregister itself.
3481 void tty_unregister_driver(struct tty_driver *driver)
3483 unregister_chrdev_region(MKDEV(driver->major, driver->minor_start),
3484 driver->num);
3486 list_del(&driver->tty_drivers);
3493 return MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index;
3627 panic("Couldn't register /dev/tty driver\n");
3633 panic("Couldn't register /dev/console driver\n");