Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 312c004d authored by Kay Sievers's avatar Kay Sievers Committed by Greg Kroah-Hartman
Browse files

[PATCH] driver core: replace "hotplug" by "uevent"



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: default avatarKay Sievers <kay.sievers@suse.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 5f123fbd
Loading
Loading
Loading
Loading
+16 −15
Original line number Diff line number Diff line
@@ -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.

@@ -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.
@@ -264,23 +264,24 @@ rpa_php_unconfig_pci_adapter() { // in rpaphp_pci.c
          calls
          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
+1 −1
Original line number Diff line number Diff line
@@ -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,
};
+24 −24
Original line number Diff line number Diff line
@@ -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)
@@ -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);
@@ -474,18 +474,18 @@ 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,
		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,
		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,
	add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
		       "MAJOR=%u", disk->major);

	/* add physical device, backing this device  */
@@ -493,18 +493,18 @@ static int block_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
	if (physdev) {
		char *path = kobject_get_path(&physdev->kobj, GFP_KERNEL);

		add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size,
		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,
			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,
			add_uevent_var(envp, num_envp, &i,
				       buffer, buffer_size, &length,
				       "PHYSDEVDRIVER=%s",
				       physdev->driver->name);
@@ -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);


/*
+4 −4
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ 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,
					kobject_uevent(&device->kobj,
						       KOBJ_ONLINE);
				else
					printk("Failed to add container\n");
@@ -180,13 +180,13 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
		} 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:
+4 −4
Original line number Diff line number Diff line
@@ -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);
}
@@ -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",
@@ -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,
Loading