Lines Matching refs:driver

256 	if (!tty || !tty->driver)
258 return tty->driver->name;
291 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
292 tty->driver->subtype == PTY_TYPE_SLAVE &&
311 * This routine returns a tty driver structure, given a device number
337 * like (4, 64) or (188, 1). If no corresponding driver is registered then
373 /* if here then driver wasn't found */
388 * This routine returns a tty driver structure, given a name
389 * and the condition that the tty driver is capable of polled
524 * informs the line discipline if present that the driver is ready
650 * We don't want to have driver/ldisc interactions beyond the ones
651 * we did here. The driver layer expects no calls after ->hangup()
757 * Perform flow control to the driver. May be called
758 * on an already stopped device and will not re-call the driver
762 * halting incoming flow and by the driver. It may therefore be
794 * tty was previous stopped and is now being started, the driver
1095 * Writes to the tty driver are serialized by the atomic_write_lock
1188 * @driver: the tty driver in use
1192 * Generate a name from a driver reference and write it to the output
1197 static void pty_line_name(struct tty_driver *driver, int index, char *p)
1199 int i = index + driver->name_base;
1202 driver->subtype == PTY_TYPE_SLAVE ? "tty" : driver->name,
1208 * @driver: the tty driver in use
1212 * Generate a name from a driver reference and write it to the output
1217 static ssize_t tty_line_name(struct tty_driver *driver, int index, char *p)
1219 if (driver->flags & TTY_DRIVER_UNNUMBERED_NODE)
1220 return sprintf(p, "%s", driver->name);
1222 return sprintf(p, "%s%d", driver->name,
1223 index + driver->name_base);
1228 * @driver: the driver for the tty
1232 * driver lookup() method returns an error.
1236 static struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver,
1241 if (driver->ops->lookup) {
1245 tty = driver->ops->lookup(driver, file, idx);
1247 if (idx >= driver->num)
1249 tty = driver->ttys[idx];
1269 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS)
1270 tty->termios = tty->driver->init_termios;
1273 tp = tty->driver->termios[idx];
1276 tty->termios.c_line = tty->driver->init_termios.c_line;
1278 tty->termios = tty->driver->init_termios;
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
1308 static int tty_driver_install_tty(struct tty_driver *driver,
1311 return driver->ops->install ? driver->ops->install(driver, tty) :
1312 tty_standard_install(driver, tty);
1316 * tty_driver_remove_tty() - remove a tty from the driver tables
1317 * @driver: the driver for the tty
1320 * Remvoe a tty object from the driver tables. The tty->index field
1325 static void tty_driver_remove_tty(struct tty_driver *driver, struct tty_struct *tty)
1327 if (driver->ops->remove)
1328 driver->ops->remove(driver, tty);
1330 driver->ttys[tty->index] = NULL;
1344 struct tty_driver *driver = tty->driver;
1348 if (driver->type == TTY_DRIVER_TYPE_PTY &&
1349 driver->subtype == PTY_TYPE_MASTER)
1379 * @driver: tty driver we are opening a device on
1388 * protects us from the tty struct or driver itself going away.
1402 struct tty_struct *tty_init_dev(struct tty_driver *driver, int idx)
1415 if (!try_module_get(driver->owner))
1418 tty = alloc_tty_struct(driver, idx);
1425 retval = tty_driver_install_tty(driver, tty);
1430 tty->port = driver->ports[idx];
1433 "%s: %s driver does not set tty->port. This would crash the kernel. Fix the driver!\n",
1434 __func__, tty->driver->name)) {
1460 module_put(driver->owner);
1475 * tty_save_termios() - save tty termios data in driver table
1486 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS)
1490 tp = tty->driver->termios[idx];
1495 tty->driver->termios[idx] = tp;
1522 * driver table slots. This function is called when a device is no longer
1527 * of ttys that the driver keeps.
1529 * This method gets called from a work queue so that the driver private
1536 struct tty_driver *driver = tty->driver;
1537 struct module *owner = driver->owner;
1543 tty_driver_kref_put(driver);
1589 * of ttys that the driver keeps.
1600 tty_driver_remove_tty(tty->driver, tty);
1625 if (idx < 0 || idx >= tty->driver->num) {
1631 if (tty->driver->flags & TTY_DRIVER_DEVPTS_MEM)
1634 if (tty != tty->driver->ttys[idx]) {
1635 tty_debug(tty, "bad driver table[%d] = %p\n",
1636 idx, tty->driver->ttys[idx]);
1639 if (tty->driver->other) {
1642 if (o_tty != tty->driver->other->ttys[idx]) {
1644 idx, tty->driver->other->ttys[idx]);
1752 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
1753 tty->driver->subtype == PTY_TYPE_MASTER)
1882 * We cannot return driver and index like for the other nodes because
1911 * tty_lookup_driver - lookup a tty driver for a given device file
1914 * @index: index for the device in the @return driver
1915 * @return: driver for this inode (with increased refcount)
1925 struct tty_driver *driver = NULL;
1931 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;
1963 * Opens tty exclusively for kernel. Performs the driver lookup,
1971 * - concurrent tty driver removal w/ lookup
1972 * - concurrent tty removal from driver table
1977 struct tty_driver *driver;
1981 driver = tty_lookup_driver(device, NULL, &index);
1982 if (IS_ERR(driver)) {
1984 return ERR_CAST(driver);
1988 tty = tty_driver_lookup_tty(driver, NULL, index);
1997 tty = tty_init_dev(driver, index);
2004 tty_driver_kref_put(driver);
2014 * Performs the driver lookup, checks for a reopen, or otherwise
2021 * - concurrent tty driver removal w/ lookup
2022 * - concurrent tty removal from driver table
2028 struct tty_driver *driver = NULL;
2033 driver = tty_lookup_driver(device, filp, &index);
2034 if (IS_ERR(driver)) {
2036 return ERR_CAST(driver);
2040 tty = tty_driver_lookup_tty(driver, filp, index);
2068 tty = tty_init_dev(driver, index);
2072 tty_driver_kref_put(driver);
2162 (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
2163 tty->driver->subtype == PTY_TYPE_MASTER);
2346 * actually has driver level meaning and triggers a VC resize.
2457 * Perform a timed break on hardware that lacks its own driver level
2472 if (tty->driver->flags & TTY_DRIVER_HARDWARE_BREAK)
2500 * Obtain the modem status bits from the tty driver if the feature
2503 * Locking: none (up to the driver)
2525 * Set the modem status bits from the tty driver if the feature
2528 * Locking: none (up to the driver)
2617 if (tty->driver->type == TTY_DRIVER_TYPE_PTY &&
2618 tty->driver->subtype == PTY_TYPE_MASTER)
3073 struct tty_struct *alloc_tty_struct(struct tty_driver *driver, int idx)
3104 tty->driver = driver;
3105 tty->ops = driver->ops;
3107 tty_line_name(driver, idx, tty->name);
3121 * Note: the specific put_char operation in the driver layer may go
3135 static int tty_cdev_add(struct tty_driver *driver, dev_t dev,
3141 driver->cdevs[index] = cdev_alloc();
3142 if (!driver->cdevs[index])
3144 driver->cdevs[index]->ops = &tty_fops;
3145 driver->cdevs[index]->owner = driver->owner;
3146 err = cdev_add(driver->cdevs[index], dev, count);
3148 kobject_put(&driver->cdevs[index]->kobj);
3154 * @driver: the tty driver that describes the tty device
3155 * @index: the index in the tty driver for this tty device
3164 * if the tty driver's flags have the TTY_DRIVER_DYNAMIC_DEV bit set. If
3166 * driver.
3171 struct device *tty_register_device(struct tty_driver *driver, unsigned index,
3174 return tty_register_device_attr(driver, index, device, NULL, NULL);
3186 * @driver: the tty driver that describes the tty device
3187 * @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.
3204 struct device *tty_register_device_attr(struct tty_driver *driver,
3210 dev_t devt = MKDEV(driver->major, driver->minor_start) + index;
3215 if (index >= driver->num) {
3217 driver->name, index);
3221 if (driver->type == TTY_DRIVER_TYPE_PTY)
3222 pty_line_name(driver, index, name);
3224 tty_line_name(driver, index, name);
3244 if (!(driver->flags & TTY_DRIVER_DYNAMIC_ALLOC)) {
3249 tp = driver->termios[index];
3251 driver->termios[index] = NULL;
3255 retval = tty_cdev_add(driver, devt, index, 1);
3276 * @driver: the tty driver that describes the tty device
3277 * @index: the index in the tty driver for this tty device
3285 void tty_unregister_device(struct tty_driver *driver, unsigned index)
3288 MKDEV(driver->major, driver->minor_start) + index);
3289 if (!(driver->flags & TTY_DRIVER_DYNAMIC_ALLOC)) {
3290 cdev_del(driver->cdevs[index]);
3291 driver->cdevs[index] = NULL;
3297 * __tty_alloc_driver -- allocate tty driver
3298 * @lines: count of lines this driver can handle at most
3299 * @owner: module which is responsible for this driver
3300 * @flags: some of TTY_DRIVER_* flags, will be set in driver->flags
3308 struct tty_driver *driver;
3315 driver = kzalloc(sizeof(*driver), GFP_KERNEL);
3316 if (!driver)
3319 kref_init(&driver->kref);
3320 driver->magic = TTY_DRIVER_MAGIC;
3321 driver->num = lines;
3322 driver->owner = owner;
3323 driver->flags = flags;
3326 driver->ttys = kcalloc(lines, sizeof(*driver->ttys),
3328 driver->termios = kcalloc(lines, sizeof(*driver->termios),
3330 if (!driver->ttys || !driver->termios) {
3337 driver->ports = kcalloc(lines, sizeof(*driver->ports),
3339 if (!driver->ports) {
3346 driver->cdevs = kcalloc(cdevs, sizeof(*driver->cdevs), GFP_KERNEL);
3347 if (!driver->cdevs) {
3352 return driver;
3354 kfree(driver->ports);
3355 kfree(driver->ttys);
3356 kfree(driver->termios);
3357 kfree(driver->cdevs);
3358 kfree(driver);
3365 struct tty_driver *driver = container_of(kref, struct tty_driver, kref);
3369 if (driver->flags & TTY_DRIVER_INSTALLED) {
3370 for (i = 0; i < driver->num; i++) {
3371 tp = driver->termios[i];
3373 driver->termios[i] = NULL;
3376 if (!(driver->flags & TTY_DRIVER_DYNAMIC_DEV))
3377 tty_unregister_device(driver, i);
3379 proc_tty_unregister_driver(driver);
3380 if (driver->flags & TTY_DRIVER_DYNAMIC_ALLOC)
3381 cdev_del(driver->cdevs[0]);
3383 kfree(driver->cdevs);
3384 kfree(driver->ports);
3385 kfree(driver->termios);
3386 kfree(driver->ttys);
3387 kfree(driver);
3390 void tty_driver_kref_put(struct tty_driver *driver)
3392 kref_put(&driver->kref, destruct_tty_driver);
3396 void tty_set_operations(struct tty_driver *driver,
3399 driver->ops = op;
3410 * Called by a tty driver to register itself.
3412 int tty_register_driver(struct tty_driver *driver)
3419 if (!driver->major) {
3420 error = alloc_chrdev_region(&dev, driver->minor_start,
3421 driver->num, driver->name);
3423 driver->major = MAJOR(dev);
3424 driver->minor_start = MINOR(dev);
3427 dev = MKDEV(driver->major, driver->minor_start);
3428 error = register_chrdev_region(dev, driver->num, driver->name);
3433 if (driver->flags & TTY_DRIVER_DYNAMIC_ALLOC) {
3434 error = tty_cdev_add(driver, dev, 0, driver->num);
3440 list_add(&driver->tty_drivers, &tty_drivers);
3443 if (!(driver->flags & TTY_DRIVER_DYNAMIC_DEV)) {
3444 for (i = 0; i < driver->num; i++) {
3445 d = tty_register_device(driver, i, NULL);
3452 proc_tty_register_driver(driver);
3453 driver->flags |= TTY_DRIVER_INSTALLED;
3458 tty_unregister_device(driver, i);
3461 list_del(&driver->tty_drivers);
3465 unregister_chrdev_region(dev, driver->num);
3472 * Called by a tty driver to unregister itself.
3474 int tty_unregister_driver(struct tty_driver *driver)
3478 if (driver->refcount)
3481 unregister_chrdev_region(MKDEV(driver->major, driver->minor_start),
3482 driver->num);
3484 list_del(&driver->tty_drivers);
3493 return MKDEV(tty->driver->major, tty->driver->minor_start) + tty->index;
3590 panic("Couldn't register /dev/tty driver\n");
3596 panic("Couldn't register /dev/console driver\n");