<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">ChangeSet 1.2098, 2004/11/12 11:43:27-08:00, kay.sievers@vrfy.org

[PATCH] add the bus name to the hotplug environment

Add the name of the bus and the driver to the hotplug event for
/sys/devices/*. With this addition, userspace knows what it can
expect from sysfs to show up, instead of waiting for a timeout
for devices without a bus.

  ACTION=add
  DEVPATH=/devices/pci0000:00/0000:00:1d.1/usb3/3-1
  SUBSYSTEM=usb
  SEQNUM=978
  PHYSDEVBUS=usb
  PHYSDEVDRIVER=usb

Signed-off-by: Kay Sievers &lt;kay.sievers@vrfy.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;greg@kroah.com&gt;


 drivers/base/bus.c  |    2 +-
 drivers/base/core.c |   21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)


diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
--- a/drivers/base/bus.c	2004-11-12 14:53:04 -08:00
+++ b/drivers/base/bus.c	2004-11-12 14:53:04 -08:00
@@ -247,7 +247,7 @@
  *	device_bind_driver - bind a driver to one device.
  *	@dev:	device.
  *
- *	Allow manual attachment of a driver to a deivce.
+ *	Allow manual attachment of a driver to a device.
  *	Caller must have already set @dev-&gt;driver.
  *
  *	Note that this does not modify the bus reference count
diff -Nru a/drivers/base/core.c b/drivers/base/core.c
--- a/drivers/base/core.c	2004-11-12 14:53:04 -08:00
+++ b/drivers/base/core.c	2004-11-12 14:53:04 -08:00
@@ -116,7 +116,28 @@
 			int num_envp, char *buffer, int buffer_size)
 {
 	struct device *dev = to_dev(kobj);
+	int i = 0;
+	int length = 0;
 	int retval = 0;
+
+	/* add bus name of physical device */
+	if (dev-&gt;bus)
+		add_hotplug_env_var(envp, num_envp, &amp;i,
+				    buffer, buffer_size, &amp;length,
+				    "PHYSDEVBUS=%s", dev-&gt;bus-&gt;name);
+
+	/* add driver name of physical device */
+	if (dev-&gt;driver)
+		add_hotplug_env_var(envp, num_envp, &amp;i,
+				    buffer, buffer_size, &amp;length,
+				    "PHYSDEVDRIVER=%s", dev-&gt;driver-&gt;name);
+
+	/* terminate, set to next free slot, shrink available space */
+	envp[i] = NULL;
+	envp = &amp;envp[i];
+	num_envp -= i;
+	buffer = &amp;buffer[length];
+	buffer_size -= length;
 
 	if (dev-&gt;bus-&gt;hotplug) {
 		/* have the bus specific function add its stuff */
</pre></body></html>