aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/tty_io.c')
-rw-r--r--drivers/tty/tty_io.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index c05c5af5aa04..be5ab4ac0b93 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3232,9 +3232,45 @@ static int __init tty_class_init(void)
3232postcore_initcall(tty_class_init); 3232postcore_initcall(tty_class_init);
3233 3233
3234/* 3/2004 jmc: why do these devices exist? */ 3234/* 3/2004 jmc: why do these devices exist? */
3235
3236static struct cdev tty_cdev, console_cdev; 3235static struct cdev tty_cdev, console_cdev;
3237 3236
3237static ssize_t show_cons_active(struct device *dev,
3238 struct device_attribute *attr, char *buf)
3239{
3240 struct console *cs[16];
3241 int i = 0;
3242 struct console *c;
3243 ssize_t count = 0;
3244
3245 acquire_console_sem();
3246 for (c = console_drivers; c; c = c->next) {
3247 if (!c->device)
3248 continue;
3249 if (!c->write)
3250 continue;
3251 if ((c->flags & CON_ENABLED) == 0)
3252 continue;
3253 cs[i++] = c;
3254 if (i >= ARRAY_SIZE(cs))
3255 break;
3256 }
3257 while (i--)
3258 count += sprintf(buf + count, "%s%d%c",
3259 cs[i]->name, cs[i]->index, i ? ' ':'\n');
3260 release_console_sem();
3261
3262 return count;
3263}
3264static DEVICE_ATTR(active, S_IRUGO, show_cons_active, NULL);
3265
3266static struct device *consdev;
3267
3268void console_sysfs_notify(void)
3269{
3270 if (consdev)
3271 sysfs_notify(&consdev->kobj, NULL, "active");
3272}
3273
3238/* 3274/*
3239 * Ok, now we can initialize the rest of the tty devices and can count 3275 * Ok, now we can initialize the rest of the tty devices and can count
3240 * on memory allocations, interrupts etc.. 3276 * on memory allocations, interrupts etc..
@@ -3245,15 +3281,18 @@ int __init tty_init(void)
3245 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) || 3281 if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
3246 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0) 3282 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
3247 panic("Couldn't register /dev/tty driver\n"); 3283 panic("Couldn't register /dev/tty driver\n");
3248 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, 3284 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");
3249 "tty");
3250 3285
3251 cdev_init(&console_cdev, &console_fops); 3286 cdev_init(&console_cdev, &console_fops);
3252 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) || 3287 if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
3253 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0) 3288 register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
3254 panic("Couldn't register /dev/console driver\n"); 3289 panic("Couldn't register /dev/console driver\n");
3255 device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL, 3290 consdev = device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL,
3256 "console"); 3291 "console");
3292 if (IS_ERR(consdev))
3293 consdev = NULL;
3294 else
3295 device_create_file(consdev, &dev_attr_active);
3257 3296
3258#ifdef CONFIG_VT 3297#ifdef CONFIG_VT
3259 vty_init(&console_fops); 3298 vty_init(&console_fops);