[PATCH 3/4] tty: allow tty drivers to rename their device nodes
From: Tilman Schmidt <hidden>
Date: 2014-05-18 22:43:23
Subsystem:
the rest, tty layer and serial drivers · Maintainers:
Linus Torvalds, Greg Kroah-Hartman, Jiri Slaby
From: Paul Bolle <redacted>
The device nodes for tty drivers are named using a straightforward
scheme: tty_driver->name with an (increasing) digit appended. But the
capi driver (a part of one of the current ISDN subsystems) requires a
different naming scheme for its "capi_nc" tty_driver:
/dev/capi/0
/dev/capi/1
[...]
So add a devnode() callback to struct tty_driver to allow tty drivers
to use a more elaborate naming scheme. And let tty_devnode(), the
devnode() callback for the "tty" class, call that new callback if a tty
driver uses one. This allows the capi driver to add a callback to
enable its scheme.
Signed-off-by: Paul Bolle <redacted>
Signed-off-by: Tilman Schmidt <redacted>
---
drivers/tty/tty_io.c | 16 ++++++++++++++--
include/linux/tty_driver.h | 1 +
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 3411071..32d7878 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c@@ -3504,12 +3504,24 @@ void __init console_init(void) static char *tty_devnode(struct device *dev, umode_t *mode) { + struct tty_driver *driver = NULL; + int unused; + char *ret = NULL; + + mutex_lock(&tty_mutex); + driver = get_tty_driver(dev->devt, &unused); + mutex_unlock(&tty_mutex); + if (driver && driver->devnode) + ret = driver->devnode(dev, mode); + if (driver) + tty_driver_kref_put(driver); + if (!mode) - return NULL; + return ret; if (dev->devt == MKDEV(TTYAUX_MAJOR, 0) || dev->devt == MKDEV(TTYAUX_MAJOR, 2)) *mode = 0666; - return NULL; + return ret; } static int __init tty_class_init(void)
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 756a609..91265bf 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h@@ -294,6 +294,7 @@ struct tty_driver { struct module *owner; const char *driver_name; const char *name; + char *(*devnode)(struct device *dev, umode_t *mode); int name_base; /* offset of printed name */ int major; /* major device number */ int minor_start; /* start of minor device number */
--
1.9.2.459.g68773ac