From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Cc: kay.sievers@vrfy.org
Subject: [PATCH] Driver core: add "bus" symlink to class/block devices
Date: Wed, 9 Mar 2005 16:34:44 -0800 [thread overview]
Message-ID: <1110414884411@kroah.com> (raw)
In-Reply-To: <11104148843411@kroah.com>
ChangeSet 1.2046, 2005/03/09 09:52:48-08:00, kay.sievers@vrfy.org
[PATCH] Driver core: add "bus" symlink to class/block devices
On Tue, Feb 15, 2005 at 09:53:44PM +0100, Kay Sievers wrote:
> Add a "bus" symlink to the class and block devices, just like the "driver"
> and "device" links. This may be a huge speed gain for e.g. udev to determine
> the bus value of a device, as we currently need to do a brute-force scan in
> /sys/bus/* to find this value.
Hmm, while playing around with it, I think we should create the "bus"
link on the physical device on not on the class device.
Also the current "driver" link at the class device should be removed,
cause class devices don't have a driver. Block devices never had this
misleading symlink.
From the class device we point with the "device" link to the physical
device, and only the physical device should have the "driver" and the
"bus" link, as it represents the real relationship.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/bus.c | 2 ++
drivers/base/class.c | 36 +++++-------------------------------
2 files changed, 7 insertions(+), 31 deletions(-)
diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c 2005-03-09 16:29:06 -08:00
+++ b/drivers/base/bus.c 2005-03-09 16:29:06 -08:00
@@ -465,6 +465,7 @@
up_write(&dev->bus->subsys.rwsem);
device_add_attrs(bus, dev);
sysfs_create_link(&bus->devices.kobj, &dev->kobj, dev->bus_id);
+ sysfs_create_link(&dev->kobj, &dev->bus->subsys.kset.kobj, "bus");
}
return error;
}
@@ -481,6 +482,7 @@
void bus_remove_device(struct device * dev)
{
if (dev->bus) {
+ sysfs_remove_link(&dev->kobj, "bus");
sysfs_remove_link(&dev->bus->devices.kobj, dev->bus_id);
device_remove_attrs(dev->bus, dev);
down_write(&dev->bus->subsys.rwsem);
diff -Nru a/drivers/base/class.c b/drivers/base/class.c
--- a/drivers/base/class.c 2005-03-09 16:29:06 -08:00
+++ b/drivers/base/class.c 2005-03-09 16:29:06 -08:00
@@ -196,33 +196,6 @@
sysfs_remove_bin_file(&class_dev->kobj, attr);
}
-static int class_device_dev_link(struct class_device * class_dev)
-{
- if (class_dev->dev)
- return sysfs_create_link(&class_dev->kobj,
- &class_dev->dev->kobj, "device");
- return 0;
-}
-
-static void class_device_dev_unlink(struct class_device * class_dev)
-{
- sysfs_remove_link(&class_dev->kobj, "device");
-}
-
-static int class_device_driver_link(struct class_device * class_dev)
-{
- if ((class_dev->dev) && (class_dev->dev->driver))
- return sysfs_create_link(&class_dev->kobj,
- &class_dev->dev->driver->kobj, "driver");
- return 0;
-}
-
-static void class_device_driver_unlink(struct class_device * class_dev)
-{
- sysfs_remove_link(&class_dev->kobj, "driver");
-}
-
-
static ssize_t
class_device_attr_show(struct kobject * kobj, struct attribute * attr,
char * buf)
@@ -452,8 +425,9 @@
class_device_create_file(class_dev, &class_device_attr_dev);
class_device_add_attrs(class_dev);
- class_device_dev_link(class_dev);
- class_device_driver_link(class_dev);
+ if (class_dev->dev)
+ sysfs_create_link(&class_dev->kobj,
+ &class_dev->dev->kobj, "device");
register_done:
if (error && parent)
@@ -482,8 +456,8 @@
up_write(&parent->subsys.rwsem);
}
- class_device_dev_unlink(class_dev);
- class_device_driver_unlink(class_dev);
+ if (class_dev->dev)
+ sysfs_remove_link(&class_dev->kobj, "device");
class_device_remove_attrs(class_dev);
kobject_del(&class_dev->kobj);
next prev parent reply other threads:[~2005-03-10 2:40 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-10 0:34 [BK PATCH] Driver core and kobject updates for 2.6.11 Greg KH
2005-03-10 0:34 ` [PATCH] Kobject: remove some unneeded exports Greg KH
2005-03-10 0:34 ` [PATCH] Add 2.4.x cpufreq /proc and sysctl interface removal feature-removal-schedule Greg KH
2005-03-10 0:34 ` [PATCH] cpufreq 2.4 interface removal schedule Greg KH
2005-03-10 0:34 ` [PATCH] driver core: Separate platform device name from platform device number Greg KH
2005-03-10 0:34 ` [PATCH] class core: export MAJOR/MINOR to the hotplug env Greg KH
2005-03-10 0:34 ` [PATCH] block " Greg KH
2005-03-10 0:34 ` [PATCH] class_simple: pass dev_t to the class core Greg KH
2005-03-10 0:34 ` [PATCH] usb: class driver " Greg KH
2005-03-10 0:34 ` [PATCH] i2c: " Greg KH
2005-03-10 0:34 ` [PATCH] videodev: " Greg KH
2005-03-10 0:34 ` [PATCH] driver core: clean driver unload Greg KH
2005-03-10 0:34 ` Greg KH [this message]
2005-03-10 0:34 ` [PATCH] floppy.c: pass physical device to device registration Greg KH
2005-03-10 0:34 ` [PATCH] kset: make ksets have a spinlock, and use that to lock their lists Greg KH
2005-03-10 0:34 ` [PATCH] sysdev: make system_subsys static as no one else needs access to it Greg KH
2005-03-10 0:34 ` [PATCH] kref: make kref_put return if this was the last put call Greg KH
2005-03-10 0:34 ` [PATCH] USB: move usb core to use class_simple instead of it's own class functions Greg KH
2005-03-10 0:34 ` [PATCH] kmap: remove usage of rwsem from kobj_map Greg KH
2005-03-10 0:34 ` [PATCH] sysdev: fix the name of the list of drivers to be a sane name Greg KH
2005-03-10 0:34 ` [PATCH] sysdev: remove the rwsem usage from this subsystem Greg KH
2005-03-10 0:34 ` [PATCH] class: add a semaphore to struct class, and use that instead of the subsystem rwsem Greg KH
2005-03-25 18:01 ` [PATCH] driver core: Separate platform device name from platform device number Paul Mundt
2005-03-25 18:10 ` Greg KH
2005-03-25 18:35 ` Paul Mundt
2005-03-25 19:38 ` Kyle Moffett
2005-03-25 19:58 ` Paul Mundt
2005-03-25 20:17 ` Kyle Moffett
2005-03-25 20:25 ` Russell King
2005-03-25 20:56 ` Paul Mundt
2005-03-25 21:03 ` Russell King
2005-03-25 22:15 ` Paul Mundt
2005-03-10 2:23 ` [PATCH] Add 2.4.x cpufreq /proc and sysctl interface removal feature-removal-schedule Dave Jones
2005-03-10 4:56 ` Dominik Brodowski
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=1110414884411@kroah.com \
--to=greg@kroah.com \
--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