aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorAzael Avalos <coproscefalo@gmail.com>2014-08-04 11:21:01 -0400
committerMatthew Garrett <matthew.garrett@nebula.com>2014-08-16 04:23:54 -0400
commitf6aac652290b31f120fc07c61331e9e0d4b4afb9 (patch)
tree32b430149d6da304e69ec9b1094f0e5f7ed4e783 /drivers/platform
parentb58b9ffc95511fafcd12c6c7a45ec04e6dcf7d57 (diff)
toshiba_acpi: Add extra check to backlight code
Some Toshiba models (most notably Qosmios) come with an incomplete backlight method where the AML code doesn't check for write or read commands and always returns HCI_SUCCESS and the actual brightness (and in some cases the max brightness), thus allowing the backlight interface to be registered without write support. This patch changes the set_lcd_brightness function, checking the returned values for values greater than zero to avoid registering a broken backlight interface. Signed-off-by: Azael Avalos <coproscefalo@gmail.com> Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/toshiba_acpi.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index dfd2243451ba..fa65cec42971 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -872,7 +872,9 @@ static int lcd_proc_open(struct inode *inode, struct file *file)
872 872
873static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value) 873static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value)
874{ 874{
875 u32 hci_result; 875 u32 in[HCI_WORDS] = { HCI_SET, HCI_LCD_BRIGHTNESS, 0, 0, 0, 0 };
876 u32 out[HCI_WORDS];
877 acpi_status status;
876 878
877 if (dev->tr_backlight_supported) { 879 if (dev->tr_backlight_supported) {
878 bool enable = !value; 880 bool enable = !value;
@@ -883,9 +885,20 @@ static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value)
883 value--; 885 value--;
884 } 886 }
885 887
886 value = value << HCI_LCD_BRIGHTNESS_SHIFT; 888 in[2] = value << HCI_LCD_BRIGHTNESS_SHIFT;
887 hci_write1(dev, HCI_LCD_BRIGHTNESS, value, &hci_result); 889 status = hci_raw(dev, in, out);
888 return hci_result == HCI_SUCCESS ? 0 : -EIO; 890 if (ACPI_FAILURE(status) || out[0] == HCI_FAILURE) {
891 pr_err("ACPI call to set brightness failed");
892 return -EIO;
893 }
894 /* Extra check for "incomplete" backlight method, where the AML code
895 * doesn't check for HCI_SET or HCI_GET and returns HCI_SUCCESS,
896 * the actual brightness, and in some cases the max brightness.
897 */
898 if (out[2] > 0 || out[3] == 0xE000)
899 return -ENODEV;
900
901 return out[0] == HCI_SUCCESS ? 0 : -EIO;
889} 902}
890 903
891static int set_lcd_status(struct backlight_device *bd) 904static int set_lcd_status(struct backlight_device *bd)