Skip to content

Commit

Permalink
[PATCH] driver core: replace "hotplug" by "uevent"
Browse files Browse the repository at this point in the history
Leave the overloaded "hotplug" word to susbsystems which are handling
real devices. The driver core does not "plug" anything, it just exports
the state to userspace and generates events.

Signed-off-by: Kay Sievers <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Kay Sievers authored and gregkh committed Jan 5, 2006
1 parent 5f123fb commit 312c004
Show file tree
Hide file tree
Showing 40 changed files with 372 additions and 378 deletions.
31 changes: 16 additions & 15 deletions Documentation/powerpc/eeh-pci-error-recovery.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Current PPC64 Linux EEH Implementation
At this time, a generic EEH recovery mechanism has been implemented,
so that individual device drivers do not need to be modified to support
EEH recovery. This generic mechanism piggy-backs on the PCI hotplug
infrastructure, and percolates events up through the hotplug/udev
infrastructure, and percolates events up through the userspace/udev
infrastructure. Followiing is a detailed description of how this is
accomplished.

Expand Down Expand Up @@ -172,7 +172,7 @@ A handler for the EEH notifier_block events is implemented in
drivers/pci/hotplug/pSeries_pci.c, called handle_eeh_events().
It saves the device BAR's and then calls rpaphp_unconfig_pci_adapter().
This last call causes the device driver for the card to be stopped,
which causes hotplug events to go out to user space. This triggers
which causes uevents to go out to user space. This triggers
user-space scripts that might issue commands such as "ifdown eth0"
for ethernet cards, and so on. This handler then sleeps for 5 seconds,
hoping to give the user-space scripts enough time to complete.
Expand Down Expand Up @@ -258,29 +258,30 @@ rpa_php_unconfig_pci_adapter() { // in rpaphp_pci.c
calls
pci_destroy_dev (struct pci_dev *) {
calls
device_unregister (&dev->dev) { // in /drivers/base/core.c
device_unregister (&dev->dev) { // in /drivers/base/core.c
calls
device_del(struct device * dev) { // in /drivers/base/core.c
device_del(struct device * dev) { // in /drivers/base/core.c
calls
kobject_del() { //in /libs/kobject.c
kobject_del() { //in /libs/kobject.c
calls
kobject_hotplug() { // in /libs/kobject.c
kobject_uevent() { // in /libs/kobject.c
calls
kset_hotplug() { // in /lib/kobject.c
kset_uevent() { // in /lib/kobject.c
calls
kset->hotplug_ops->hotplug() which is really just
kset->uevent_ops->uevent() // which is really just
a call to
dev_hotplug() { // in /drivers/base/core.c
dev_uevent() { // in /drivers/base/core.c
calls
dev->bus->hotplug() which is really just a call to
pci_hotplug () { // in drivers/pci/hotplug.c
dev->bus->uevent() which is really just a call to
pci_uevent () { // in drivers/pci/hotplug.c
which prints device name, etc....
}
}
then kset_hotplug() calls
call_usermodehelper () with
argv[0]=hotplug_path[] which is "/sbin/hotplug"
--> event to userspace,
then kobject_uevent() sends a netlink uevent to userspace
--> userspace uevent
(during early boot, nobody listens to netlink events and
kobject_uevent() executes uevent_helper[], which runs the
event process /sbin/hotplug)
}
}
kobject_del() then calls sysfs_remove_dir(), which would
Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/vio.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,6 @@ static int vio_hotplug(struct device *dev, char **envp, int num_envp,

struct bus_type vio_bus_type = {
.name = "vio",
.hotplug = vio_hotplug,
.uevent = vio_hotplug,
.match = vio_bus_match,
};
48 changes: 24 additions & 24 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ static struct sysfs_ops disk_sysfs_ops = {
static ssize_t disk_uevent_store(struct gendisk * disk,
const char *buf, size_t count)
{
kobject_hotplug(&disk->kobj, KOBJ_ADD);
kobject_uevent(&disk->kobj, KOBJ_ADD);
return count;
}
static ssize_t disk_dev_read(struct gendisk * disk, char *page)
Expand Down Expand Up @@ -455,14 +455,14 @@ static struct kobj_type ktype_block = {

extern struct kobj_type ktype_part;

static int block_hotplug_filter(struct kset *kset, struct kobject *kobj)
static int block_uevent_filter(struct kset *kset, struct kobject *kobj)
{
struct kobj_type *ktype = get_ktype(kobj);

return ((ktype == &ktype_block) || (ktype == &ktype_part));
}

static int block_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
static int block_uevent(struct kset *kset, struct kobject *kobj, char **envp,
int num_envp, char *buffer, int buffer_size)
{
struct kobj_type *ktype = get_ktype(kobj);
Expand All @@ -474,40 +474,40 @@ static int block_hotplug(struct kset *kset, struct kobject *kobj, char **envp,

if (ktype == &ktype_block) {
disk = container_of(kobj, struct gendisk, kobj);
add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
&length, "MINOR=%u", disk->first_minor);
add_uevent_var(envp, num_envp, &i, buffer, buffer_size,
&length, "MINOR=%u", disk->first_minor);
} else if (ktype == &ktype_part) {
disk = container_of(kobj->parent, struct gendisk, kobj);
part = container_of(kobj, struct hd_struct, kobj);
add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
&length, "MINOR=%u",
disk->first_minor + part->partno);
add_uevent_var(envp, num_envp, &i, buffer, buffer_size,
&length, "MINOR=%u",
disk->first_minor + part->partno);
} else
return 0;

add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length,
"MAJOR=%u", disk->major);
add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
"MAJOR=%u", disk->major);

/* add physical device, backing this device */
physdev = disk->driverfs_dev;
if (physdev) {
char *path = kobject_get_path(&physdev->kobj, GFP_KERNEL);

add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
&length, "PHYSDEVPATH=%s", path);
add_uevent_var(envp, num_envp, &i, buffer, buffer_size,
&length, "PHYSDEVPATH=%s", path);
kfree(path);

if (physdev->bus)
add_hotplug_env_var(envp, num_envp, &i,
buffer, buffer_size, &length,
"PHYSDEVBUS=%s",
physdev->bus->name);
add_uevent_var(envp, num_envp, &i,
buffer, buffer_size, &length,
"PHYSDEVBUS=%s",
physdev->bus->name);

if (physdev->driver)
add_hotplug_env_var(envp, num_envp, &i,
buffer, buffer_size, &length,
"PHYSDEVDRIVER=%s",
physdev->driver->name);
add_uevent_var(envp, num_envp, &i,
buffer, buffer_size, &length,
"PHYSDEVDRIVER=%s",
physdev->driver->name);
}

/* terminate, set to next free slot, shrink available space */
Expand All @@ -520,13 +520,13 @@ static int block_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
return 0;
}

static struct kset_hotplug_ops block_hotplug_ops = {
.filter = block_hotplug_filter,
.hotplug = block_hotplug,
static struct kset_uevent_ops block_uevent_ops = {
.filter = block_uevent_filter,
.uevent = block_uevent,
};

/* declare block_subsys. */
static decl_subsys(block, &ktype_block, &block_hotplug_ops);
static decl_subsys(block, &ktype_block, &block_uevent_ops);


/*
Expand Down
8 changes: 4 additions & 4 deletions drivers/acpi/container.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,21 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
if (ACPI_FAILURE(status) || !device) {
result = container_device_add(&device, handle);
if (!result)
kobject_hotplug(&device->kobj,
KOBJ_ONLINE);
kobject_uevent(&device->kobj,
KOBJ_ONLINE);
else
printk("Failed to add container\n");
}
} else {
if (ACPI_SUCCESS(status)) {
/* device exist and this is a remove request */
kobject_hotplug(&device->kobj, KOBJ_OFFLINE);
kobject_uevent(&device->kobj, KOBJ_OFFLINE);
}
}
break;
case ACPI_NOTIFY_EJECT_REQUEST:
if (!acpi_bus_get_device(handle, &device) && device) {
kobject_hotplug(&device->kobj, KOBJ_OFFLINE);
kobject_uevent(&device->kobj, KOBJ_OFFLINE);
}
break;
default:
Expand Down
8 changes: 4 additions & 4 deletions drivers/acpi/processor_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
return_VALUE(-ENODEV);

if ((pr->id >= 0) && (pr->id < NR_CPUS)) {
kobject_hotplug(&(*device)->kobj, KOBJ_ONLINE);
kobject_uevent(&(*device)->kobj, KOBJ_ONLINE);
}
return_VALUE(0);
}
Expand Down Expand Up @@ -788,13 +788,13 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
}

if (pr->id >= 0 && (pr->id < NR_CPUS)) {
kobject_hotplug(&device->kobj, KOBJ_OFFLINE);
kobject_uevent(&device->kobj, KOBJ_OFFLINE);
break;
}

result = acpi_processor_start(device);
if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) {
kobject_hotplug(&device->kobj, KOBJ_ONLINE);
kobject_uevent(&device->kobj, KOBJ_ONLINE);
} else {
ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
"Device [%s] failed to start\n",
Expand All @@ -818,7 +818,7 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
}

if ((pr->id < NR_CPUS) && (cpu_present(pr->id)))
kobject_hotplug(&device->kobj, KOBJ_OFFLINE);
kobject_uevent(&device->kobj, KOBJ_OFFLINE);
break;
default:
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Expand Down
14 changes: 7 additions & 7 deletions drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static struct kobj_type ktype_acpi_ns = {
.release = acpi_device_release,
};

static int namespace_hotplug(struct kset *kset, struct kobject *kobj,
static int namespace_uevent(struct kset *kset, struct kobject *kobj,
char **envp, int num_envp, char *buffer,
int buffer_size)
{
Expand All @@ -89,17 +89,17 @@ static int namespace_hotplug(struct kset *kset, struct kobject *kobj,
if (!dev->driver)
return 0;

if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len,
"PHYSDEVDRIVER=%s", dev->driver->name))
if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len,
"PHYSDEVDRIVER=%s", dev->driver->name))
return -ENOMEM;

envp[i] = NULL;

return 0;
}

static struct kset_hotplug_ops namespace_hotplug_ops = {
.hotplug = &namespace_hotplug,
static struct kset_uevent_ops namespace_uevent_ops = {
.uevent = &namespace_uevent,
};

static struct kset acpi_namespace_kset = {
Expand All @@ -108,7 +108,7 @@ static struct kset acpi_namespace_kset = {
},
.subsys = &acpi_subsys,
.ktype = &ktype_acpi_ns,
.hotplug_ops = &namespace_hotplug_ops,
.uevent_ops = &namespace_uevent_ops,
};

static void acpi_device_register(struct acpi_device *device,
Expand Down Expand Up @@ -347,7 +347,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
}

/* --------------------------------------------------------------------------
ACPI hotplug sysfs device file support
ACPI sysfs device file support
-------------------------------------------------------------------------- */
static ssize_t acpi_eject_store(struct acpi_device *device,
const char *buf, size_t count);
Expand Down
4 changes: 2 additions & 2 deletions drivers/base/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ config PREVENT_FIRMWARE_BUILD
If unsure say Y here.

config FW_LOADER
tristate "Hotplug firmware loading support"
tristate "Userspace firmware loading support"
select HOTPLUG
---help---
This option is provided for the case where no in-kernel-tree modules
require hotplug firmware loading support, but a module built outside
require userspace firmware loading support, but a module built outside
the kernel tree does.

config DEBUG_DRIVER
Expand Down
Loading

0 comments on commit 312c004

Please sign in to comment.