mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	TTY: pdc_cons, use tty_port
Instead of digging a tty out of the tty_driver struct, which is not defined to work, use tty_port properly. This includes proper tty refcounting even though there is no possible race currently. But we will need tty_port for tty buffers in the future anyway. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Kyle McMartin <kyle@mcmartin.ca> Cc: Helge Deller <deller@gmx.de> Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
		
							parent
							
								
									0b479d54ae
								
							
						
					
					
						commit
						5dd5bc40f3
					
				
					 1 changed files with 12 additions and 7 deletions
				
			
		| 
						 | 
					@ -92,10 +92,11 @@ static int pdc_console_setup(struct console *co, char *options)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void pdc_console_poll(unsigned long unused);
 | 
					static void pdc_console_poll(unsigned long unused);
 | 
				
			||||||
static DEFINE_TIMER(pdc_console_timer, pdc_console_poll, 0, 0);
 | 
					static DEFINE_TIMER(pdc_console_timer, pdc_console_poll, 0, 0);
 | 
				
			||||||
 | 
					static struct tty_port tty_port;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
 | 
					static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						tty_port_tty_set(&tty_port, tty);
 | 
				
			||||||
	mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
 | 
						mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					@ -103,8 +104,10 @@ static int pdc_console_tty_open(struct tty_struct *tty, struct file *filp)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp)
 | 
					static void pdc_console_tty_close(struct tty_struct *tty, struct file *filp)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (!tty->count)
 | 
						if (!tty->count) {
 | 
				
			||||||
		del_timer_sync(&pdc_console_timer);
 | 
							del_timer_sync(&pdc_console_timer);
 | 
				
			||||||
 | 
							tty_port_tty_set(&tty_port, NULL);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int pdc_console_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
 | 
					static int pdc_console_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
 | 
				
			||||||
| 
						 | 
					@ -123,8 +126,6 @@ static int pdc_console_tty_chars_in_buffer(struct tty_struct *tty)
 | 
				
			||||||
	return 0; /* no buffer */
 | 
						return 0; /* no buffer */
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct tty_driver *pdc_console_tty_driver;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static const struct tty_operations pdc_console_tty_ops = {
 | 
					static const struct tty_operations pdc_console_tty_ops = {
 | 
				
			||||||
	.open = pdc_console_tty_open,
 | 
						.open = pdc_console_tty_open,
 | 
				
			||||||
	.close = pdc_console_tty_close,
 | 
						.close = pdc_console_tty_close,
 | 
				
			||||||
| 
						 | 
					@ -135,10 +136,8 @@ static const struct tty_operations pdc_console_tty_ops = {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void pdc_console_poll(unsigned long unused)
 | 
					static void pdc_console_poll(unsigned long unused)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					 | 
				
			||||||
	int data, count = 0;
 | 
						int data, count = 0;
 | 
				
			||||||
 | 
						struct tty_struct *tty = tty_port_tty_get(&tty_port);
 | 
				
			||||||
	struct tty_struct *tty = pdc_console_tty_driver->ttys[0];
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!tty)
 | 
						if (!tty)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					@ -154,10 +153,14 @@ static void pdc_console_poll(unsigned long unused)
 | 
				
			||||||
	if (count)
 | 
						if (count)
 | 
				
			||||||
		tty_flip_buffer_push(tty);
 | 
							tty_flip_buffer_push(tty);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						tty_kref_put(tty);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (pdc_cons.flags & CON_ENABLED)
 | 
						if (pdc_cons.flags & CON_ENABLED)
 | 
				
			||||||
		mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
 | 
							mod_timer(&pdc_console_timer, jiffies + PDC_CONS_POLL_DELAY);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static struct tty_driver *pdc_console_tty_driver;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int __init pdc_console_tty_driver_init(void)
 | 
					static int __init pdc_console_tty_driver_init(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
| 
						 | 
					@ -182,6 +185,8 @@ static int __init pdc_console_tty_driver_init(void)
 | 
				
			||||||
	printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n");
 | 
						printk(KERN_INFO "The PDC console driver is still registered, removing CON_BOOT flag\n");
 | 
				
			||||||
	pdc_cons.flags &= ~CON_BOOT;
 | 
						pdc_cons.flags &= ~CON_BOOT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						tty_port_init(&tty_port);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pdc_console_tty_driver = alloc_tty_driver(1);
 | 
						pdc_console_tty_driver = alloc_tty_driver(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!pdc_console_tty_driver)
 | 
						if (!pdc_console_tty_driver)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue