From: Matthew Garrett <matthew.garrett@nebula.com>
Date: Tue, 16 Jul 2013 17:08:16 +0000 (+0000)
Subject: ACPI / video: Always call acpi_video_init_brightness() on init
X-Git-Tag: firefly_0821_release~176^2~5660^2~2
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c04c697cf1fe8f0962ccd3c2392a9b637a5307aa;p=firefly-linux-kernel-4.4.55.git

ACPI / video: Always call acpi_video_init_brightness() on init

We have to call acpi_video_init_brightness() even if we're not going
to initialise the backlight - Thinkpads seem to use this as the
trigger for enabling ACPI notifications rather than handling it in
firmware.

[rjw: Drop the brightness object created by
 acpi_video_init_brightness() if we are not going to use it.]
Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 5d7075d25700..f236e172d948 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -898,6 +898,9 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
 		device->cap._DDC = 1;
 	}
 
+	if (acpi_video_init_brightness(device))
+		return;
+
 	if (acpi_video_backlight_support()) {
 		struct backlight_properties props;
 		struct pci_dev *pdev;
@@ -907,9 +910,6 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
 		static int count = 0;
 		char *name;
 
-		result = acpi_video_init_brightness(device);
-		if (result)
-			return;
 		name = kasprintf(GFP_KERNEL, "acpi_video%d", count);
 		if (!name)
 			return;
@@ -969,6 +969,11 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
 		if (result)
 			printk(KERN_ERR PREFIX "Create sysfs link\n");
 
+	} else {
+		/* Remove the brightness object. */
+		kfree(device->brightness->levels);
+		kfree(device->brightness);
+		device->brightness = NULL;
 	}
 }