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
1110 * Writes to the tty driver are serialized by the atomic_write_lock
1179 * @driver: the tty driver in use
1183 * Generate a name from a @driver reference and write it to the output buffer
1188 static void pty_line_name(struct tty_driver *driver, int index, char *p)
1191 int i = index + driver->name_base;
1194 driver->subtype == PTY_TYPE_SLAVE ? "tty" : driver->name,
1200 * @driver: the tty driver in use
1204 * Generate a name from a @driver reference and write it to the output buffer
1209 static ssize_t tty_line_name(struct tty_driver *driver, int index, char *p)
1211 if (driver->flags & TTY_DRIVER_UNNUMBERED_NODE)
1212 return sprintf(p, "%s", driver->name);
1214 return sprintf(p, "%s%d", driver->name,
1215 index + driver->name_base);
1220 * @driver: the driver for the tty
1225 * driver lookup() method returns an error.
1229 static struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver,
1234 if (driver->ops->lookup) {
1238 tty = driver->ops->lookup(driver, file, idx);
1240 if (idx >= driver->num)
1242 tty = driver->ttys[idx];
1261 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS)
1262 tty->termios = tty->driver->init_termios;
1265 tp = tty->driver->termios[idx];
1268 tty->termios.c_line = tty->driver->init_termios.c_line;
1270 tty->termios = tty->driver->init_termios;
1280 * @driver: the driver for the tty
1283 * If the @driver overrides @tty->ops->install, it still can call this function
1286 int tty_standard_install(struct tty_driver *driver, struct tty_struct *tty)
1289 tty_driver_kref_get(driver);
1291 driver->ttys[tty->index] = tty;
1297 * tty_driver_install_tty() - install a tty entry in the driver
1298 * @driver: the driver for the tty
1301 * Install a tty object into the driver tables. The @tty->index field will be
1307 static int tty_driver_install_tty(struct tty_driver *driver,
1310 return driver->ops->install ? driver->ops->install(driver, tty) :
1311 tty_standard_install(driver, tty);
1315 * tty_driver_remove_tty() - remove a tty from the driver tables
1316 * @driver: the driver for the tty
1319 * Remove a tty object from the driver tables. The tty->index field will be set
1324 static void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct *tty)
1326 if (driver->ops->remove)
1327 driver->ops->remove(driver, tty);
1329 driver->ttys[tty->index] = NULL;
1343 struct tty_driver *driver = tty->driver;
1347 if (driver->type == TTY_DRIVER_TYPE_PTY &&
1348 driver->subtype == PTY_TYPE_MASTER)
1378 * @driver: tty driver we are opening a device on
1386 * tty struct or driver itself going away.
1399 struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx)
1412 if (!try_module_get(driver->owner))
1415 tty = alloc_tty_struct(driver, idx);
1422 retval = tty_driver_install_tty(driver, tty);
1427 tty->port = driver->ports[idx];
1430 "%s: %s driver does not set tty->port. This would crash the kernel. Fix the driver!\n",
1431 __func__, tty->driver->name)) {
1457 module_put(driver->owner);
1472 * tty_save_termios() - save tty termios data in driver table
1483 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS)
1487 tp = tty->driver->termios[idx];
1492 tty->driver->termios[idx] = tp;
1519 * driver table slots. This function is called when a device is no longer
1524 * that the driver keeps.
1526 * This method gets called from a work queue so that the driver private
1533 struct tty_driver *driver = tty->driver;
1534 struct module *owner = driver->owner;
1539 tty_driver_kref_put(driver);
1587 * that the driver keeps.
1597 tty_driver_remove_tty(tty->driver, tty);
1622 if (idx < 0 || idx >= tty->driver->num) {
1628 if (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM)
1631 if (tty != tty->driver->ttys[idx]) {
1632 tty_debug(tty, "bad driver table[%d] = %p\n",
1633 idx, tty->driver->ttys[idx]);
1636 if (tty->driver->other) {
1639 if (o_tty != tty->driver->other->ttys[idx]) {
1641 idx, tty->driver->other->ttys[idx]);
1748 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
1749 tty->driver->subtype == PTY_TYPE_MASTER)
1879 * We cannot return driver and index like for the other nodes because devpts
1908 * tty_lookup_driver - lookup a tty driver for a given device file
1911 * @index: index for the device in the @return driver
1918 * Return: driver for this inode (with increased refcount)
1923 struct tty_driver *driver = NULL;
1930 driver = tty_driver_kref_get(console_driver);
1939 driver = tty_driver_kref_get(console_driver);
1940 if (driver && filp) {
1946 if (driver)
1947 tty_driver_kref_put(driver);
1951 driver = get_tty_driver(device, index);
1952 if (!driver)
1956 return driver;
1962 struct tty_driver *driver;
1966 driver = tty_lookup_driver(device, NULL, &index);
1967 if (IS_ERR(driver)) {
1969 return ERR_CAST(driver);
1973 tty = tty_driver_lookup_tty(driver, NULL, index);
1982 tty = tty_init_dev(driver, index);
1989 tty_driver_kref_put(driver);
1997 * Opens tty exclusively for kernel. Performs the driver lookup, makes sure
2002 * * concurrent tty driver removal w/ lookup
2003 * * concurrent tty removal from driver table
2033 * Performs the driver lookup, checks for a reopen, or otherwise performs the
2039 * * concurrent tty driver removal w/ lookup
2040 * * concurrent tty removal from driver table
2048 struct tty_driver *driver = NULL;
2053 driver = tty_lookup_driver(device, filp, &index);
2054 if (IS_ERR(driver)) {
2056 return ERR_CAST(driver);
2060 tty = tty_driver_lookup_tty(driver, filp, index);
2088 tty = tty_init_dev(driver, index);
2092 tty_driver_kref_put(driver);
2181 (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
2182 tty->driver->subtype == PTY_TYPE_MASTER);
2362 * just advisory information but for the Linux console it actually has driver
2472 * Perform a timed break on hardware that lacks its own driver level timed
2485 if (tty->driver->flags & TTY_DRIVER_HARDWARE_BREAK)
2512 * Obtain the modem status bits from the tty driver if the feature
2531 * Obtain the modem status bits from the tty driver if the feature is
2534 * Locking: none (up to the driver)
2553 * Set the modem status bits from the tty driver if the feature
2556 * Locking: none (up to the driver)
2595 * Locking: none (up to the driver)
2670 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
2671 tty->driver->subtype == PTY_TYPE_MASTER)
3105 * @driver: driver which will handle the returned tty
3112 struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)
3142 tty->driver = driver;
3143 tty->ops = driver->ops;
3145 tty_line_name(driver, idx, tty->name);
3159 * Note: the specific put_char operation in the driver layer may go
3172 static int tty_cdev_add(struct tty_driver *driver, dev_t dev,
3178 driver->cdevs[index] = cdev_alloc();
3179 if (!driver->cdevs[index])
3181 driver->cdevs[index]->ops = &tty_fops;
3182 driver->cdevs[index]->owner = driver->owner;
3183 err = cdev_add(driver->cdevs[index], dev, count);
3185 kobject_put(&driver->cdevs[index]->kobj);
3191 * @driver: the tty driver that describes the tty device
3192 * @index: the index in the tty driver for this tty device
3198 * if the tty driver's flags have the %TTY_DRIVER_DYNAMIC_DEV bit set. If
3200 * driver.
3207 struct device *tty_register_device(struct tty_driver *driver, unsigned index,
3210 return tty_register_device_attr(driver, index, device, NULL, NULL);
3222 * @driver: the tty driver that describes the tty device
3223 * @index: the index in the tty driver for this tty device
3231 * tty driver's flags have the %TTY_DRIVER_DYNAMIC_DEV bit set. If that bit is
3232 * not set, this function should not be called by a tty driver.
3239 struct device *tty_register_device_attr(struct tty_driver *driver,
3245 dev_t devt = MKDEV(driver->major, driver->minor_start) + index;
3250 if (index >= driver->num) {
3252 driver->name, index);
3256 if (driver->type == TTY_DRIVER_TYPE_PTY)
3257 pty_line_name(driver, index, name);
3259 tty_line_name(driver, index, name);
3279 if (!(driver->flags & TTY_DRIVER_DYNAMIC_ALLOC)) {
3284 tp = driver->termios[index];
3286 driver->termios[index] = NULL;
3290 retval = tty_cdev_add(driver, devt, index, 1);
3311 * @driver: the tty driver that describes the tty device
3312 * @index: the index in the tty driver for this tty device
3319 void tty_unregister_device(struct tty_driver *driver, unsigned index)
3321 device_destroy(&tty_class, MKDEV(driver->major, driver->minor_start) + index);
3322 if (!(driver->flags & TTY_DRIVER_DYNAMIC_ALLOC)) {
3323 cdev_del(driver->cdevs[index]);
3324 driver->cdevs[index] = NULL;
3330 * __tty_alloc_driver - allocate tty driver
3331 * @lines: count of lines this driver can handle at most
3332 * @owner: module which is responsible for this driver
3333 * @flags: some of %TTY_DRIVER_ flags, will be set in driver->flags
3341 struct tty_driver *driver;
3348 driver = kzalloc(sizeof(*driver), GFP_KERNEL);
3349 if (!driver)
3352 kref_init(&driver->kref);
3353 driver->num = lines;
3354 driver->owner = owner;
3355 driver->flags = flags;
3358 driver->ttys = kcalloc(lines, sizeof(*driver->ttys),
3360 driver->termios = kcalloc(lines, sizeof(*driver->termios),
3362 if (!driver->ttys || !driver->termios) {
3369 driver->ports = kcalloc(lines, sizeof(*driver->ports),
3371 if (!driver->ports) {
3378 driver->cdevs = kcalloc(cdevs, sizeof(*driver->cdevs), GFP_KERNEL);
3379 if (!driver->cdevs) {
3384 return driver;
3386 kfree(driver->ports);
3387 kfree(driver->ttys);
3388 kfree(driver->termios);
3389 kfree(driver->cdevs);
3390 kfree(driver);
3397 struct tty_driver *driver = container_of(kref, struct tty_driver, kref);
3401 if (driver->flags & TTY_DRIVER_INSTALLED) {
3402 for (i = 0; i < driver->num; i++) {
3403 tp = driver->termios[i];
3405 driver->termios[i] = NULL;
3408 if (!(driver->flags & TTY_DRIVER_DYNAMIC_DEV))
3409 tty_unregister_device(driver, i);
3411 proc_tty_unregister_driver(driver);
3412 if (driver->flags & TTY_DRIVER_DYNAMIC_ALLOC)
3413 cdev_del(driver->cdevs[0]);
3415 kfree(driver->cdevs);
3416 kfree(driver->ports);
3417 kfree(driver->termios);
3418 kfree(driver->ttys);
3419 kfree(driver);
3423 * tty_driver_kref_put - drop a reference to a tty driver
3424 * @driver: driver of which to drop the reference
3426 * The final put will destroy and free up the driver.
3428 void tty_driver_kref_put(struct tty_driver *driver)
3430 kref_put(&driver->kref, destruct_tty_driver);
3435 * tty_register_driver - register a tty driver
3436 * @driver: driver to register
3438 * Called by a tty driver to register itself.
3440 int tty_register_driver(struct tty_driver *driver)
3447 if (!driver->major) {
3448 error = alloc_chrdev_region(&dev, driver->minor_start,
3449 driver->num, driver->name);
3451 driver->major = MAJOR(dev);
3452 driver->minor_start = MINOR(dev);
3455 dev = MKDEV(driver->major, driver->minor_start);
3456 error = register_chrdev_region(dev, driver->num, driver->name);
3461 if (driver->flags & TTY_DRIVER_DYNAMIC_ALLOC) {
3462 error = tty_cdev_add(driver, dev, 0, driver->num);
3468 list_add(&driver->tty_drivers, &tty_drivers);
3471 if (!(driver->flags & TTY_DRIVER_DYNAMIC_DEV)) {
3472 for (i = 0; i < driver->num; i++) {
3473 d = tty_register_device(driver, i, NULL);
3480 proc_tty_register_driver(driver);
3481 driver->flags |= TTY_DRIVER_INSTALLED;
3486 tty_unregister_device(driver, i);
3489 list_del(&driver->tty_drivers);
3493 unregister_chrdev_region(dev, driver->num);
3500 * tty_unregister_driver - unregister a tty driver
3501 * @driver: driver to unregister
3503 * Called by a tty driver to unregister itself.
3505 void tty_unregister_driver(struct tty_driver *driver)
3507 unregister_chrdev_region(MKDEV(driver->major, driver->minor_start),
3508 driver->num);
3510 list_del(&driver->tty_drivers);
3517 return MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index;
3650 panic("Couldn't register /dev/tty driver\n");
3656 panic("Couldn't register /dev/console driver\n");