[patch 1/7] tty: export tty_open_by_driver

Samuel Thibault samuel.thibault at ens-lyon.org
Sun Apr 9 17:29:43 EDT 2017


Hello,

Okash Khawaja, on lun. 03 avril 2017 21:21:24 +0100, wrote:
> This applies on top of the changes already in staging-next branch which allow
> kernel access to TTY dev.
> 
> Signed-off-by: Okash Khawaja <okash.khawaja at gmail.com>

Well, you could have kept my

Reviewed-by: Samuel Thibault <samuel.thibault at ens-lyon.org>

since there is actually no newer change :)

> 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)
>  { }
> 


More information about the Speakup mailing list