Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f70ac0e9651aa8c07dffe72a44872f92054d42c3
Commit:     f70ac0e9651aa8c07dffe72a44872f92054d42c3
Parent:     23b0f015bf2c050b8b5399430ca64e1b3398cf76
Author:     Danny Kukawka <[EMAIL PROTECTED]>
AuthorDate: Tue Jul 3 01:33:53 2007 -0400
Committer:  Len Brown <[EMAIL PROTECTED]>
CommitDate: Tue Jul 3 01:33:53 2007 -0400

    ACPI video: Don't export sysfs backlight interface if query _BCL fail
    
    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.
    
    http://bugzilla.kernel.org/show_bug.cgi?id=8375
    
    Signed-off-by: Danny Kukawka <[EMAIL PROTECTED]>
    Acked-by: Luming Yu <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Len Brown <[EMAIL PROTECTED]>
---
 drivers/acpi/video.c |   80 ++++++++++++++++++++++++++-----------------------
 1 files changed, 42 insertions(+), 38 deletions(-)

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 39273da..5f014d3 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -559,7 +559,6 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int 
bios_flag, int lcd_flag)
 
 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;
@@ -593,50 +592,55 @@ static void acpi_video_device_find_cap(struct 
acpi_video_device *device)
                device->cap._DSS = 1;
        }
 
-       status = 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 (ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) {
+
+               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;
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to