* put "device" symlink into hotplug environment?
@ 2004-11-03 23:39 Kay Sievers
2004-11-04 0:12 ` Kay Sievers
0 siblings, 1 reply; 2+ messages in thread
From: Kay Sievers @ 2004-11-03 23:39 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 791 bytes --]
Hi Greg,
what if we put the sysfs path of the physical device into the hotplug
environment? All virtual devices will not have the key. This would solve
all the wait for the "device" link issues and we can throw away one of
the exception lists as the kernel will tell us if it is going to create
a symlink.
I get hotplug events like this now:
physical backed device:
ACTION=add
SUBSYSTEM=net
DEVPATH=/class/net/eth0
DEVSYSDEV=/devices/pci0000:00/0000:00:1e.0/0000:02:01.0
INTERFACE=eth0
SEQNUM=966
PATH=/sbin:/bin:/usr/sbin:/usr/bin
HOME=/
virtual:
ACTION=add
SUBSYSTEM=net
DEVPATH=/class/net/dummy0
INTERFACE=dummy0
SEQNUM=977
PATH=/sbin:/bin:/usr/sbin:/usr/bin
HOME=/
The current patch is only for class-devices block-devices are not covered.
Thanks,
Kay
[-- Attachment #2: kernel-DEVSYSDEV-01.patch --]
[-- Type: text/plain, Size: 1021 bytes --]
===== drivers/base/class.c 1.54 vs edited =====
--- 1.54/drivers/base/class.c 2004-10-08 20:32:52 +02:00
+++ edited/drivers/base/class.c 2004-11-04 00:23:56 +01:00
@@ -283,8 +283,27 @@ static int class_hotplug(struct kset *ks
{
struct class_device *class_dev = to_class_dev(kobj);
int retval = 0;
+ int i = 0;
+ int length = 0;
pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id);
+
+ if (class_dev->dev) {
+ /* add physical device backing this class to environment */
+ char *dev = kobject_get_path(&class_dev->dev->kobj, GFP_KERNEL);
+
+ add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
+ &length, "DEVSYSDEV=%s", dev);
+ kfree(dev);
+
+ /* terminate, set to next free slot, shrink available space */
+ envp[i] = NULL;
+ envp = &envp[i];
+ num_envp -= i;
+ buffer = &buffer[length];
+ buffer_size -= length;
+ }
+
if (class_dev->class->hotplug) {
/* have the bus specific function add its stuff */
retval = class_dev->class->hotplug (class_dev, envp, num_envp,
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: put "device" symlink into hotplug environment?
2004-11-03 23:39 put "device" symlink into hotplug environment? Kay Sievers
@ 2004-11-04 0:12 ` Kay Sievers
0 siblings, 0 replies; 2+ messages in thread
From: Kay Sievers @ 2004-11-04 0:12 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 1558 bytes --]
On Thu, Nov 04, 2004 at 12:39:59AM +0100, Kay Sievers wrote:
> Hi Greg,
> what if we put the sysfs path of the physical device into the hotplug
> environment? All virtual devices will not have the key. This would solve
> all the wait for the "device" link issues and we can throw away one of
> the exception lists as the kernel will tell us if it is going to create
> a symlink.
>
> I get hotplug events like this now:
>
> physical backed device:
> ACTION=add
> SUBSYSTEM=net
> DEVPATH=/class/net/eth0
> DEVSYSDEV=/devices/pci0000:00/0000:00:1e.0/0000:02:01.0
> INTERFACE=eth0
> SEQNUM=966
> PATH=/sbin:/bin:/usr/sbin:/usr/bin
> HOME=/
>
> virtual:
> ACTION=add
> SUBSYSTEM=net
> DEVPATH=/class/net/dummy0
> INTERFACE=dummy0
> SEQNUM=977
> PATH=/sbin:/bin:/usr/sbin:/usr/bin
> HOME=/
We can also pass the BUS together with the class device. The search
for the BUS value is an expensive tasks in udev, cause we need to
reverse lookup the whole /sys/bus directory to find the symlink to our
physical device.
This is my pci network card again:
ACTION=add
SUBSYSTEM=net
DEVPATH=/class/net/eth0
DEVPHYSDEV=/devices/pci0000:00/0000:00:1e.0/0000:02:01.0
DEVBUS=pci
INTERFACE=eth0
SEQNUM=827
PATH=/sbin:/bin:/usr/sbin:/usr/bin
HOME=/
And an USB-mouse:
ACTION=add
SUBSYSTEM=input
DEVPATH=/class/input/mouse2
DEVPHYSDEV=/devices/pci0000:00/0000:00:1d.1/usb3/3-2/3-2:1.0
DEVBUS=usb
SEQNUM=1001
PATH=/sbin:/bin:/usr/sbin:/usr/bin
HOME=/
Hmm, another exception list in wait_for_sysfs killed. :)
Kay
[-- Attachment #2: kernel-DEVSYSDEV-02.patch --]
[-- Type: text/plain, Size: 1197 bytes --]
===== drivers/base/class.c 1.54 vs edited =====
--- 1.54/drivers/base/class.c 2004-10-08 20:32:52 +02:00
+++ edited/drivers/base/class.c 2004-11-04 00:54:26 +01:00
@@ -283,8 +283,33 @@ static int class_hotplug(struct kset *ks
{
struct class_device *class_dev = to_class_dev(kobj);
int retval = 0;
+ int i = 0;
+ int length = 0;
pr_debug("%s - name = %s\n", __FUNCTION__, class_dev->class_id);
+
+ if (class_dev->dev) {
+ /* add physical device backing this class to environment */
+ struct device *dev = class_dev->dev;
+ char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);
+
+ add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
+ &length, "DEVPHYSDEV=%s", path);
+ kfree(path);
+
+ if (dev->bus)
+ add_hotplug_env_var(envp, num_envp, &i,
+ buffer, buffer_size, &length,
+ "DEVBUS=%s", dev->bus->name);
+
+ /* terminate, set to next free slot, shrink available space */
+ envp[i] = NULL;
+ envp = &envp[i];
+ num_envp -= i;
+ buffer = &buffer[length];
+ buffer_size -= length;
+ }
+
if (class_dev->class->hotplug) {
/* have the bus specific function add its stuff */
retval = class_dev->class->hotplug (class_dev, envp, num_envp,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-11-04 0:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-03 23:39 put "device" symlink into hotplug environment? Kay Sievers
2004-11-04 0:12 ` Kay Sievers
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).