aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/toshiba_acpi.c
diff options
context:
space:
mode:
authorSeth Forshee <seth.forshee@canonical.com>2011-09-20 17:55:50 -0400
committerMatthew Garrett <mjg@redhat.com>2011-10-24 10:52:36 -0400
commit32bcd5cba02436336053d9c3b7a8ff86f889ebf4 (patch)
tree2a51f960618ea2e7360419c8f235b0848552fb1b /drivers/platform/x86/toshiba_acpi.c
parent135740de77641b4180c8a1f19abcfcd5e4351b15 (diff)
toshiba_acpi: Fix up return codes
Many routines are returning success on failure, and those that are indicating failure frequently return incorrect error codes. Fix these up throughout the driver. Signed-off-by: Seth Forshee <seth.forshee@canonical.com> Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/platform/x86/toshiba_acpi.c')
-rw-r--r--drivers/platform/x86/toshiba_acpi.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index d74c97cde0f1..6b281c040bc0 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -191,7 +191,7 @@ static int write_acpi_int(const char *methodName, int val)
191 in_objs[0].integer.value = val; 191 in_objs[0].integer.value = val;
192 192
193 status = acpi_evaluate_object(NULL, (char *)methodName, &params, NULL); 193 status = acpi_evaluate_object(NULL, (char *)methodName, &params, NULL);
194 return (status == AE_OK); 194 return (status == AE_OK) ? 0 : -EIO;
195} 195}
196 196
197/* Perform a raw HCI call. Here we don't care about input or output buffer 197/* Perform a raw HCI call. Here we don't care about input or output buffer
@@ -419,7 +419,7 @@ static int bt_rfkill_set_block(void *data, bool blocked)
419 419
420 mutex_lock(&dev->mutex); 420 mutex_lock(&dev->mutex);
421 if (hci_get_radio_state(dev, &radio_state) != HCI_SUCCESS) { 421 if (hci_get_radio_state(dev, &radio_state) != HCI_SUCCESS) {
422 err = -EBUSY; 422 err = -EIO;
423 goto out; 423 goto out;
424 } 424 }
425 425
@@ -432,7 +432,7 @@ static int bt_rfkill_set_block(void *data, bool blocked)
432 hci_write2(dev, HCI_WIRELESS, value, HCI_WIRELESS_BT_ATTACH, &result2); 432 hci_write2(dev, HCI_WIRELESS, value, HCI_WIRELESS_BT_ATTACH, &result2);
433 433
434 if (result1 != HCI_SUCCESS || result2 != HCI_SUCCESS) 434 if (result1 != HCI_SUCCESS || result2 != HCI_SUCCESS)
435 err = -EBUSY; 435 err = -EIO;
436 else 436 else
437 err = 0; 437 err = 0;
438 out: 438 out:
@@ -478,10 +478,10 @@ static int get_lcd(struct backlight_device *bd)
478 u32 value; 478 u32 value;
479 479
480 hci_read1(dev, HCI_LCD_BRIGHTNESS, &value, &hci_result); 480 hci_read1(dev, HCI_LCD_BRIGHTNESS, &value, &hci_result);
481 if (hci_result == HCI_SUCCESS) { 481 if (hci_result == HCI_SUCCESS)
482 return (value >> HCI_LCD_BRIGHTNESS_SHIFT); 482 return (value >> HCI_LCD_BRIGHTNESS_SHIFT);
483 } else 483
484 return -EFAULT; 484 return -EIO;
485} 485}
486 486
487static int lcd_proc_show(struct seq_file *m, void *v) 487static int lcd_proc_show(struct seq_file *m, void *v)
@@ -497,11 +497,11 @@ static int lcd_proc_show(struct seq_file *m, void *v)
497 seq_printf(m, "brightness: %d\n", value); 497 seq_printf(m, "brightness: %d\n", value);
498 seq_printf(m, "brightness_levels: %d\n", 498 seq_printf(m, "brightness_levels: %d\n",
499 HCI_LCD_BRIGHTNESS_LEVELS); 499 HCI_LCD_BRIGHTNESS_LEVELS);
500 } else { 500 return 0;
501 pr_err("Error reading LCD brightness\n");
502 } 501 }
503 502
504 return 0; 503 pr_err("Error reading LCD brightness\n");
504 return -EIO;
505} 505}
506 506
507static int lcd_proc_open(struct inode *inode, struct file *file) 507static int lcd_proc_open(struct inode *inode, struct file *file)
@@ -515,10 +515,7 @@ static int set_lcd(struct toshiba_acpi_dev *dev, int value)
515 515
516 value = value << HCI_LCD_BRIGHTNESS_SHIFT; 516 value = value << HCI_LCD_BRIGHTNESS_SHIFT;
517 hci_write1(dev, HCI_LCD_BRIGHTNESS, value, &hci_result); 517 hci_write1(dev, HCI_LCD_BRIGHTNESS, value, &hci_result);
518 if (hci_result != HCI_SUCCESS) 518 return hci_result == HCI_SUCCESS ? 0 : -EIO;
519 return -EFAULT;
520
521 return 0;
522} 519}
523 520
524static int set_lcd_status(struct backlight_device *bd) 521static int set_lcd_status(struct backlight_device *bd)
@@ -575,11 +572,10 @@ static int video_proc_show(struct seq_file *m, void *v)
575 seq_printf(m, "lcd_out: %d\n", is_lcd); 572 seq_printf(m, "lcd_out: %d\n", is_lcd);
576 seq_printf(m, "crt_out: %d\n", is_crt); 573 seq_printf(m, "crt_out: %d\n", is_crt);
577 seq_printf(m, "tv_out: %d\n", is_tv); 574 seq_printf(m, "tv_out: %d\n", is_tv);
578 } else { 575 return 0;
579 pr_err("Error reading video out status\n");
580 } 576 }
581 577
582 return 0; 578 return -EIO;
583} 579}
584 580
585static int video_proc_open(struct inode *inode, struct file *file) 581static int video_proc_open(struct inode *inode, struct file *file)
@@ -592,6 +588,7 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf,
592{ 588{
593 struct toshiba_acpi_dev *dev = PDE(file->f_path.dentry->d_inode)->data; 589 struct toshiba_acpi_dev *dev = PDE(file->f_path.dentry->d_inode)->data;
594 char *cmd, *buffer; 590 char *cmd, *buffer;
591 int ret = 0;
595 int value; 592 int value;
596 int remain = count; 593 int remain = count;
597 int lcd_out = -1; 594 int lcd_out = -1;
@@ -644,12 +641,12 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf,
644 /* To avoid unnecessary video disruption, only write the new 641 /* To avoid unnecessary video disruption, only write the new
645 * video setting if something changed. */ 642 * video setting if something changed. */
646 if (new_video_out != video_out) 643 if (new_video_out != video_out)
647 write_acpi_int(METHOD_VIDEO_OUT, new_video_out); 644 ret = write_acpi_int(METHOD_VIDEO_OUT, new_video_out);
648 } else { 645 } else {
649 return -EFAULT; 646 ret = -EIO;
650 } 647 }
651 648
652 return count; 649 return ret ? ret : count;
653} 650}
654 651
655static const struct file_operations video_proc_fops = { 652static const struct file_operations video_proc_fops = {
@@ -671,11 +668,10 @@ static int fan_proc_show(struct seq_file *m, void *v)
671 if (hci_result == HCI_SUCCESS) { 668 if (hci_result == HCI_SUCCESS) {
672 seq_printf(m, "running: %d\n", (value > 0)); 669 seq_printf(m, "running: %d\n", (value > 0));
673 seq_printf(m, "force_on: %d\n", dev->force_fan); 670 seq_printf(m, "force_on: %d\n", dev->force_fan);
674 } else { 671 return 0;
675 pr_err("Error reading fan status\n");
676 } 672 }
677 673
678 return 0; 674 return -EIO;
679} 675}
680 676
681static int fan_proc_open(struct inode *inode, struct file *file) 677static int fan_proc_open(struct inode *inode, struct file *file)
@@ -701,7 +697,7 @@ static ssize_t fan_proc_write(struct file *file, const char __user *buf,
701 value >= 0 && value <= 1) { 697 value >= 0 && value <= 1) {
702 hci_write1(dev, HCI_FAN, value, &hci_result); 698 hci_write1(dev, HCI_FAN, value, &hci_result);
703 if (hci_result != HCI_SUCCESS) 699 if (hci_result != HCI_SUCCESS)
704 return -EFAULT; 700 return -EIO;
705 else 701 else
706 dev->force_fan = value; 702 dev->force_fan = value;
707 } else { 703 } else {
@@ -741,13 +737,12 @@ static int keys_proc_show(struct seq_file *m, void *v)
741 pr_notice("Re-enabled hotkeys\n"); 737 pr_notice("Re-enabled hotkeys\n");
742 } else { 738 } else {
743 pr_err("Error reading hotkey status\n"); 739 pr_err("Error reading hotkey status\n");
744 goto end; 740 return -EIO;
745 } 741 }
746 } 742 }
747 743
748 seq_printf(m, "hotkey_ready: %d\n", dev->key_event_valid); 744 seq_printf(m, "hotkey_ready: %d\n", dev->key_event_valid);
749 seq_printf(m, "hotkey: 0x%04x\n", dev->last_key_event); 745 seq_printf(m, "hotkey: 0x%04x\n", dev->last_key_event);
750end:
751 return 0; 746 return 0;
752} 747}
753 748