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

Commit b844eba2 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Greg Kroah-Hartman
Browse files

PM: Remove destroy_suspended_device()



After 2.6.24 there was a plan to make the PM core acquire all device
semaphores during a suspend/hibernation to protect itself from
concurrent operations involving device objects.  That proved to be
too heavy-handed and we found a better way to achieve the goal, but
before it happened, we had introduced the functions
device_pm_schedule_removal() and destroy_suspended_device() to allow
drivers to "safely" destroy a suspended device and we had adapted some
drivers to use them.  Now that these functions are no longer necessary,
it seems reasonable to remove them and modify their users to use the
normal device unregistration instead.

Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 138fe4e0
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -154,12 +154,10 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
		err = cpuid_device_create(cpu);
		break;
	case CPU_UP_CANCELED:
	case CPU_UP_CANCELED_FROZEN:
	case CPU_DEAD:
		cpuid_device_destroy(cpu);
		break;
	case CPU_UP_CANCELED_FROZEN:
		destroy_suspended_device(cpuid_class, MKDEV(CPUID_MAJOR, cpu));
		break;
	}
	return err ? NOTIFY_BAD : NOTIFY_OK;
}
+1 −3
Original line number Diff line number Diff line
@@ -162,12 +162,10 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
		err = msr_device_create(cpu);
		break;
	case CPU_UP_CANCELED:
	case CPU_UP_CANCELED_FROZEN:
	case CPU_DEAD:
		msr_device_destroy(cpu);
		break;
	case CPU_UP_CANCELED_FROZEN:
		destroy_suspended_device(msr_class, MKDEV(MSR_MAJOR, cpu));
		break;
	}
	return err ? NOTIFY_BAD : NOTIFY_OK;
}
+0 −29
Original line number Diff line number Diff line
@@ -1163,35 +1163,6 @@ void device_destroy(struct class *class, dev_t devt)
}
EXPORT_SYMBOL_GPL(device_destroy);

#ifdef CONFIG_PM_SLEEP
/**
 * destroy_suspended_device - asks the PM core to remove a suspended device
 * @class: pointer to the struct class that this device was registered with
 * @devt: the dev_t of the device that was previously registered
 *
 * This call notifies the PM core of the necessity to unregister a suspended
 * device created with a call to device_create() (devices cannot be
 * unregistered directly while suspended, since the PM core holds their
 * semaphores at that time).
 *
 * It can only be called within the scope of a system sleep transition.  In
 * practice this means it has to be directly or indirectly invoked either by
 * a suspend or resume method, or by the PM core (e.g. via
 * disable_nonboot_cpus() or enable_nonboot_cpus()).
 */
void destroy_suspended_device(struct class *class, dev_t devt)
{
	struct device *dev;

	dev = class_find_device(class, &devt, __match_devt);
	if (dev) {
		device_pm_schedule_removal(dev);
		put_device(dev);
	}
}
EXPORT_SYMBOL_GPL(destroy_suspended_device);
#endif /* CONFIG_PM_SLEEP */

/**
 * device_rename - renames a device
 * @dev: the pointer to the struct device to be renamed
+0 −40
Original line number Diff line number Diff line
@@ -50,7 +50,6 @@
LIST_HEAD(dpm_active);
static LIST_HEAD(dpm_off);
static LIST_HEAD(dpm_off_irq);
static LIST_HEAD(dpm_destroy);

static DEFINE_MUTEX(dpm_list_mtx);

@@ -104,24 +103,6 @@ void device_pm_remove(struct device *dev)
	mutex_unlock(&dpm_list_mtx);
}

/**
 *	device_pm_schedule_removal - schedule the removal of a suspended device
 *	@dev:	Device to destroy
 *
 *	Moves the device to the dpm_destroy list for further processing by
 *	unregister_dropped_devices().
 */
void device_pm_schedule_removal(struct device *dev)
{
	pr_debug("PM: Preparing for removal: %s:%s\n",
		dev->bus ? dev->bus->name : "No Bus",
		kobject_name(&dev->kobj));
	mutex_lock(&dpm_list_mtx);
	list_move_tail(&dev->power.entry, &dpm_destroy);
	mutex_unlock(&dpm_list_mtx);
}
EXPORT_SYMBOL_GPL(device_pm_schedule_removal);

/*------------------------- Resume routines -------------------------*/

/**
@@ -245,26 +226,6 @@ static void dpm_resume(void)
	mutex_unlock(&dpm_list_mtx);
}

/**
 *	unregister_dropped_devices - Unregister devices scheduled for removal
 *
 *	Unregister all devices on the dpm_destroy list.
 */
static void unregister_dropped_devices(void)
{
	mutex_lock(&dpm_list_mtx);
	while (!list_empty(&dpm_destroy)) {
		struct list_head *entry = dpm_destroy.next;
		struct device *dev = to_device(entry);

		mutex_unlock(&dpm_list_mtx);
		/* This also removes the device from the list */
		device_unregister(dev);
		mutex_lock(&dpm_list_mtx);
	}
	mutex_unlock(&dpm_list_mtx);
}

/**
 *	device_resume - Restore state of each device in system.
 *
@@ -275,7 +236,6 @@ void device_resume(void)
{
	might_sleep();
	dpm_resume();
	unregister_dropped_devices();
}
EXPORT_SYMBOL_GPL(device_resume);

+5 −5
Original line number Diff line number Diff line
@@ -238,11 +238,11 @@ static DEVICE_ATTR(rng_available, S_IRUGO,
		   NULL);


static void unregister_miscdev(bool suspended)
static void unregister_miscdev(void)
{
	device_remove_file(rng_miscdev.this_device, &dev_attr_rng_available);
	device_remove_file(rng_miscdev.this_device, &dev_attr_rng_current);
	__misc_deregister(&rng_miscdev, suspended);
	misc_deregister(&rng_miscdev);
}

static int register_miscdev(void)
@@ -317,7 +317,7 @@ out:
}
EXPORT_SYMBOL_GPL(hwrng_register);

void __hwrng_unregister(struct hwrng *rng, bool suspended)
void hwrng_unregister(struct hwrng *rng)
{
	int err;

@@ -336,11 +336,11 @@ void __hwrng_unregister(struct hwrng *rng, bool suspended)
		}
	}
	if (list_empty(&rng_list))
		unregister_miscdev(suspended);
		unregister_miscdev();

	mutex_unlock(&rng_mutex);
}
EXPORT_SYMBOL_GPL(__hwrng_unregister);
EXPORT_SYMBOL_GPL(hwrng_unregister);


MODULE_DESCRIPTION("H/W Random Number Generator (RNG) driver");
Loading