This applies on top of the changes already in staging-next branch which allow kernel access to TTY dev. Signe-doff-by: Okash Khawaja <okash.khawaja@xxxxxxxxx> Reviewed-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx> Index: linux-staging/drivers/tty/tty_io.c =================================================================== --- linux-staging.orig/drivers/tty/tty_io.c +++ linux-staging/drivers/tty/tty_io.c @@ -1369,7 +1369,10 @@ static struct tty_struct *tty_driver_loo struct tty_struct *tty; if (driver->ops->lookup) - tty = driver->ops->lookup(driver, file, idx); + if (!file) + tty = ERR_PTR(-EIO); + else + tty = driver->ops->lookup(driver, file, idx); else tty = driver->ttys[idx]; @@ -2001,7 +2004,7 @@ static struct tty_driver *tty_lookup_dri struct tty_driver *console_driver = console_device(index); if (console_driver) { driver = tty_driver_kref_get(console_driver); - if (driver) { + if (driver && filp) { /* Don't let /dev/console block */ filp->f_flags |= O_NONBLOCK; break; @@ -2034,7 +2037,7 @@ static struct tty_driver *tty_lookup_dri * - concurrent tty driver removal w/ lookup * - concurrent tty removal from driver table */ -static struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode, +struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode, struct file *filp) { struct tty_struct *tty; @@ -2079,6 +2082,7 @@ out: tty_driver_kref_put(driver); return tty; } +EXPORT_SYMBOL(tty_open_by_driver); /** * tty_open - open a tty device Index: linux-staging/include/linux/tty.h =================================================================== --- linux-staging.orig/include/linux/tty.h +++ linux-staging/include/linux/tty.h @@ -401,6 +401,8 @@ extern struct tty_struct *get_current_tt /* tty_io.c */ extern int __init tty_init(void); extern const char *tty_name(const struct tty_struct *tty); +extern struct tty_struct *tty_open_by_driver(dev_t device, struct inode *inode, + struct file *filp); #else static inline void console_init(void) { } _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel