Commit f60c3b75 authored by Kay Sievers's avatar Kay Sievers Committed by Greg Kroah-Hartman

[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: default avatarKay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 489a826c
...@@ -247,7 +247,7 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start, ...@@ -247,7 +247,7 @@ int bus_for_each_drv(struct bus_type * bus, struct device_driver * start,
* device_bind_driver - bind a driver to one device. * device_bind_driver - bind a driver to one device.
* @dev: 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->driver. * Caller must have already set @dev->driver.
* *
* Note that this does not modify the bus reference count * Note that this does not modify the bus reference count
......
...@@ -116,8 +116,29 @@ static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp, ...@@ -116,8 +116,29 @@ static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
int num_envp, char *buffer, int buffer_size) int num_envp, char *buffer, int buffer_size)
{ {
struct device *dev = to_dev(kobj); struct device *dev = to_dev(kobj);
int i = 0;
int length = 0;
int retval = 0; int retval = 0;
/* add bus name of physical device */
if (dev->bus)
add_hotplug_env_var(envp, num_envp, &i,
buffer, buffer_size, &length,
"PHYSDEVBUS=%s", dev->bus->name);
/* add driver name of physical device */
if (dev->driver)
add_hotplug_env_var(envp, num_envp, &i,
buffer, buffer_size, &length,
"PHYSDEVDRIVER=%s", dev->driver->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 (dev->bus->hotplug) { if (dev->bus->hotplug) {
/* have the bus specific function add its stuff */ /* have the bus specific function add its stuff */
retval = dev->bus->hotplug (dev, envp, num_envp, buffer, buffer_size); retval = dev->bus->hotplug (dev, envp, num_envp, buffer, buffer_size);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment