]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
tty: core: Add helper fn to deref tty driver name
authorPeter Hurley <peter@hurleysoftware.com>
Sun, 8 Nov 2015 18:01:12 +0000 (13:01 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Dec 2015 03:59:48 +0000 (19:59 -0800)
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>
drivers/tty/tty_io.c
include/linux/tty.h

index 336714cf370af239a7ec0a847c1e8026643e0431..ef8ee34670c322ba3a76c2375687fb6a5016eab8 100644 (file)
@@ -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)
 {
index 0532465ea14203c95d629ae42e79de3000291213..a9c1af990da96b98c27a2d424e44832554349568 100644 (file)
@@ -420,6 +420,7 @@ static inline struct tty_struct *tty_kref_get(struct tty_struct *tty)
 }
 
 extern const char *tty_name(const struct tty_struct *tty);
+extern const char *tty_driver_name(const struct tty_struct *tty);
 extern void tty_wait_until_sent(struct tty_struct *tty, long timeout);
 extern int __tty_check_change(struct tty_struct *tty, int sig);
 extern int tty_check_change(struct tty_struct *tty);