From: Jiri Slaby <jslaby@suse.cz>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: linux-kernel@vger.kernel.org, Kay Sievers <kay.sievers@vrfy.org>
Subject: Re: [PATCH 34/36] tty: add 'active' sysfs attribute to tty0 and console device
Date: Fri, 07 Jan 2011 10:09:58 +0100 [thread overview]
Message-ID: <4D26D866.40906@suse.cz> (raw)
In-Reply-To: <1294352605-31906-34-git-send-email-gregkh@suse.de>
On 01/06/2011 11:23 PM, Greg Kroah-Hartman wrote:
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -3232,9 +3232,45 @@ static int __init tty_class_init(void)
> postcore_initcall(tty_class_init);
>
> /* 3/2004 jmc: why do these devices exist? */
> -
> static struct cdev tty_cdev, console_cdev;
>
> +static ssize_t show_cons_active(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct console *cs[16];
> + int i = 0;
> + struct console *c;
> + ssize_t count = 0;
> +
> + acquire_console_sem();
> + for (c = console_drivers; c; c = c->next) {
This should be:
for_each_console(c)
like somebody already suggested.
> + if (!c->device)
> + continue;
Why are consoles without devices ignored here?
Other than that there are 2 build warnings, see below.
> + if (!c->write)
> + continue;
> + if ((c->flags & CON_ENABLED) == 0)
> + continue;
> + cs[i++] = c;
> + if (i >= ARRAY_SIZE(cs))
> + break;
> + }
> + while (i--)
> + count += sprintf(buf + count, "%s%d%c",
> + cs[i]->name, cs[i]->index, i ? ' ':'\n');
> + release_console_sem();
> +
> + return count;
> +}
> +static DEVICE_ATTR(active, S_IRUGO, show_cons_active, NULL);
> +
> +static struct device *consdev;
> +
> +void console_sysfs_notify(void)
> +{
> + if (consdev)
> + sysfs_notify(&consdev->kobj, NULL, "active");
> +}
> +
> /*
> * Ok, now we can initialize the rest of the tty devices and can count
> * on memory allocations, interrupts etc..
> @@ -3245,15 +3281,18 @@ int __init tty_init(void)
> if (cdev_add(&tty_cdev, MKDEV(TTYAUX_MAJOR, 0), 1) ||
> register_chrdev_region(MKDEV(TTYAUX_MAJOR, 0), 1, "/dev/tty") < 0)
> panic("Couldn't register /dev/tty driver\n");
> - device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL,
> - "tty");
> + device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 0), NULL, "tty");
>
> cdev_init(&console_cdev, &console_fops);
> if (cdev_add(&console_cdev, MKDEV(TTYAUX_MAJOR, 1), 1) ||
> register_chrdev_region(MKDEV(TTYAUX_MAJOR, 1), 1, "/dev/console") < 0)
> panic("Couldn't register /dev/console driver\n");
> - device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL,
> + consdev = device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 1), NULL,
> "console");
> + if (IS_ERR(consdev))
> + consdev = NULL;
> + else
> + device_create_file(consdev, &dev_attr_active);
drivers/tty/tty_io.c: In function ‘tty_init’:
drivers/tty/tty_io.c:3309:21: warning: ignoring return value of
‘device_create_file’, declared with attribute warn_unused_result
> @@ -2967,13 +2977,24 @@ static const struct tty_operations con_ops = {
>
> static struct cdev vc0_cdev;
>
> +static ssize_t show_tty_active(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + return sprintf(buf, "tty%d\n", fg_console + 1);
> +}
> +static DEVICE_ATTR(active, S_IRUGO, show_tty_active, NULL);
> +
> int __init vty_init(const struct file_operations *console_fops)
> {
> cdev_init(&vc0_cdev, console_fops);
> if (cdev_add(&vc0_cdev, MKDEV(TTY_MAJOR, 0), 1) ||
> register_chrdev_region(MKDEV(TTY_MAJOR, 0), 1, "/dev/vc/0") < 0)
> panic("Couldn't register /dev/tty0 driver\n");
> - device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
> + tty0dev = device_create(tty_class, NULL, MKDEV(TTY_MAJOR, 0), NULL, "tty0");
> + if (IS_ERR(tty0dev))
> + tty0dev = NULL;
> + else
> + device_create_file(tty0dev, &dev_attr_active);
drivers/tty/vt/vt.c: In function ‘vty_init’:
drivers/tty/vt/vt.c:2997:21: warning: ignoring return value of
‘device_create_file’, declared with attribute warn_unused_result
>
> vcs_init();
>
regards,
--
js
suse labs
next prev parent reply other threads:[~2011-01-07 9:10 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-06 21:54 [GIT PATCH] TTY/serial merge for .38 Greg KH
2011-01-06 22:00 ` Alan Cox
2011-01-06 22:24 ` Greg KH
2011-01-06 23:54 ` Kay Sievers
2011-01-07 3:40 ` Greg KH
2011-01-06 22:22 ` [PATCH 01/36] ifx6x60: SPI protocol driver for Infineon 6x60 modem Greg Kroah-Hartman
2011-01-06 22:22 ` [PATCH 02/36] serial: Add support for UART on VIA VT8500 and compatibles Greg Kroah-Hartman
2011-01-06 22:22 ` [PATCH 03/36] n_gsm: Fix support for legacy encoding Greg Kroah-Hartman
2011-01-06 22:22 ` [PATCH 04/36] n_gsm: clean up printks Greg Kroah-Hartman
2011-01-06 22:22 ` [PATCH 05/36] serial: add Documentation about RS485 serial communications Greg Kroah-Hartman
2011-01-06 22:22 ` [PATCH 06/36] serial: cpm_uat: reducing CPM serial latency Greg Kroah-Hartman
2011-01-06 22:22 ` [PATCH 07/36] serial: cpu_uart: Remove unused uart_cpm_port fields Greg Kroah-Hartman
2011-01-06 22:22 ` [PATCH 08/36] console: move for_each_console to linux/console.h Greg Kroah-Hartman
2011-01-06 22:22 ` [PATCH 09/36] TTY: include termios.h in tty_driver.h Greg Kroah-Hartman
2011-01-06 22:22 ` [PATCH 10/36] VIDEO: xen-fb, switch to for_each_console Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 11/36] console: add /proc/consoles Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 12/36] parisc: cleanup console handling Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 13/36] serial: mpc52xx: make printout for type more generic Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 14/36] serial: ifx6x60: The IFX requires SPI Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 15/36] serial: ifx6x60: Fix missing include for msleep Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 16/36] Serial: ce4100: Add PCI UART support for the ce4100 Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 17/36] Serial: EG20T: add PCH_UART driver Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 18/36] serial: ifx6x60: free IRQ on error Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 19/36] serial: ifx6x60: fix memory leak Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 20/36] RS485 documentation: add 16C950 UART description Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 21/36] drivers: char: hvc: add arm JTAG DCC console support Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 22/36] serial: fix pch_uart kconfig & build Greg Kroah-Hartman
2011-01-07 0:21 ` Tomoya MORINAGA
2011-01-07 0:31 ` Greg KH
2011-01-06 22:23 ` [PATCH 23/36] serial: omap-serial: Add support for kernel debugger Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 24/36] 8250: use container_of() instead of casting Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 25/36] 8250: add a UPIO_DWAPB32 for 32 bit accesses Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 26/36] rocket: fix compiler warning on rocket_pci_ids Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 27/36] specialix: fix compiler warning on specialix_pci_tbl Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 28/36] ip2: fix compiler warning on ip2main_pci_tbl Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 29/36] 8250: fix uninitialized FIFOs Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 30/36] pch_uart : fix warnings for 64bit compile Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 31/36] tty: fix typos/errors in tty_driver.h comments Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 32/36] Serial: Avoid unbalanced IRQ wake disable during resume Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 33/36] drivers: serial: apbuart: Handle OF failures gracefully Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 34/36] tty: add 'active' sysfs attribute to tty0 and console device Greg Kroah-Hartman
2011-01-07 9:09 ` Jiri Slaby [this message]
2011-01-07 13:20 ` Kay Sievers
2011-01-07 15:12 ` Jiri Slaby
2011-01-06 22:23 ` [PATCH 35/36] TTY: Add tty ioctl to figure device node of the system console Greg Kroah-Hartman
2011-01-06 22:23 ` [PATCH 36/36] serial: apbuart: Fixup apbuart_console_init() Greg Kroah-Hartman
2011-01-07 22:44 ` [GIT PATCH] TTY/serial merge for .38 Linus Torvalds
2011-01-07 23:41 ` Greg KH
2011-01-11 14:00 ` Daniel Hellstrom
2011-01-11 14:56 ` Thomas Gleixner
2011-01-11 15:08 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D26D866.40906@suse.cz \
--to=jslaby@suse.cz \
--cc=gregkh@suse.de \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox