From: Greg KH <greg@kroah.com>
To: Andreas Jellinghaus <aj@dungeon.inka.de>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] sysfs support for vcs devices (was Re: State of devfs in 2.6?)
Date: Mon, 8 Dec 2003 16:51:36 -0800 [thread overview]
Message-ID: <20031209005136.GA31863@kroah.com> (raw)
In-Reply-To: <20031208233428.GA31370@kroah.com>
On Mon, Dec 08, 2003 at 03:34:28PM -0800, Greg KH wrote:
> On Tue, Dec 09, 2003 at 12:04:08AM +0100, Andreas Jellinghaus wrote:
> > - 18 vcc/ devices
>
> Hm, good catch. I wonder why these aren't getting picked up in
> /sys/class/tty as they are tty devices. I thought they used to be
> there...
Ah, they really aren't tty devices, they are char devices. That's why
they never have showed up.
Anyway, here's a patch against 2.6.0-test11 that adds sysfs support for
all of the vcs devices. Now udev has support for them :)
thanks for pointing these out,
greg k-h
# add /sys/class/vc support for the vcs devices.
diff -Nru a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
--- a/drivers/char/vc_screen.c Mon Dec 8 16:49:54 2003
+++ b/drivers/char/vc_screen.c Mon Dec 8 16:49:54 2003
@@ -36,6 +36,7 @@
#include <linux/kbd_kern.h>
#include <linux/console.h>
#include <linux/smp_lock.h>
+#include <linux/device.h>
#include <asm/uaccess.h>
#include <asm/byteorder.h>
#include <asm/unaligned.h>
@@ -469,6 +470,85 @@
.open = vcs_open,
};
+/* vc class implementation */
+
+struct vc_dev {
+ struct list_head node;
+ dev_t dev;
+ struct class_device class_dev;
+};
+#define to_vc_dev(d) container_of(d, struct vc_dev, class_dev)
+
+static LIST_HEAD(vc_dev_list);
+static spinlock_t vc_dev_list_lock = SPIN_LOCK_UNLOCKED;
+
+static void release_vc_dev(struct class_device *class_dev)
+{
+ struct vc_dev *vc_dev = to_vc_dev(class_dev);
+ kfree(vc_dev);
+}
+
+static struct class vc_class = {
+ .name = "vc",
+ .release = &release_vc_dev,
+};
+
+static ssize_t show_dev(struct class_device *class_dev, char *buf)
+{
+ struct vc_dev *vc_dev = to_vc_dev(class_dev);
+ return print_dev_t(buf, vc_dev->dev);
+}
+static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
+
+static int vc_add_class_device(dev_t dev, char *name, int minor)
+{
+ struct vc_dev *vc_dev = NULL;
+ int retval;
+
+ vc_dev = kmalloc(sizeof(*vc_dev), GFP_KERNEL);
+ if (!vc_dev)
+ return -ENOMEM;
+ memset(vc_dev, 0x00, sizeof(*vc_dev));
+
+ vc_dev->dev = dev;
+ vc_dev->class_dev.class = &vc_class;
+ snprintf(vc_dev->class_dev.class_id, BUS_ID_SIZE, name, minor);
+ retval = class_device_register(&vc_dev->class_dev);
+ if (retval)
+ goto error;
+ class_device_create_file(&vc_dev->class_dev, &class_device_attr_dev);
+ spin_lock(&vc_dev_list_lock);
+ list_add(&vc_dev->node, &vc_dev_list);
+ spin_unlock(&vc_dev_list_lock);
+ return 0;
+error:
+ kfree(vc_dev);
+ return retval;
+}
+
+static void vc_remove_class_device(int minor)
+{
+ struct vc_dev *vc_dev = NULL;
+ struct list_head *tmp;
+ int found = 0;
+
+ spin_lock(&vc_dev_list_lock);
+ list_for_each(tmp, &vc_dev_list) {
+ vc_dev = list_entry(tmp, struct vc_dev, node);
+ if (MINOR(vc_dev->dev) == minor) {
+ found = 1;
+ break;
+ }
+ }
+ if (found) {
+ list_del(&vc_dev->node);
+ spin_unlock(&vc_dev_list_lock);
+ class_device_unregister(&vc_dev->class_dev);
+ } else {
+ spin_unlock(&vc_dev_list_lock);
+ }
+}
+
void vcs_make_devfs(struct tty_struct *tty)
{
devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 1),
@@ -477,19 +557,26 @@
devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 129),
S_IFCHR|S_IRUSR|S_IWUSR,
"vcc/a%u", tty->index + 1);
+ vc_add_class_device(MKDEV(VCS_MAJOR, tty->index + 1), "vcs%u", tty->index + 1);
+ vc_add_class_device(MKDEV(VCS_MAJOR, tty->index + 129), "vcsa%u", tty->index + 1);
}
void vcs_remove_devfs(struct tty_struct *tty)
{
devfs_remove("vcc/%u", tty->index + 1);
devfs_remove("vcc/a%u", tty->index + 1);
+ vc_remove_class_device(tty->index + 1);
+ vc_remove_class_device(tty->index + 129);
}
int __init vcs_init(void)
{
if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops))
panic("unable to get major %d for vcs device", VCS_MAJOR);
+ class_register(&vc_class);
devfs_mk_cdev(MKDEV(VCS_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/0");
devfs_mk_cdev(MKDEV(VCS_MAJOR, 128), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/a0");
+ vc_add_class_device(MKDEV(VCS_MAJOR, 0), "vcs", 0);
+ vc_add_class_device(MKDEV(VCS_MAJOR, 128), "vcsa", 128);
return 0;
}
next prev parent reply other threads:[~2003-12-09 0:52 UTC|newest]
Thread overview: 101+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-08 15:36 State of devfs in 2.6? Andrew Walrond
2003-12-08 15:42 ` William Lee Irwin III
2003-12-08 15:59 ` Andrew Walrond
2003-12-08 23:38 ` Greg KH
2003-12-09 10:37 ` Andrew Walrond
2003-12-09 10:57 ` Måns Rullgård
2003-12-09 12:54 ` Paul P Komkoff Jr
2003-12-09 5:04 ` Rob Landley
2003-12-08 19:09 ` udev sysfs docs " Bob
2003-12-08 23:37 ` Greg KH
2003-12-09 5:17 ` Witukind
2003-12-09 7:21 ` Bob
2003-12-09 7:39 ` Matthew Reppert
2003-12-09 8:52 ` Måns Rullgård
2003-12-09 9:16 ` Greg KH
2003-12-09 9:45 ` Måns Rullgård
2003-12-09 9:18 ` Greg KH
2003-12-09 9:46 ` Andreas Jellinghaus
2003-12-09 10:25 ` Måns Rullgård
2003-12-09 15:28 ` Andreas Jellinghaus
2003-12-09 20:16 ` Oliver Hunt
2003-12-09 20:53 ` Måns Rullgård
2003-12-09 22:14 ` Olaf Hering
2003-12-09 22:46 ` Oliver Hunt
2003-12-09 23:03 ` Måns Rullgård
2003-12-09 7:56 ` Greg KH
2003-12-09 9:00 ` Xavier Bestel
2003-12-09 9:08 ` Greg KH
2003-12-09 9:19 ` Miles Bader
2003-12-09 9:39 ` Måns Rullgård
2003-12-09 11:01 ` Helge Hafting
2003-12-12 11:26 ` Jamie Lokier
2003-12-12 13:33 ` Duncan Sands
2003-12-12 14:51 ` Jamie Lokier
2003-12-12 16:34 ` Chuck Campbell
2003-12-12 17:13 ` Chris Friesen
2003-12-12 17:17 ` Måns Rullgård
2003-12-15 2:12 ` Miles Bader
2003-12-15 3:51 ` Mark Mielke
2003-12-15 6:09 ` Tim Connors
2003-12-10 19:23 ` Witukind
2003-12-10 19:33 ` Måns Rullgård
2003-12-10 20:22 ` Witukind
2003-12-10 20:47 ` Ed Sweetman
2003-12-10 20:53 ` Ed Sweetman
2003-12-10 21:31 ` Witukind
2003-12-10 21:28 ` Witukind
2003-12-10 21:48 ` Måns Rullgård
2003-12-11 6:31 ` Witukind
2003-12-10 21:49 ` Måns Rullgård
2003-12-10 23:48 ` Maciej Zenczykowski
2003-12-11 1:53 ` Mark Mielke
2003-12-11 8:42 ` Måns Rullgård
2003-12-11 16:33 ` Mark Mielke
2003-12-10 20:48 ` Måns Rullgård
2003-12-10 23:40 ` Maciej Zenczykowski
2003-12-09 9:55 ` Xavier Bestel
2003-12-09 13:03 ` Maciej Zenczykowski
2003-12-09 15:01 ` Helge Hafting
2003-12-09 18:30 ` Greg KH
2003-12-09 18:53 ` Måns Rullgård
2003-12-10 7:02 ` Xavier Bestel
2003-12-10 20:06 ` Witukind
2003-12-11 9:27 ` Xavier Bestel
2003-12-11 10:15 ` Måns Rullgård
2003-12-11 11:05 ` Xavier Bestel
2003-12-10 0:38 ` Greg KH
2003-12-09 9:26 ` Måns Rullgård
2003-12-09 9:41 ` Miles Bader
2003-12-10 8:13 ` Jakob Oestergaard
2003-12-10 8:24 ` Rob Landley
2003-12-08 23:04 ` Andreas Jellinghaus
2003-12-08 23:34 ` Greg KH
2003-12-09 0:31 ` Sven-Haegar Koch
2003-12-09 0:42 ` Greg KH
2003-12-09 0:51 ` Greg KH [this message]
2003-12-09 5:26 ` Rob Landley
2003-12-09 18:19 ` Greg KH
2003-12-09 18:20 ` Greg KH
2003-12-09 7:02 ` Andreas Jellinghaus
2003-12-09 7:13 ` Murray J. Root
2003-12-09 8:21 ` Holger Schurig
2003-12-09 8:52 ` Miles Bader
2003-12-09 10:08 ` Holger Schurig
2003-12-09 17:10 ` Mark Mielke
2003-12-10 5:42 ` Greg KH
2003-12-10 23:29 ` jw schultz
2003-12-11 20:32 ` [2.4.23] cursor dissapears in framebuffer console after switching back from X Witukind
2003-12-11 23:59 ` Gene Heskett
2003-12-12 6:24 ` Witukind
2003-12-09 8:32 ` State of devfs in 2.6? Greg KH
2003-12-09 9:59 ` Jan Dittmer
2003-12-09 13:54 ` Matthew Reppert
2003-12-09 16:27 ` Greg KH
2003-12-09 16:47 ` Eduard Bloch
2003-12-09 19:33 ` Greg KH
2003-12-10 2:15 ` Clemens Schwaighofer
2003-12-10 4:10 ` Bob
2003-12-09 7:33 ` Vojtech Pavlik
2003-12-09 9:48 ` Andreas Jellinghaus
2003-12-08 23:35 ` 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=20031209005136.GA31863@kroah.com \
--to=greg@kroah.com \
--cc=aj@dungeon.inka.de \
--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;
as well as URLs for NNTP newsgroup(s).