aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform
diff options
context:
space:
mode:
authorAzael Avalos <coproscefalo@gmail.com>2015-07-31 23:58:14 -0400
committerDarren Hart <dvhart@linux.intel.com>2015-08-05 05:08:03 -0400
commite1a949c1b9883d1d0586b0cbdd2c0cc3f55514bd (patch)
tree3f6890c542000b1c4611f55ecdf07b422364c4d4 /drivers/platform
parent0409cbced3c9ab975e300584b6cc036c26974b43 (diff)
toshiba_acpi: Refactor *{get, set} functions return value
This patch refactors the return value of the driver *{get, set} functions, since the driver default error value is -EIO. All the functions now check for TOS_FAILURE, TOS_NOT_SUPPORTED and TOS_SUCCESS. On TOS_FAILURE a pr_err message is printed informing the user of the error (no change was made to this, except the check was added to the functions not checking for this). On TOS_NOT_SUPPORTED we now return -ENODEV immediately (some functions were returning -EIO and some other were not checking) On TOS_SUCCESS* we now return 0 (as a side effect, a new success value was added, since some functions return one instead of zero to indicate success). As a special case, the LED functions now check for *FAILURE on *set, and check for TOS_FAILURE and TOS_SUCCESS on *get with their "default" return value set to LED_OFF. Also the {lcd, video}_proc* functions were adapted to reflect these changes to their parent HCI functions. Signed-off-by: Azael Avalos <coproscefalo@gmail.com> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r--drivers/platform/x86/toshiba_acpi.c177
1 files changed, 104 insertions, 73 deletions
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 66b596a7f710..65adb122189f 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -93,6 +93,7 @@ MODULE_LICENSE("GPL");
93 93
94/* Return codes */ 94/* Return codes */
95#define TOS_SUCCESS 0x0000 95#define TOS_SUCCESS 0x0000
96#define TOS_SUCCESS2 0x0001
96#define TOS_OPEN_CLOSE_OK 0x0044 97#define TOS_OPEN_CLOSE_OK 0x0044
97#define TOS_FAILURE 0x1000 98#define TOS_FAILURE 0x1000
98#define TOS_NOT_SUPPORTED 0x8000 99#define TOS_NOT_SUPPORTED 0x8000
@@ -469,7 +470,8 @@ static void toshiba_illumination_set(struct led_classdev *cdev,
469{ 470{
470 struct toshiba_acpi_dev *dev = container_of(cdev, 471 struct toshiba_acpi_dev *dev = container_of(cdev,
471 struct toshiba_acpi_dev, led_dev); 472 struct toshiba_acpi_dev, led_dev);
472 u32 state, result; 473 u32 result;
474 u32 state;
473 475
474 /* First request : initialize communication. */ 476 /* First request : initialize communication. */
475 if (!sci_open(dev)) 477 if (!sci_open(dev))
@@ -503,7 +505,7 @@ static enum led_brightness toshiba_illumination_get(struct led_classdev *cdev)
503 if (result == TOS_FAILURE || result == TOS_INPUT_DATA_ERROR) { 505 if (result == TOS_FAILURE || result == TOS_INPUT_DATA_ERROR) {
504 pr_err("ACPI call for illumination failed\n"); 506 pr_err("ACPI call for illumination failed\n");
505 return LED_OFF; 507 return LED_OFF;
506 } else if (result == TOS_NOT_SUPPORTED) { 508 } else if (result != TOS_SUCCESS) {
507 return LED_OFF; 509 return LED_OFF;
508 } 510 }
509 511
@@ -565,7 +567,7 @@ static int toshiba_kbd_illum_status_set(struct toshiba_acpi_dev *dev, u32 time)
565 return -ENODEV; 567 return -ENODEV;
566 } 568 }
567 569
568 return 0; 570 return result == TOS_SUCCESS ? 0 : -EIO;
569} 571}
570 572
571static int toshiba_kbd_illum_status_get(struct toshiba_acpi_dev *dev, u32 *time) 573static int toshiba_kbd_illum_status_get(struct toshiba_acpi_dev *dev, u32 *time)
@@ -584,21 +586,22 @@ static int toshiba_kbd_illum_status_get(struct toshiba_acpi_dev *dev, u32 *time)
584 return -ENODEV; 586 return -ENODEV;
585 } 587 }
586 588
587 return 0; 589 return result == TOS_SUCCESS ? 0 : -EIO;
588} 590}
589 591
590static enum led_brightness toshiba_kbd_backlight_get(struct led_classdev *cdev) 592static enum led_brightness toshiba_kbd_backlight_get(struct led_classdev *cdev)
591{ 593{
592 struct toshiba_acpi_dev *dev = container_of(cdev, 594 struct toshiba_acpi_dev *dev = container_of(cdev,
593 struct toshiba_acpi_dev, kbd_led); 595 struct toshiba_acpi_dev, kbd_led);
594 u32 state, result; 596 u32 result;
597 u32 state;
595 598
596 /* Check the keyboard backlight state */ 599 /* Check the keyboard backlight state */
597 result = hci_read(dev, HCI_KBD_ILLUMINATION, &state); 600 result = hci_read(dev, HCI_KBD_ILLUMINATION, &state);
598 if (result == TOS_FAILURE || result == TOS_INPUT_DATA_ERROR) { 601 if (result == TOS_FAILURE || result == TOS_INPUT_DATA_ERROR) {
599 pr_err("ACPI call to get the keyboard backlight failed\n"); 602 pr_err("ACPI call to get the keyboard backlight failed\n");
600 return LED_OFF; 603 return LED_OFF;
601 } else if (result == TOS_NOT_SUPPORTED) { 604 } else if (result != TOS_SUCCESS) {
602 return LED_OFF; 605 return LED_OFF;
603 } 606 }
604 607
@@ -610,7 +613,8 @@ static void toshiba_kbd_backlight_set(struct led_classdev *cdev,
610{ 613{
611 struct toshiba_acpi_dev *dev = container_of(cdev, 614 struct toshiba_acpi_dev *dev = container_of(cdev,
612 struct toshiba_acpi_dev, kbd_led); 615 struct toshiba_acpi_dev, kbd_led);
613 u32 state, result; 616 u32 result;
617 u32 state;
614 618
615 /* Set the keyboard backlight state */ 619 /* Set the keyboard backlight state */
616 state = brightness ? 1 : 0; 620 state = brightness ? 1 : 0;
@@ -640,7 +644,7 @@ static int toshiba_touchpad_set(struct toshiba_acpi_dev *dev, u32 state)
640 return -ENODEV; 644 return -ENODEV;
641 } 645 }
642 646
643 return 0; 647 return result == TOS_SUCCESS ? 0 : -EIO;
644} 648}
645 649
646static int toshiba_touchpad_get(struct toshiba_acpi_dev *dev, u32 *state) 650static int toshiba_touchpad_get(struct toshiba_acpi_dev *dev, u32 *state)
@@ -659,7 +663,7 @@ static int toshiba_touchpad_get(struct toshiba_acpi_dev *dev, u32 *state)
659 return -ENODEV; 663 return -ENODEV;
660 } 664 }
661 665
662 return 0; 666 return result == TOS_SUCCESS ? 0 : -EIO;
663} 667}
664 668
665/* Eco Mode support */ 669/* Eco Mode support */
@@ -709,6 +713,8 @@ toshiba_eco_mode_get_status(struct led_classdev *cdev)
709 if (ACPI_FAILURE(status) || out[0] == TOS_INPUT_DATA_ERROR) { 713 if (ACPI_FAILURE(status) || out[0] == TOS_INPUT_DATA_ERROR) {
710 pr_err("ACPI call to get ECO led failed\n"); 714 pr_err("ACPI call to get ECO led failed\n");
711 return LED_OFF; 715 return LED_OFF;
716 } else if (out[0] != TOS_SUCCESS) {
717 return LED_OFF;
712 } 718 }
713 719
714 return out[2] ? LED_FULL : LED_OFF; 720 return out[2] ? LED_FULL : LED_OFF;
@@ -769,12 +775,15 @@ static int toshiba_accelerometer_get(struct toshiba_acpi_dev *dev,
769 if (ACPI_FAILURE(status) || out[0] == TOS_INPUT_DATA_ERROR) { 775 if (ACPI_FAILURE(status) || out[0] == TOS_INPUT_DATA_ERROR) {
770 pr_err("ACPI call to query the accelerometer failed\n"); 776 pr_err("ACPI call to query the accelerometer failed\n");
771 return -EIO; 777 return -EIO;
778 } else if (out[0] == TOS_NOT_SUPPORTED) {
779 return -ENODEV;
780 } else if (out[0] == TOS_SUCCESS) {
781 *xy = out[2];
782 *z = out[4];
783 return 0;
772 } 784 }
773 785
774 *xy = out[2]; 786 return -EIO;
775 *z = out[4];
776
777 return 0;
778} 787}
779 788
780/* Sleep (Charge and Music) utilities support */ 789/* Sleep (Charge and Music) utilities support */
@@ -835,7 +844,7 @@ static int toshiba_usb_sleep_charge_get(struct toshiba_acpi_dev *dev,
835 return -EIO; 844 return -EIO;
836 } 845 }
837 846
838 return 0; 847 return result == TOS_SUCCESS ? 0 : -EIO;
839} 848}
840 849
841static int toshiba_usb_sleep_charge_set(struct toshiba_acpi_dev *dev, 850static int toshiba_usb_sleep_charge_set(struct toshiba_acpi_dev *dev,
@@ -857,7 +866,7 @@ static int toshiba_usb_sleep_charge_set(struct toshiba_acpi_dev *dev,
857 return -EIO; 866 return -EIO;
858 } 867 }
859 868
860 return 0; 869 return result == TOS_SUCCESS ? 0 : -EIO;
861} 870}
862 871
863static int toshiba_sleep_functions_status_get(struct toshiba_acpi_dev *dev, 872static int toshiba_sleep_functions_status_get(struct toshiba_acpi_dev *dev,
@@ -880,11 +889,12 @@ static int toshiba_sleep_functions_status_get(struct toshiba_acpi_dev *dev,
880 return -ENODEV; 889 return -ENODEV;
881 } else if (out[0] == TOS_INPUT_DATA_ERROR) { 890 } else if (out[0] == TOS_INPUT_DATA_ERROR) {
882 return -EIO; 891 return -EIO;
892 } else if (out[0] == TOS_SUCCESS) {
893 *mode = out[2];
894 return 0;
883 } 895 }
884 896
885 *mode = out[2]; 897 return -EIO;
886
887 return 0;
888} 898}
889 899
890static int toshiba_sleep_functions_status_set(struct toshiba_acpi_dev *dev, 900static int toshiba_sleep_functions_status_set(struct toshiba_acpi_dev *dev,
@@ -910,7 +920,7 @@ static int toshiba_sleep_functions_status_set(struct toshiba_acpi_dev *dev,
910 return -EIO; 920 return -EIO;
911 } 921 }
912 922
913 return 0; 923 return out[0] == TOS_SUCCESS ? 0 : -EIO;
914} 924}
915 925
916static int toshiba_usb_rapid_charge_get(struct toshiba_acpi_dev *dev, 926static int toshiba_usb_rapid_charge_get(struct toshiba_acpi_dev *dev,
@@ -932,11 +942,12 @@ static int toshiba_usb_rapid_charge_get(struct toshiba_acpi_dev *dev,
932 } else if (out[0] == TOS_NOT_SUPPORTED || 942 } else if (out[0] == TOS_NOT_SUPPORTED ||
933 out[0] == TOS_INPUT_DATA_ERROR) { 943 out[0] == TOS_INPUT_DATA_ERROR) {
934 return -ENODEV; 944 return -ENODEV;
945 } else if (out[0] == TOS_SUCCESS || out[0] == TOS_SUCCESS2) {
946 *state = out[2];
947 return 0;
935 } 948 }
936 949
937 *state = out[2]; 950 return -EIO;
938
939 return 0;
940} 951}
941 952
942static int toshiba_usb_rapid_charge_set(struct toshiba_acpi_dev *dev, 953static int toshiba_usb_rapid_charge_set(struct toshiba_acpi_dev *dev,
@@ -962,7 +973,7 @@ static int toshiba_usb_rapid_charge_set(struct toshiba_acpi_dev *dev,
962 return -EIO; 973 return -EIO;
963 } 974 }
964 975
965 return 0; 976 return (out[0] == TOS_SUCCESS || out[0] == TOS_SUCCESS2) ? 0 : -EIO;
966} 977}
967 978
968static int toshiba_usb_sleep_music_get(struct toshiba_acpi_dev *dev, u32 *state) 979static int toshiba_usb_sleep_music_get(struct toshiba_acpi_dev *dev, u32 *state)
@@ -983,7 +994,7 @@ static int toshiba_usb_sleep_music_get(struct toshiba_acpi_dev *dev, u32 *state)
983 return -EIO; 994 return -EIO;
984 } 995 }
985 996
986 return 0; 997 return result = TOS_SUCCESS ? 0 : -EIO;
987} 998}
988 999
989static int toshiba_usb_sleep_music_set(struct toshiba_acpi_dev *dev, u32 state) 1000static int toshiba_usb_sleep_music_set(struct toshiba_acpi_dev *dev, u32 state)
@@ -1004,7 +1015,7 @@ static int toshiba_usb_sleep_music_set(struct toshiba_acpi_dev *dev, u32 state)
1004 return -EIO; 1015 return -EIO;
1005 } 1016 }
1006 1017
1007 return 0; 1018 return result == TOS_SUCCESS ? 0 : -EIO;
1008} 1019}
1009 1020
1010/* Keyboard function keys */ 1021/* Keyboard function keys */
@@ -1024,7 +1035,7 @@ static int toshiba_function_keys_get(struct toshiba_acpi_dev *dev, u32 *mode)
1024 return -ENODEV; 1035 return -ENODEV;
1025 } 1036 }
1026 1037
1027 return 0; 1038 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO;
1028} 1039}
1029 1040
1030static int toshiba_function_keys_set(struct toshiba_acpi_dev *dev, u32 mode) 1041static int toshiba_function_keys_set(struct toshiba_acpi_dev *dev, u32 mode)
@@ -1043,7 +1054,7 @@ static int toshiba_function_keys_set(struct toshiba_acpi_dev *dev, u32 mode)
1043 return -ENODEV; 1054 return -ENODEV;
1044 } 1055 }
1045 1056
1046 return 0; 1057 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO;
1047} 1058}
1048 1059
1049/* Panel Power ON */ 1060/* Panel Power ON */
@@ -1065,7 +1076,7 @@ static int toshiba_panel_power_on_get(struct toshiba_acpi_dev *dev, u32 *state)
1065 return -EIO; 1076 return -EIO;
1066 } 1077 }
1067 1078
1068 return 0; 1079 return result == TOS_SUCCESS ? 0 : -EIO;
1069} 1080}
1070 1081
1071static int toshiba_panel_power_on_set(struct toshiba_acpi_dev *dev, u32 state) 1082static int toshiba_panel_power_on_set(struct toshiba_acpi_dev *dev, u32 state)
@@ -1086,7 +1097,7 @@ static int toshiba_panel_power_on_set(struct toshiba_acpi_dev *dev, u32 state)
1086 return -EIO; 1097 return -EIO;
1087 } 1098 }
1088 1099
1089 return 0; 1100 return result == TOS_SUCCESS ? 0 : -EIO;
1090} 1101}
1091 1102
1092/* USB Three */ 1103/* USB Three */
@@ -1108,7 +1119,7 @@ static int toshiba_usb_three_get(struct toshiba_acpi_dev *dev, u32 *state)
1108 return -EIO; 1119 return -EIO;
1109 } 1120 }
1110 1121
1111 return 0; 1122 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO;
1112} 1123}
1113 1124
1114static int toshiba_usb_three_set(struct toshiba_acpi_dev *dev, u32 state) 1125static int toshiba_usb_three_set(struct toshiba_acpi_dev *dev, u32 state)
@@ -1129,7 +1140,7 @@ static int toshiba_usb_three_set(struct toshiba_acpi_dev *dev, u32 state)
1129 return -EIO; 1140 return -EIO;
1130 } 1141 }
1131 1142
1132 return 0; 1143 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO;
1133} 1144}
1134 1145
1135/* Hotkey Event type */ 1146/* Hotkey Event type */
@@ -1146,26 +1157,37 @@ static int toshiba_hotkey_event_type_get(struct toshiba_acpi_dev *dev,
1146 return -EIO; 1157 return -EIO;
1147 } else if (out[0] == TOS_NOT_SUPPORTED) { 1158 } else if (out[0] == TOS_NOT_SUPPORTED) {
1148 return -ENODEV; 1159 return -ENODEV;
1160 } else if (out[0] == TOS_SUCCESS) {
1161 *type = out[3];
1162 return 0;
1149 } 1163 }
1150 1164
1151 *type = out[3]; 1165 return -EIO;
1152
1153 return 0;
1154} 1166}
1155 1167
1156/* Transflective Backlight */ 1168/* Transflective Backlight */
1157static int get_tr_backlight_status(struct toshiba_acpi_dev *dev, u32 *status) 1169static int get_tr_backlight_status(struct toshiba_acpi_dev *dev, u32 *status)
1158{ 1170{
1159 u32 hci_result = hci_read(dev, HCI_TR_BACKLIGHT, status); 1171 u32 result = hci_read(dev, HCI_TR_BACKLIGHT, status);
1172
1173 if (result == TOS_FAILURE)
1174 pr_err("ACPI call to get Transflective Backlight failed\n");
1175 else if (result == TOS_NOT_SUPPORTED)
1176 return -ENODEV;
1160 1177
1161 return hci_result == TOS_SUCCESS ? 0 : -EIO; 1178 return result == TOS_SUCCESS ? 0 : -EIO;
1162} 1179}
1163 1180
1164static int set_tr_backlight_status(struct toshiba_acpi_dev *dev, u32 status) 1181static int set_tr_backlight_status(struct toshiba_acpi_dev *dev, u32 status)
1165{ 1182{
1166 u32 hci_result = hci_write(dev, HCI_TR_BACKLIGHT, !status); 1183 u32 result = hci_write(dev, HCI_TR_BACKLIGHT, !status);
1184
1185 if (result == TOS_FAILURE)
1186 pr_err("ACPI call to set Transflective Backlight failed\n");
1187 else if (result == TOS_NOT_SUPPORTED)
1188 return -ENODEV;
1167 1189
1168 return hci_result == TOS_SUCCESS ? 0 : -EIO; 1190 return result == TOS_SUCCESS ? 0 : -EIO;
1169} 1191}
1170 1192
1171static struct proc_dir_entry *toshiba_proc_dir; 1193static struct proc_dir_entry *toshiba_proc_dir;
@@ -1173,7 +1195,7 @@ static struct proc_dir_entry *toshiba_proc_dir;
1173/* LCD Brightness */ 1195/* LCD Brightness */
1174static int __get_lcd_brightness(struct toshiba_acpi_dev *dev) 1196static int __get_lcd_brightness(struct toshiba_acpi_dev *dev)
1175{ 1197{
1176 u32 hci_result; 1198 u32 result;
1177 u32 value; 1199 u32 value;
1178 int brightness = 0; 1200 int brightness = 0;
1179 1201
@@ -1187,8 +1209,12 @@ static int __get_lcd_brightness(struct toshiba_acpi_dev *dev)
1187 brightness++; 1209 brightness++;
1188 } 1210 }
1189 1211
1190 hci_result = hci_read(dev, HCI_LCD_BRIGHTNESS, &value); 1212 result = hci_read(dev, HCI_LCD_BRIGHTNESS, &value);
1191 if (hci_result == TOS_SUCCESS) 1213 if (result == TOS_FAILURE)
1214 pr_err("ACPI call to get LCD Brightness failed\n");
1215 else if (result == TOS_NOT_SUPPORTED)
1216 return -ENODEV;
1217 if (result == TOS_SUCCESS)
1192 return brightness + (value >> HCI_LCD_BRIGHTNESS_SHIFT); 1218 return brightness + (value >> HCI_LCD_BRIGHTNESS_SHIFT);
1193 1219
1194 return -EIO; 1220 return -EIO;
@@ -1204,8 +1230,8 @@ static int get_lcd_brightness(struct backlight_device *bd)
1204static int lcd_proc_show(struct seq_file *m, void *v) 1230static int lcd_proc_show(struct seq_file *m, void *v)
1205{ 1231{
1206 struct toshiba_acpi_dev *dev = m->private; 1232 struct toshiba_acpi_dev *dev = m->private;
1207 int value;
1208 int levels; 1233 int levels;
1234 int value;
1209 1235
1210 if (!dev->backlight_dev) 1236 if (!dev->backlight_dev)
1211 return -ENODEV; 1237 return -ENODEV;
@@ -1219,6 +1245,7 @@ static int lcd_proc_show(struct seq_file *m, void *v)
1219 } 1245 }
1220 1246
1221 pr_err("Error reading LCD brightness\n"); 1247 pr_err("Error reading LCD brightness\n");
1248
1222 return -EIO; 1249 return -EIO;
1223} 1250}
1224 1251
@@ -1229,7 +1256,7 @@ static int lcd_proc_open(struct inode *inode, struct file *file)
1229 1256
1230static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value) 1257static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value)
1231{ 1258{
1232 u32 hci_result; 1259 u32 result;
1233 1260
1234 if (dev->tr_backlight_supported) { 1261 if (dev->tr_backlight_supported) {
1235 int ret = set_tr_backlight_status(dev, !value); 1262 int ret = set_tr_backlight_status(dev, !value);
@@ -1241,8 +1268,13 @@ static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value)
1241 } 1268 }
1242 1269
1243 value = value << HCI_LCD_BRIGHTNESS_SHIFT; 1270 value = value << HCI_LCD_BRIGHTNESS_SHIFT;
1244 hci_result = hci_write(dev, HCI_LCD_BRIGHTNESS, value); 1271 result = hci_write(dev, HCI_LCD_BRIGHTNESS, value);
1245 return hci_result == TOS_SUCCESS ? 0 : -EIO; 1272 if (result == TOS_FAILURE)
1273 pr_err("ACPI call to set LCD Brightness failed\n");
1274 else if (result == TOS_NOT_SUPPORTED)
1275 return -ENODEV;
1276
1277 return result == TOS_SUCCESS ? 0 : -EIO;
1246} 1278}
1247 1279
1248static int set_lcd_status(struct backlight_device *bd) 1280static int set_lcd_status(struct backlight_device *bd)
@@ -1258,24 +1290,22 @@ static ssize_t lcd_proc_write(struct file *file, const char __user *buf,
1258 struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file)); 1290 struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file));
1259 char cmd[42]; 1291 char cmd[42];
1260 size_t len; 1292 size_t len;
1261 int value;
1262 int ret;
1263 int levels = dev->backlight_dev->props.max_brightness + 1; 1293 int levels = dev->backlight_dev->props.max_brightness + 1;
1294 int value;
1264 1295
1265 len = min(count, sizeof(cmd) - 1); 1296 len = min(count, sizeof(cmd) - 1);
1266 if (copy_from_user(cmd, buf, len)) 1297 if (copy_from_user(cmd, buf, len))
1267 return -EFAULT; 1298 return -EFAULT;
1268 cmd[len] = '\0'; 1299 cmd[len] = '\0';
1269 1300
1270 if (sscanf(cmd, " brightness : %i", &value) == 1 && 1301 if (sscanf(cmd, " brightness : %i", &value) != 1 &&
1271 value >= 0 && value < levels) { 1302 value < 0 && value > levels)
1272 ret = set_lcd_brightness(dev, value); 1303 return -EINVAL;
1273 if (ret == 0) 1304
1274 ret = count; 1305 if (set_lcd_brightness(dev, value))
1275 } else { 1306 return -EIO;
1276 ret = -EINVAL; 1307
1277 } 1308 return count;
1278 return ret;
1279} 1309}
1280 1310
1281static const struct file_operations lcd_proc_fops = { 1311static const struct file_operations lcd_proc_fops = {
@@ -1287,22 +1317,25 @@ static const struct file_operations lcd_proc_fops = {
1287 .write = lcd_proc_write, 1317 .write = lcd_proc_write,
1288}; 1318};
1289 1319
1320/* Video-Out */
1290static int get_video_status(struct toshiba_acpi_dev *dev, u32 *status) 1321static int get_video_status(struct toshiba_acpi_dev *dev, u32 *status)
1291{ 1322{
1292 u32 hci_result; 1323 u32 result = hci_read(dev, HCI_VIDEO_OUT, status);
1324
1325 if (result == TOS_FAILURE)
1326 pr_err("ACPI call to get Video-Out failed\n");
1327 else if (result == TOS_NOT_SUPPORTED)
1328 return -ENODEV;
1293 1329
1294 hci_result = hci_read(dev, HCI_VIDEO_OUT, status); 1330 return result == TOS_SUCCESS ? 0 : -EIO;
1295 return hci_result == TOS_SUCCESS ? 0 : -EIO;
1296} 1331}
1297 1332
1298static int video_proc_show(struct seq_file *m, void *v) 1333static int video_proc_show(struct seq_file *m, void *v)
1299{ 1334{
1300 struct toshiba_acpi_dev *dev = m->private; 1335 struct toshiba_acpi_dev *dev = m->private;
1301 u32 value; 1336 u32 value;
1302 int ret;
1303 1337
1304 ret = get_video_status(dev, &value); 1338 if (!get_video_status(dev, &value)) {
1305 if (!ret) {
1306 int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0; 1339 int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0;
1307 int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0; 1340 int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0;
1308 int is_tv = (value & HCI_VIDEO_OUT_TV) ? 1 : 0; 1341 int is_tv = (value & HCI_VIDEO_OUT_TV) ? 1 : 0;
@@ -1310,9 +1343,10 @@ static int video_proc_show(struct seq_file *m, void *v)
1310 seq_printf(m, "lcd_out: %d\n", is_lcd); 1343 seq_printf(m, "lcd_out: %d\n", is_lcd);
1311 seq_printf(m, "crt_out: %d\n", is_crt); 1344 seq_printf(m, "crt_out: %d\n", is_crt);
1312 seq_printf(m, "tv_out: %d\n", is_tv); 1345 seq_printf(m, "tv_out: %d\n", is_tv);
1346 return 0;
1313 } 1347 }
1314 1348
1315 return ret; 1349 return -EIO;
1316} 1350}
1317 1351
1318static int video_proc_open(struct inode *inode, struct file *file) 1352static int video_proc_open(struct inode *inode, struct file *file)
@@ -1324,13 +1358,14 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf,
1324 size_t count, loff_t *pos) 1358 size_t count, loff_t *pos)
1325{ 1359{
1326 struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file)); 1360 struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file));
1327 char *cmd, *buffer; 1361 char *buffer;
1328 int ret; 1362 char *cmd;
1329 int value;
1330 int remain = count; 1363 int remain = count;
1331 int lcd_out = -1; 1364 int lcd_out = -1;
1332 int crt_out = -1; 1365 int crt_out = -1;
1333 int tv_out = -1; 1366 int tv_out = -1;
1367 int value;
1368 int ret;
1334 u32 video_out; 1369 u32 video_out;
1335 1370
1336 cmd = kmalloc(count + 1, GFP_KERNEL); 1371 cmd = kmalloc(count + 1, GFP_KERNEL);
@@ -1382,7 +1417,7 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf,
1382 ret = write_acpi_int(METHOD_VIDEO_OUT, new_video_out); 1417 ret = write_acpi_int(METHOD_VIDEO_OUT, new_video_out);
1383 } 1418 }
1384 1419
1385 return ret ? ret : count; 1420 return ret ? -EIO : count;
1386} 1421}
1387 1422
1388static const struct file_operations video_proc_fops = { 1423static const struct file_operations video_proc_fops = {
@@ -1403,10 +1438,8 @@ static int get_fan_status(struct toshiba_acpi_dev *dev, u32 *status)
1403 pr_err("ACPI call to get Fan status failed\n"); 1438 pr_err("ACPI call to get Fan status failed\n");
1404 else if (result == TOS_NOT_SUPPORTED) 1439 else if (result == TOS_NOT_SUPPORTED)
1405 return -ENODEV; 1440 return -ENODEV;
1406 else if (result == TOS_SUCCESS)
1407 return 0;
1408 1441
1409 return -EIO; 1442 return result == TOS_SUCCESS ? 0 : -EIO;
1410} 1443}
1411 1444
1412static int set_fan_status(struct toshiba_acpi_dev *dev, u32 status) 1445static int set_fan_status(struct toshiba_acpi_dev *dev, u32 status)
@@ -1417,10 +1450,8 @@ static int set_fan_status(struct toshiba_acpi_dev *dev, u32 status)
1417 pr_err("ACPI call to set Fan status failed\n"); 1450 pr_err("ACPI call to set Fan status failed\n");
1418 else if (result == TOS_NOT_SUPPORTED) 1451 else if (result == TOS_NOT_SUPPORTED)
1419 return -ENODEV; 1452 return -ENODEV;
1420 else if (result == TOS_SUCCESS)
1421 return 0;
1422 1453
1423 return -EIO; 1454 return result == TOS_SUCCESS ? 0 : -EIO;
1424} 1455}
1425 1456
1426static int fan_proc_show(struct seq_file *m, void *v) 1457static int fan_proc_show(struct seq_file *m, void *v)