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

Commit 99678ed7 authored by Hans de Goede's avatar Hans de Goede Committed by Rafael J. Wysocki
Browse files

ACPI / video: Don't register acpi_video_resume notifier without backlight devices



If we're not going to be registering any backlight devices then
acpi_video_resume is always nop, so don't register it in that case.

Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarAaron Lu <aaron.lu@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 886129a8
Loading
Loading
Loading
Loading
+74 −65
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ struct acpi_video_enumerated_device {

struct acpi_video_bus {
	struct acpi_device *device;
	bool backlight_registered;
	u8 dos_setting;
	struct acpi_video_enumerated_device *attached_array;
	u8 attached_count;
@@ -1666,7 +1667,6 @@ acpi_video_bus_match(acpi_handle handle, u32 level, void *context,

static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
{
	if (acpi_video_verify_backlight_support()) {
	struct backlight_properties props;
	struct pci_dev *pdev;
	acpi_handle acpi_parent;
@@ -1714,11 +1714,9 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
				device->dev, &video_cooling_ops);
	if (IS_ERR(device->cooling_dev)) {
		/*
			 * Set cooling_dev to NULL so we don't crash trying to
			 * free it.
			 * Also, why the hell we are returning early and
			 * not attempt to register video output if cooling
			 * device registration failed?
		 * Set cooling_dev to NULL so we don't crash trying to free it.
		 * Also, why the hell we are returning early and not attempt to
		 * register video output if cooling device registration failed?
		 * -- dtor
		 */
		device->cooling_dev = NULL;
@@ -1737,17 +1735,21 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
	if (result)
		printk(KERN_ERR PREFIX "Create sysfs link\n");
}
}

static int acpi_video_bus_register_backlight(struct acpi_video_bus *video)
{
	struct acpi_video_device *dev;

	if (!acpi_video_verify_backlight_support())
		return 0;

	mutex_lock(&video->device_list_lock);
	list_for_each_entry(dev, &video->video_device_list, entry)
		acpi_video_dev_register_backlight(dev);
	mutex_unlock(&video->device_list_lock);

	video->backlight_registered = true;

	video->pm_nb.notifier_call = acpi_video_resume;
	video->pm_nb.priority = 0;
	return register_pm_notifier(&video->pm_nb);
@@ -1775,13 +1777,20 @@ static void acpi_video_dev_unregister_backlight(struct acpi_video_device *device
static int acpi_video_bus_unregister_backlight(struct acpi_video_bus *video)
{
	struct acpi_video_device *dev;
	int error = unregister_pm_notifier(&video->pm_nb);
	int error;

	if (!video->backlight_registered)
		return 0;

	error = unregister_pm_notifier(&video->pm_nb);

	mutex_lock(&video->device_list_lock);
	list_for_each_entry(dev, &video->video_device_list, entry)
		acpi_video_dev_unregister_backlight(dev);
	mutex_unlock(&video->device_list_lock);

	video->backlight_registered = false;

	return error;
}