From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Driver Core update for 2.6.4
Date: Mon, 15 Mar 2004 15:59:09 -0800 [thread overview]
Message-ID: <10793951492163@kroah.com> (raw)
In-Reply-To: <1079395148429@kroah.com>
ChangeSet 1.1608.84.12, 2004/03/12 15:20:28-08:00, corbet@lwn.net
[PATCH] cdev 1/2: Eliminate /sys/cdev
This is the first of two patches designed to make life easier for authors
of device driver books - and, with luck, driver authors too.
/sys/cdev is, according to Al, a mistake which was never really meant to
exist. I believe nothing uses it currently - there isn't a whole lot there
to use. Its existence takes up system resources, and also requires drivers
to deal with the cdev's embedded kobject in their failure paths. The
following patch (against 2.6.4) makes it all go away.
OK, almost all. We have to keep (but not register) cdev_subsys because
it's rwsem is needed to control access to cdev_map.
drivers/char/tty_io.c | 10 +++-------
fs/char_dev.c | 26 ++++++++------------------
2 files changed, 11 insertions(+), 25 deletions(-)
diff -Nru a/drivers/char/tty_io.c b/drivers/char/tty_io.c
--- a/drivers/char/tty_io.c Mon Mar 15 15:28:42 2004
+++ b/drivers/char/tty_io.c Mon Mar 15 15:28:42 2004
@@ -2175,8 +2175,6 @@
EXPORT_SYMBOL(tty_register_device);
EXPORT_SYMBOL(tty_unregister_device);
-static struct kobject tty_kobj = {.name = "tty"};
-
struct tty_driver *alloc_tty_driver(int lines)
{
struct tty_driver *driver;
@@ -2276,7 +2274,6 @@
driver->termios_locked = NULL;
}
- driver->cdev.kobj.parent = &tty_kobj;
strcpy(driver->cdev.kobj.name, driver->name);
for (s = strchr(driver->cdev.kobj.name, '/'); s; s = strchr(s, '/'))
*s = '!';
@@ -2400,7 +2397,9 @@
}
postcore_initcall(tty_class_init);
-
+
+/* 3/2004 jmc: why do these devices exist? */
+
static struct cdev tty_cdev, console_cdev;
#ifdef CONFIG_UNIX98_PTYS
static struct cdev ptmx_cdev;
@@ -2430,9 +2429,6 @@
panic("Couldn't register /dev/console driver\n");
devfs_mk_cdev(MKDEV(TTYAUX_MAJOR, 1), S_IFCHR|S_IRUSR|S_IWUSR, "console");
class_simple_device_add(tty_class, MKDEV(TTYAUX_MAJOR, 1), NULL, "console");
-
- tty_kobj.kset = tty_cdev.kobj.kset;
- kobject_register(&tty_kobj);
#ifdef CONFIG_UNIX98_PTYS
strcpy(ptmx_cdev.kobj.name, "dev.ptmx");
diff -Nru a/fs/char_dev.c b/fs/char_dev.c
--- a/fs/char_dev.c Mon Mar 15 15:28:42 2004
+++ b/fs/char_dev.c Mon Mar 15 15:28:42 2004
@@ -340,15 +340,9 @@
int cdev_add(struct cdev *p, dev_t dev, unsigned count)
{
- int err = kobject_add(&p->kobj);
- if (err)
- return err;
- err = kobj_map(cdev_map, dev, count, NULL, exact_match, exact_lock, p);
- if (err)
- kobject_del(&p->kobj);
p->dev = dev;
p->count = count;
- return err;
+ return kobj_map(cdev_map, dev, count, NULL, exact_match, exact_lock, p);
}
static void cdev_unmap(dev_t dev, unsigned count)
@@ -359,7 +353,6 @@
void cdev_del(struct cdev *p)
{
cdev_unmap(p->dev, p->count);
- kobject_del(&p->kobj);
kobject_put(&p->kobj);
}
@@ -407,18 +400,12 @@
.release = cdev_dynamic_release,
};
-static struct kset kset_dynamic = {
- .subsys = &cdev_subsys,
- .kobj = {.name = "major",},
- .ktype = &ktype_cdev_dynamic,
-};
-
struct cdev *cdev_alloc(void)
{
struct cdev *p = kmalloc(sizeof(struct cdev), GFP_KERNEL);
if (p) {
memset(p, 0, sizeof(struct cdev));
- p->kobj.kset = &kset_dynamic;
+ p->kobj.ktype = &ktype_cdev_dynamic;
INIT_LIST_HEAD(&p->list);
kobject_init(&p->kobj);
}
@@ -428,7 +415,6 @@
void cdev_init(struct cdev *cdev, struct file_operations *fops)
{
INIT_LIST_HEAD(&cdev->list);
- kobj_set_kset_s(cdev, cdev_subsys);
cdev->kobj.ktype = &ktype_cdev_default;
kobject_init(&cdev->kobj);
cdev->ops = fops;
@@ -444,8 +430,12 @@
void __init chrdev_init(void)
{
- subsystem_register(&cdev_subsys);
- kset_register(&kset_dynamic);
+/*
+ * Keep cdev_subsys around because (and only because) the kobj_map code
+ * depends on the rwsem it contains. We don't make it public in sysfs,
+ * however.
+ */
+ subsystem_init(&cdev_subsys);
cdev_map = kobj_map_init(base_probe, &cdev_subsys);
}
next prev parent reply other threads:[~2004-03-16 1:14 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-15 23:55 [BK PATCH] Driver Core update for 2.6.4 Greg KH
2004-03-15 23:59 ` [PATCH] " Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH [this message]
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-15 23:59 ` Greg KH
2004-03-16 7:04 ` Christoph Hellwig
2004-03-16 9:51 ` Andrew Morton
[not found] <1AajM-5vw-21@gated-at.bofh.it>
[not found] ` <1Abpq-6Av-1@gated-at.bofh.it>
[not found] ` <1Aj3K-5Fn-9@gated-at.bofh.it>
[not found] ` <1AjwZ-65D-15@gated-at.bofh.it>
2004-03-16 16:14 ` Andi Kleen
2004-03-16 19:40 ` Greg KH
2004-03-17 0:01 ` Andi Kleen
2004-03-19 9:17 ` Jamie Lokier
2004-03-19 11:52 ` Giuseppe Bilotta
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=10793951492163@kroah.com \
--to=greg@kroah.com \
--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