aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_io.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-01-07 17:39:20 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-07 17:39:20 -0500
commit56b85f32d530d09d6805488ad00775d4e0e3baab (patch)
treee7fbe69e338ef775d3b2dd822aa915d259b4bc94 /drivers/tty/tty_io.c
parent3e5b08cbbf78bedd316904ab0cf3b27119433ee5 (diff)
parent568389c257fa7d74ce36c2f78bad31965fded4cf (diff)
Merge branch 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6
* 'tty-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: (36 commits) serial: apbuart: Fixup apbuart_console_init() TTY: Add tty ioctl to figure device node of the system console. tty: add 'active' sysfs attribute to tty0 and console device drivers: serial: apbuart: Handle OF failures gracefully Serial: Avoid unbalanced IRQ wake disable during resume tty: fix typos/errors in tty_driver.h comments pch_uart : fix warnings for 64bit compile 8250: fix uninitialized FIFOs ip2: fix compiler warning on ip2main_pci_tbl specialix: fix compiler warning on specialix_pci_tbl rocket: fix compiler warning on rocket_pci_ids 8250: add a UPIO_DWAPB32 for 32 bit accesses 8250: use container_of() instead of casting serial: omap-serial: Add support for kernel debugger serial: fix pch_uart kconfig & build drivers: char: hvc: add arm JTAG DCC console support RS485 documentation: add 16C950 UART description serial: ifx6x60: fix memory leak serial: ifx6x60: free IRQ on error Serial: EG20T: add PCH_UART driver ... Fixed up conflicts in drivers/serial/apbuart.c with evil merge that makes the code look fairly sane (unlike either side).
Diffstat (limited to 'drivers/tty/tty_io.c')
-rw-r--r--drivers/tty/tty_io.c52
1 files changed, 48 insertions, 4 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 35480dd57a30..464d09d97873 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2627,6 +2627,11 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2627 return put_user(tty->ldisc->ops->num, (int __user *)p); 2627 return put_user(tty->ldisc->ops->num, (int __user *)p);
2628 case TIOCSETD: 2628 case TIOCSETD:
2629 return tiocsetd(tty, p); 2629 return tiocsetd(tty, p);
2630 case TIOCGDEV:
2631 {
2632 unsigned int ret = new_encode_dev(tty_devnum(real_tty));
2633 return put_user(ret, (unsigned int __user *)p);
2634 }
2630 /* 2635 /*
2631 * Break handling 2636 * Break handling
2632 */ 2637 */
@@ -3241,9 +3246,45 @@ static int __init tty_class_init(void)
3241postcore_initcall(tty_class_init); 3246postcore_initcall(tty_class_init);
3242 3247
3243/* 3/2004 jmc: why do these devices exist? */ 3248/* 3/2004 jmc: why do these devices exist? */
3244
3245static struct cdev tty_cdev, console_cdev; 3249static struct cdev tty_cdev, console_cdev;
3246 3250
3251static ssize_t show_cons_active(struct device *dev,
3252 struct device_attribute *attr, char *buf)
3253{
3254 struct console *cs[16];
3255 int i = 0;
3256 struct console *c;
3257 ssize_t count = 0;
3258
3259 acquire_console_sem();
3260 for (c = console_drivers; c; c = c->next) {
3261 if (!c->device)
3262 continue;
3263 if (!c->write)
3264 continue;
3265 if ((c->flags & CON_ENABLED) == 0)
3266 continue;
3267 cs[i++] = c;
3268 if (i >= ARRAY_SIZE(cs))
3269 break;
3270 }
3271 while (i--)
3272 count += sprintf(buf + count, "%s%d%c",
3273 cs[i]->name, cs[i]->index, i ? ' ':'\n');
3274 release_console_sem();
3275
3276 return count;
3277}
3278static DEVICE_ATTR(active, S_IRUGO, show_cons_active, NULL);
3279
3280static struct device *consdev;
3281
3282void console_sysfs_notify(void)
3283{
3284 if (consdev)
3285 sysfs_notify(&consdev->kobj, NULL, "active");
3286}
3287
3247/* 3288/*
3248 * Ok, now we can initialize the rest of the tty devices and can count 3289 * Ok, now we can initialize the rest of the tty devices and can count
3249 * on memory allocations, interrupts etc.. 3290 * on memory allocations, interrupts etc..
@@ -3254,15 +3295,18 @@ int __init tty_init(void)
3254 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || 3295 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
3255 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) 3296 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
3256 panic("Couldn't register /dev/tty driver\n"); 3297 panic("Couldn't register /dev/tty driver\n");
3257 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, 3298 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");
3258 "tty");
3259 3299
3260 cdev_init(&console_cdev, &console_fops); 3300 cdev_init(&console_cdev, &console_fops);
3261 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || 3301 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
3262 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) 3302 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
3263 panic("Couldn't register /dev/console driver\n"); 3303 panic("Couldn't register /dev/console driver\n");
3264 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, 3304 consdev = device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL,
3265 "console"); 3305 "console");
3306 if (IS_ERR(consdev))
3307 consdev = NULL;
3308 else
3309 device_create_file(consdev, &dev_attr_active);
3266 3310
3267#ifdef CONFIG_VT 3311#ifdef CONFIG_VT
3268 vty_init(&console_fops); 3312 vty_init(&console_fops);