]> nv-tegra.nvidia Code Review - linux-3.10.git/blobdiff - drivers/acpi/video.c
ACPI / scan: Remove unnecessary initialization of local variables
[linux-3.10.git] / drivers / acpi / video.c
index eaef02afc7cfce7004e3d74e25b733ee4d54cb97..ac9a69cd45f5a4082a05c743de6dd58aad369c60 100644 (file)
@@ -389,6 +389,12 @@ static int __init video_set_bqc_offset(const struct dmi_system_id *d)
        return 0;
 }
 
+static int video_ignore_initial_backlight(const struct dmi_system_id *d)
+{
+       use_bios_initial_backlight = 0;
+       return 0;
+}
+
 static struct dmi_system_id video_dmi_table[] __initdata = {
        /*
         * Broken _BQC workaround http://bugzilla.kernel.org/show_bug.cgi?id=13121
@@ -433,6 +439,14 @@ static struct dmi_system_id video_dmi_table[] __initdata = {
                DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7720"),
                },
        },
+       {
+        .callback = video_ignore_initial_backlight,
+        .ident = "HP Folio 13-2000",
+        .matches = {
+               DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
+               DMI_MATCH(DMI_PRODUCT_NAME, "HP Folio 13 - 2000 Notebook PC"),
+               },
+       },
        {}
 };
 
@@ -548,27 +562,29 @@ acpi_video_device_EDID(struct acpi_video_device *device,
  *             1.      The system BIOS should NOT automatically control the brightness 
  *                     level of the LCD when the power changes from AC to DC.
  * Return Value:
- *             -1      wrong arg.
+ *             -EINVAL wrong arg.
  */
 
 static int
 acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
 {
-       u64 status = 0;
+       acpi_status status;
        union acpi_object arg0 = { ACPI_TYPE_INTEGER };
        struct acpi_object_list args = { 1, &arg0 };
 
+       if (!video->cap._DOS)
+               return 0;
 
-       if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1) {
-               status = -1;
-               goto Failed;
-       }
+       if (bios_flag < 0 || bios_flag > 3 || lcd_flag < 0 || lcd_flag > 1)
+               return -EINVAL;
        arg0.integer.value = (lcd_flag << 2) | bios_flag;
        video->dos_setting = arg0.integer.value;
-       acpi_evaluate_object(video->device->handle, "_DOS", &args, NULL);
+       status = acpi_evaluate_object(video->device->handle, "_DOS",
+               &args, NULL);
+       if (ACPI_FAILURE(status))
+               return -EIO;
 
-      Failed:
-       return status;
+       return 0;
 }
 
 /*
@@ -1346,12 +1362,17 @@ acpi_video_bus_get_devices(struct acpi_video_bus *video,
        int status = 0;
        struct acpi_device *dev;
 
+       /*
+        * There are systems where video module known to work fine regardless
+        * of broken _DOD and ignoring returned value here doesn't cause
+        * any issues later.
+        */
        acpi_video_device_enumerate(video);
 
        list_for_each_entry(dev, &device->children, node) {
 
                status = acpi_video_bus_get_one_device(dev, video);
-               if (ACPI_FAILURE(status)) {
+               if (status) {
                        printk(KERN_WARNING PREFIX
                                        "Can't attach device\n");
                        continue;
@@ -1444,8 +1465,7 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
        case ACPI_VIDEO_NOTIFY_SWITCH:  /* User requested a switch,
                                         * most likely via hotkey. */
                acpi_bus_generate_proc_event(device, event, 0);
-               if (!acpi_notifier_call_chain(device, event, 0))
-                       keycode = KEY_SWITCHVIDEOMODE;
+               keycode = KEY_SWITCHVIDEOMODE;
                break;
 
        case ACPI_VIDEO_NOTIFY_PROBE:   /* User plugged in or removed a video
@@ -1475,8 +1495,9 @@ static void acpi_video_bus_notify(struct acpi_device *device, u32 event)
                break;
        }
 
-       if (event != ACPI_VIDEO_NOTIFY_SWITCH)
-               acpi_notifier_call_chain(device, event, 0);
+       if (acpi_notifier_call_chain(device, event, 0))
+               /* Something vetoed the keypress. */
+               keycode = 0;
 
        if (keycode) {
                input_report_key(input, keycode, 1);
@@ -1653,15 +1674,20 @@ static int acpi_video_bus_add(struct acpi_device *device)
        mutex_init(&video->device_list_lock);
        INIT_LIST_HEAD(&video->video_device_list);
 
-       acpi_video_bus_get_devices(video, device);
-       acpi_video_bus_start_devices(video);
+       error = acpi_video_bus_get_devices(video, device);
+       if (error)
+               goto err_free_video;
 
        video->input = input = input_allocate_device();
        if (!input) {
                error = -ENOMEM;
-               goto err_stop_video;
+               goto err_put_video;
        }
 
+       error = acpi_video_bus_start_devices(video);
+       if (error)
+               goto err_free_input_dev;
+
        snprintf(video->phys, sizeof(video->phys),
                "%s/video/input0", acpi_device_hid(video->device));
 
@@ -1680,10 +1706,6 @@ static int acpi_video_bus_add(struct acpi_device *device)
        set_bit(KEY_BRIGHTNESS_ZERO, input->keybit);
        set_bit(KEY_DISPLAY_OFF, input->keybit);
 
-       error = input_register_device(input);
-       if (error)
-               goto err_free_input_dev;
-
        printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s  rom: %s  post: %s)\n",
               ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
               video->flags.multihead ? "yes" : "no",
@@ -1692,14 +1714,23 @@ static int acpi_video_bus_add(struct acpi_device *device)
 
        video->pm_nb.notifier_call = acpi_video_resume;
        video->pm_nb.priority = 0;
-       register_pm_notifier(&video->pm_nb);
+       error = register_pm_notifier(&video->pm_nb);
+       if (error)
+               goto err_stop_video;
+
+       error = input_register_device(input);
+       if (error)
+               goto err_unregister_pm_notifier;
 
        return 0;
 
- err_free_input_dev:
-       input_free_device(input);
+ err_unregister_pm_notifier:
+       unregister_pm_notifier(&video->pm_nb);
  err_stop_video:
        acpi_video_bus_stop_devices(video);
+ err_free_input_dev:
+       input_free_device(input);
+ err_put_video:
        acpi_video_bus_put_devices(video);
        kfree(video->attached_array);
  err_free_video:
@@ -1731,9 +1762,18 @@ static int acpi_video_bus_remove(struct acpi_device *device, int type)
        return 0;
 }
 
+static int __init is_i740(struct pci_dev *dev)
+{
+       if (dev->device == 0x00D1)
+               return 1;
+       if (dev->device == 0x7000)
+               return 1;
+       return 0;
+}
+
 static int __init intel_opregion_present(void)
 {
-#if defined(CONFIG_DRM_I915) || defined(CONFIG_DRM_I915_MODULE)
+       int opregion = 0;
        struct pci_dev *dev = NULL;
        u32 address;
 
@@ -1742,13 +1782,15 @@ static int __init intel_opregion_present(void)
                        continue;
                if (dev->vendor != PCI_VENDOR_ID_INTEL)
                        continue;
+               /* We don't want to poke around undefined i740 registers */
+               if (is_i740(dev))
+                       continue;
                pci_read_config_dword(dev, 0xfc, &address);
                if (!address)
                        continue;
-               return 1;
+               opregion = 1;
        }
-#endif
-       return 0;
+       return opregion;
 }
 
 int acpi_video_register(void)