aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/asus-laptop.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/asus-laptop.c')
-rw-r--r--drivers/misc/asus-laptop.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/drivers/misc/asus-laptop.c b/drivers/misc/asus-laptop.c
index 0846c33296bc..34666ff60d37 100644
--- a/drivers/misc/asus-laptop.c
+++ b/drivers/misc/asus-laptop.c
@@ -254,7 +254,7 @@ ASUS_LED(gled, "gaming");
254 * method is searched within the scope of the handle, can be NULL. The output 254 * method is searched within the scope of the handle, can be NULL. The output
255 * of the method is written is output, which can also be NULL 255 * of the method is written is output, which can also be NULL
256 * 256 *
257 * returns 1 if write is successful, 0 else. 257 * returns 0 if write is successful, -1 else.
258 */ 258 */
259static int write_acpi_int(acpi_handle handle, const char *method, int val, 259static int write_acpi_int(acpi_handle handle, const char *method, int val,
260 struct acpi_buffer *output) 260 struct acpi_buffer *output)
@@ -263,13 +263,19 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val,
263 union acpi_object in_obj; //the only param we use 263 union acpi_object in_obj; //the only param we use
264 acpi_status status; 264 acpi_status status;
265 265
266 if (!handle)
267 return 0;
268
266 params.count = 1; 269 params.count = 1;
267 params.pointer = &in_obj; 270 params.pointer = &in_obj;
268 in_obj.type = ACPI_TYPE_INTEGER; 271 in_obj.type = ACPI_TYPE_INTEGER;
269 in_obj.integer.value = val; 272 in_obj.integer.value = val;
270 273
271 status = acpi_evaluate_object(handle, (char *)method, &params, output); 274 status = acpi_evaluate_object(handle, (char *)method, &params, output);
272 return (status == AE_OK); 275 if (status == AE_OK)
276 return 0;
277 else
278 return -1;
273} 279}
274 280
275static int read_wireless_status(int mask) 281static int read_wireless_status(int mask)
@@ -335,7 +341,7 @@ static void write_status(acpi_handle handle, int out, int mask)
335 break; 341 break;
336 } 342 }
337 343
338 if (handle && !write_acpi_int(handle, NULL, out, NULL)) 344 if (write_acpi_int(handle, NULL, out, NULL))
339 printk(ASUS_WARNING " write failed %x\n", mask); 345 printk(ASUS_WARNING " write failed %x\n", mask);
340} 346}
341 347
@@ -415,7 +421,7 @@ static int set_brightness(struct backlight_device *bd, int value)
415 value = (0 < value) ? ((15 < value) ? 15 : value) : 0; 421 value = (0 < value) ? ((15 < value) ? 15 : value) : 0;
416 /* 0 <= value <= 15 */ 422 /* 0 <= value <= 15 */
417 423
418 if (!write_acpi_int(brightness_set_handle, NULL, value, NULL)) { 424 if (write_acpi_int(brightness_set_handle, NULL, value, NULL)) {
419 printk(ASUS_WARNING "Error changing brightness\n"); 425 printk(ASUS_WARNING "Error changing brightness\n");
420 ret = -EIO; 426 ret = -EIO;
421 } 427 }
@@ -545,7 +551,7 @@ static ssize_t store_ledd(struct device *dev, struct device_attribute *attr,
545 551
546 rv = parse_arg(buf, count, &value); 552 rv = parse_arg(buf, count, &value);
547 if (rv > 0) { 553 if (rv > 0) {
548 if (!write_acpi_int(ledd_set_handle, NULL, value, NULL)) 554 if (write_acpi_int(ledd_set_handle, NULL, value, NULL))
549 printk(ASUS_WARNING "LED display write failed\n"); 555 printk(ASUS_WARNING "LED display write failed\n");
550 else 556 else
551 hotk->ledd_status = (u32) value; 557 hotk->ledd_status = (u32) value;
@@ -590,7 +596,7 @@ static ssize_t store_bluetooth(struct device *dev,
590static void set_display(int value) 596static void set_display(int value)
591{ 597{
592 /* no sanity check needed for now */ 598 /* no sanity check needed for now */
593 if (!write_acpi_int(display_set_handle, NULL, value, NULL)) 599 if (write_acpi_int(display_set_handle, NULL, value, NULL))
594 printk(ASUS_WARNING "Error setting display\n"); 600 printk(ASUS_WARNING "Error setting display\n");
595 return; 601 return;
596} 602}
@@ -647,7 +653,7 @@ static ssize_t store_disp(struct device *dev, struct device_attribute *attr,
647 */ 653 */
648static void set_light_sens_switch(int value) 654static void set_light_sens_switch(int value)
649{ 655{
650 if (!write_acpi_int(ls_switch_handle, NULL, value, NULL)) 656 if (write_acpi_int(ls_switch_handle, NULL, value, NULL))
651 printk(ASUS_WARNING "Error setting light sensor switch\n"); 657 printk(ASUS_WARNING "Error setting light sensor switch\n");
652 hotk->light_switch = value; 658 hotk->light_switch = value;
653} 659}
@@ -672,7 +678,7 @@ static ssize_t store_lssw(struct device *dev, struct device_attribute *attr,
672 678
673static void set_light_sens_level(int value) 679static void set_light_sens_level(int value)
674{ 680{
675 if (!write_acpi_int(ls_level_handle, NULL, value, NULL)) 681 if (write_acpi_int(ls_level_handle, NULL, value, NULL))
676 printk(ASUS_WARNING "Error setting light sensor level\n"); 682 printk(ASUS_WARNING "Error setting light sensor level\n");
677 hotk->light_level = value; 683 hotk->light_level = value;
678} 684}
@@ -860,7 +866,7 @@ static int asus_hotk_get_info(void)
860 printk(ASUS_WARNING "Couldn't get the DSDT table header\n"); 866 printk(ASUS_WARNING "Couldn't get the DSDT table header\n");
861 867
862 /* We have to write 0 on init this far for all ASUS models */ 868 /* We have to write 0 on init this far for all ASUS models */
863 if (!write_acpi_int(hotk->handle, "INIT", 0, &buffer)) { 869 if (write_acpi_int(hotk->handle, "INIT", 0, &buffer)) {
864 printk(ASUS_ERR "Hotkey initialization failed\n"); 870 printk(ASUS_ERR "Hotkey initialization failed\n");
865 return -ENODEV; 871 return -ENODEV;
866 } 872 }