LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] ACPI video: Don't export sysfs backlight interface if query _BCL fail
@ 2007-04-27 10:18 Danny Kukawka
  2007-05-06  9:35 ` Luming Yu
  0 siblings, 1 reply; 2+ messages in thread
From: Danny Kukawka @ 2007-04-27 10:18 UTC (permalink / raw)
  To: linux-acpi; +Cc: linux-kernel, luming.yu

Hi,

currently the acpi video module export the backlight interface to sysfs also
if acpi_video_device_lcd_query_levels() fails to read _BLC method (e.g. 
because the method is not available). In this case the userspace don't know 
which brightness level are supported and can't set a brightness level (echo 
return with: "write error: Invalid Argument"). This happend e.g. on a ASUS
RF1 (correct supported by the asus-laptop module).

The video module should not export the backlight interface if query _BLC fail,
because you can't set anything from userspace and this make it useless.

See also: http://bugzilla.kernel.org/show_bug.cgi?id=8375

Danny

From: Danny Kukawka <dkukawka@suse.de>
Subject: ACPI video: Don't export sysfs backlight interface if query _BLC fail

if qeuery _BCL fail (e.g. because the method is missing in BIOS) don't 
export the backlight interface to sysfs.

Signed-off-by: Danny Kukawka <dkukawka@suse.de>
---
 video.c |   78 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 41 insertions(+), 37 deletions(-)

--- linux-2.6.21/drivers/acpi/video.c	2007-04-26 13:50:51.000000000 +0200
+++ linux-2.6.21/drivers/acpi/video.c	2007-04-26 13:50:53.000000000 +0200
@@ -531,7 +531,6 @@
 
 static void acpi_video_device_find_cap(struct acpi_video_device *device)
 {
-	acpi_integer status;
 	acpi_handle h_dummy1;
 	int i;
 	u32 max_level = 0;
@@ -565,50 +564,55 @@
 		device->cap._DSS = 1;
 	}
 
-	status = acpi_video_device_lcd_query_levels(device, &obj);
+	if (ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) {
 
-	if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) {
-		int count = 0;
-		union acpi_object *o;
-
-		br = kzalloc(sizeof(*br), GFP_KERNEL);
-		if (!br) {
-			printk(KERN_ERR "can't allocate memory\n");
-		} else {
-			br->levels = kmalloc(obj->package.count *
-					     sizeof *(br->levels), GFP_KERNEL);
-			if (!br->levels)
-				goto out;
-
-			for (i = 0; i < obj->package.count; i++) {
-				o = (union acpi_object *)&obj->package.
-				    elements[i];
-				if (o->type != ACPI_TYPE_INTEGER) {
-					printk(KERN_ERR PREFIX "Invalid data\n");
-					continue;
-				}
-				br->levels[count] = (u32) o->integer.value;
-				if (br->levels[count] > max_level)
-					max_level = br->levels[count];
-				count++;
-			}
-		      out:
-			if (count < 2) {
-				kfree(br->levels);
-				kfree(br);
+		if (obj->package.count >= 2) {
+			int count = 0;
+			union acpi_object *o;
+
+			br = kzalloc(sizeof(*br), GFP_KERNEL);
+			if (!br) {
+				printk(KERN_ERR "can't allocate memory\n");
 			} else {
-				br->count = count;
-				device->brightness = br;
-				ACPI_DEBUG_PRINT((ACPI_DB_INFO,
-						  "found %d brightness levels\n",
-						  count));
+				br->levels = kmalloc(obj->package.count *
+						     sizeof *(br->levels), GFP_KERNEL);
+				if (!br->levels) 
+					goto out;
+
+				for (i = 0; i < obj->package.count; i++) {
+					o = (union acpi_object *)&obj->package.
+					    elements[i];
+					if (o->type != ACPI_TYPE_INTEGER) {
+						printk(KERN_ERR PREFIX "Invalid data\n");
+						continue;
+					}
+					br->levels[count] = (u32) o->integer.value;
+
+					if (br->levels[count] > max_level)
+						max_level = br->levels[count];
+					count++;
+				}
+			      out:
+				if (count < 2) {
+					kfree(br->levels);
+					kfree(br);
+				} else {
+					br->count = count;
+					device->brightness = br;
+					ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+							  "found %d brightness levels\n",
+							  count));
+				}
 			}
 		}
+
+	} else {
+		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available LCD brightness level\n"));
 	}
 
 	kfree(obj);
 
-	if (device->cap._BCL && device->cap._BCM && device->cap._BQC){
+	if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){
 		unsigned long tmp;
 		static int count = 0;
 		char *name;


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ACPI video: Don't export sysfs backlight interface if query _BCL fail
  2007-04-27 10:18 [PATCH] ACPI video: Don't export sysfs backlight interface if query _BCL fail Danny Kukawka
@ 2007-05-06  9:35 ` Luming Yu
  0 siblings, 0 replies; 2+ messages in thread
From: Luming Yu @ 2007-05-06  9:35 UTC (permalink / raw)
  To: Danny Kukawka; +Cc: linux-acpi, linux-kernel, luming.yu

Ack!


On 4/27/07, Danny Kukawka <dkukawka@suse.de> wrote:
> Hi,
>
> currently the acpi video module export the backlight interface to sysfs also
> if acpi_video_device_lcd_query_levels() fails to read _BLC method (e.g.
> because the method is not available). In this case the userspace don't know
> which brightness level are supported and can't set a brightness level (echo
> return with: "write error: Invalid Argument"). This happend e.g. on a ASUS
> RF1 (correct supported by the asus-laptop module).
>
> The video module should not export the backlight interface if query _BLC fail,
> because you can't set anything from userspace and this make it useless.
>
> See also: http://bugzilla.kernel.org/show_bug.cgi?id=8375
>
> Danny
>
> From: Danny Kukawka <dkukawka@suse.de>
> Subject: ACPI video: Don't export sysfs backlight interface if query _BLC fail
>
> if qeuery _BCL fail (e.g. because the method is missing in BIOS) don't
> export the backlight interface to sysfs.
>
> Signed-off-by: Danny Kukawka <dkukawka@suse.de>
> ---
>  video.c |   78 ++++++++++++++++++++++++++++--------------------------
>  1 file changed, 41 insertions(+), 37 deletions(-)
>
> --- linux-2.6.21/drivers/acpi/video.c   2007-04-26 13:50:51.000000000 +0200
> +++ linux-2.6.21/drivers/acpi/video.c   2007-04-26 13:50:53.000000000 +0200
> @@ -531,7 +531,6 @@

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-05-06  9:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-27 10:18 [PATCH] ACPI video: Don't export sysfs backlight interface if query _BCL fail Danny Kukawka
2007-05-06  9:35 ` Luming Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).