diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2015-11-08 13:01:12 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-12-13 19:59:48 -0800 |
commit | 0a083eddae33b6e20234d05a9cf54f87b0095511 (patch) | |
tree | eb2487f1492031b4947f3e38f7a768524911d0d6 /drivers/tty | |
parent | 25080652a2d4a6d27a51fc1412e258f467174615 (diff) |
tty: core: Add helper fn to deref tty driver name
Similar to tty_name(), add tty_driver_name() helper to safely
dereference tty->driver->name (otherwise return empty string).
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/tty_io.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 336714cf370a..ef8ee34670c3 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -256,6 +256,13 @@ const char *tty_name(const struct tty_struct *tty) EXPORT_SYMBOL(tty_name); +const char *tty_driver_name(const struct tty_struct *tty) +{ + if (!tty || !tty->driver) + return ""; + return tty->driver->name; +} + static int tty_paranoia_check(struct tty_struct *tty, struct inode *inode, const char *routine) { |