diff options
author | Henrique de Moraes Holschuh <hmh@hmh.eng.br> | 2007-04-21 10:08:36 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-04-21 23:30:34 -0400 |
commit | d8fd94d9f08237ffda7e44e6825b057bf20a90e3 (patch) | |
tree | 0c0a818fd36aaa8ea708e64ac4db727df95724e3 | |
parent | 926411779287ad4f7013c9d80aa44fd131b70cd9 (diff) |
ACPI: thinkpad-acpi: use bitfields for module flags
Use a bitfield to hold boolean module-wide flags, to conserve some memory.
It is easy and it is clean, so we do it just for the heck of it even if it
saves very little space.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r-- | drivers/misc/thinkpad_acpi.c | 147 | ||||
-rw-r--r-- | drivers/misc/thinkpad_acpi.h | 28 |
2 files changed, 83 insertions, 92 deletions
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index a5efd06523dd..e2a1b63a812f 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c | |||
@@ -501,8 +501,6 @@ static struct ibm_struct thinkpad_acpi_driver_data = { | |||
501 | * Hotkey subdriver | 501 | * Hotkey subdriver |
502 | */ | 502 | */ |
503 | 503 | ||
504 | static int hotkey_supported; | ||
505 | static int hotkey_mask_supported; | ||
506 | static int hotkey_orig_status; | 504 | static int hotkey_orig_status; |
507 | static int hotkey_orig_mask; | 505 | static int hotkey_orig_mask; |
508 | 506 | ||
@@ -513,30 +511,30 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
513 | IBM_HANDLE_INIT(hkey); | 511 | IBM_HANDLE_INIT(hkey); |
514 | 512 | ||
515 | /* hotkey not supported on 570 */ | 513 | /* hotkey not supported on 570 */ |
516 | hotkey_supported = hkey_handle != NULL; | 514 | tp_features.hotkey = hkey_handle != NULL; |
517 | 515 | ||
518 | vdbg_printk(TPACPI_DBG_INIT, "hotkeys are %s\n", | 516 | vdbg_printk(TPACPI_DBG_INIT, "hotkeys are %s\n", |
519 | str_supported(hotkey_supported)); | 517 | str_supported(tp_features.hotkey)); |
520 | 518 | ||
521 | if (hotkey_supported) { | 519 | if (tp_features.hotkey) { |
522 | /* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, | 520 | /* mask not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, |
523 | A30, R30, R31, T20-22, X20-21, X22-24 */ | 521 | A30, R30, R31, T20-22, X20-21, X22-24 */ |
524 | hotkey_mask_supported = | 522 | tp_features.hotkey_mask = |
525 | acpi_evalf(hkey_handle, NULL, "DHKN", "qv"); | 523 | acpi_evalf(hkey_handle, NULL, "DHKN", "qv"); |
526 | 524 | ||
527 | vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n", | 525 | vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n", |
528 | str_supported(hotkey_mask_supported)); | 526 | str_supported(tp_features.hotkey_mask)); |
529 | 527 | ||
530 | if (!hotkey_get(&hotkey_orig_status, &hotkey_orig_mask)) | 528 | if (!hotkey_get(&hotkey_orig_status, &hotkey_orig_mask)) |
531 | return -ENODEV; | 529 | return -ENODEV; |
532 | } | 530 | } |
533 | 531 | ||
534 | return (hotkey_supported)? 0 : 1; | 532 | return (tp_features.hotkey)? 0 : 1; |
535 | } | 533 | } |
536 | 534 | ||
537 | static void hotkey_exit(void) | 535 | static void hotkey_exit(void) |
538 | { | 536 | { |
539 | if (hotkey_supported) { | 537 | if (tp_features.hotkey) { |
540 | dbg_printk(TPACPI_DBG_EXIT, "restoring original hotkey mask\n"); | 538 | dbg_printk(TPACPI_DBG_EXIT, "restoring original hotkey mask\n"); |
541 | hotkey_set(hotkey_orig_status, hotkey_orig_mask); | 539 | hotkey_set(hotkey_orig_status, hotkey_orig_mask); |
542 | } | 540 | } |
@@ -559,7 +557,7 @@ static int hotkey_get(int *status, int *mask) | |||
559 | if (!acpi_evalf(hkey_handle, status, "DHKC", "d")) | 557 | if (!acpi_evalf(hkey_handle, status, "DHKC", "d")) |
560 | return 0; | 558 | return 0; |
561 | 559 | ||
562 | if (hotkey_mask_supported) | 560 | if (tp_features.hotkey_mask) |
563 | if (!acpi_evalf(hkey_handle, mask, "DHKN", "d")) | 561 | if (!acpi_evalf(hkey_handle, mask, "DHKN", "d")) |
564 | return 0; | 562 | return 0; |
565 | 563 | ||
@@ -573,7 +571,7 @@ static int hotkey_set(int status, int mask) | |||
573 | if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", status)) | 571 | if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", status)) |
574 | return 0; | 572 | return 0; |
575 | 573 | ||
576 | if (hotkey_mask_supported) | 574 | if (tp_features.hotkey_mask) |
577 | for (i = 0; i < 32; i++) { | 575 | for (i = 0; i < 32; i++) { |
578 | int bit = ((1 << i) & mask) != 0; | 576 | int bit = ((1 << i) & mask) != 0; |
579 | if (!acpi_evalf(hkey_handle, | 577 | if (!acpi_evalf(hkey_handle, |
@@ -589,7 +587,7 @@ static int hotkey_read(char *p) | |||
589 | int status, mask; | 587 | int status, mask; |
590 | int len = 0; | 588 | int len = 0; |
591 | 589 | ||
592 | if (!hotkey_supported) { | 590 | if (!tp_features.hotkey) { |
593 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 591 | len += sprintf(p + len, "status:\t\tnot supported\n"); |
594 | return len; | 592 | return len; |
595 | } | 593 | } |
@@ -598,7 +596,7 @@ static int hotkey_read(char *p) | |||
598 | return -EIO; | 596 | return -EIO; |
599 | 597 | ||
600 | len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0)); | 598 | len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0)); |
601 | if (hotkey_mask_supported) { | 599 | if (tp_features.hotkey_mask) { |
602 | len += sprintf(p + len, "mask:\t\t0x%04x\n", mask); | 600 | len += sprintf(p + len, "mask:\t\t0x%04x\n", mask); |
603 | len += sprintf(p + len, | 601 | len += sprintf(p + len, |
604 | "commands:\tenable, disable, reset, <mask>\n"); | 602 | "commands:\tenable, disable, reset, <mask>\n"); |
@@ -616,7 +614,7 @@ static int hotkey_write(char *buf) | |||
616 | char *cmd; | 614 | char *cmd; |
617 | int do_cmd = 0; | 615 | int do_cmd = 0; |
618 | 616 | ||
619 | if (!hotkey_supported) | 617 | if (!tp_features.hotkey) |
620 | return -ENODEV; | 618 | return -ENODEV; |
621 | 619 | ||
622 | if (!hotkey_get(&status, &mask)) | 620 | if (!hotkey_get(&status, &mask)) |
@@ -660,8 +658,6 @@ static struct ibm_struct hotkey_driver_data = { | |||
660 | * Bluetooth subdriver | 658 | * Bluetooth subdriver |
661 | */ | 659 | */ |
662 | 660 | ||
663 | static int bluetooth_supported; | ||
664 | |||
665 | static int __init bluetooth_init(struct ibm_init_struct *iibm) | 661 | static int __init bluetooth_init(struct ibm_init_struct *iibm) |
666 | { | 662 | { |
667 | vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n"); | 663 | vdbg_printk(TPACPI_DBG_INIT, "initializing bluetooth subdriver\n"); |
@@ -670,20 +666,20 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm) | |||
670 | 666 | ||
671 | /* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, | 667 | /* bluetooth not supported on 570, 600e/x, 770e, 770x, A21e, A2xm/p, |
672 | G4x, R30, R31, R40e, R50e, T20-22, X20-21 */ | 668 | G4x, R30, R31, R40e, R50e, T20-22, X20-21 */ |
673 | bluetooth_supported = hkey_handle && | 669 | tp_features.bluetooth = hkey_handle && |
674 | acpi_evalf(hkey_handle, NULL, "GBDC", "qv"); | 670 | acpi_evalf(hkey_handle, NULL, "GBDC", "qv"); |
675 | 671 | ||
676 | vdbg_printk(TPACPI_DBG_INIT, "bluetooth is %s\n", | 672 | vdbg_printk(TPACPI_DBG_INIT, "bluetooth is %s\n", |
677 | str_supported(bluetooth_supported)); | 673 | str_supported(tp_features.bluetooth)); |
678 | 674 | ||
679 | return (bluetooth_supported)? 0 : 1; | 675 | return (tp_features.bluetooth)? 0 : 1; |
680 | } | 676 | } |
681 | 677 | ||
682 | static int bluetooth_status(void) | 678 | static int bluetooth_status(void) |
683 | { | 679 | { |
684 | int status; | 680 | int status; |
685 | 681 | ||
686 | if (!bluetooth_supported || | 682 | if (!tp_features.bluetooth || |
687 | !acpi_evalf(hkey_handle, &status, "GBDC", "d")) | 683 | !acpi_evalf(hkey_handle, &status, "GBDC", "d")) |
688 | status = 0; | 684 | status = 0; |
689 | 685 | ||
@@ -695,7 +691,7 @@ static int bluetooth_read(char *p) | |||
695 | int len = 0; | 691 | int len = 0; |
696 | int status = bluetooth_status(); | 692 | int status = bluetooth_status(); |
697 | 693 | ||
698 | if (!bluetooth_supported) | 694 | if (!tp_features.bluetooth) |
699 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 695 | len += sprintf(p + len, "status:\t\tnot supported\n"); |
700 | else if (!(status & 1)) | 696 | else if (!(status & 1)) |
701 | len += sprintf(p + len, "status:\t\tnot installed\n"); | 697 | len += sprintf(p + len, "status:\t\tnot installed\n"); |
@@ -713,7 +709,7 @@ static int bluetooth_write(char *buf) | |||
713 | char *cmd; | 709 | char *cmd; |
714 | int do_cmd = 0; | 710 | int do_cmd = 0; |
715 | 711 | ||
716 | if (!bluetooth_supported) | 712 | if (!tp_features.bluetooth) |
717 | return -ENODEV; | 713 | return -ENODEV; |
718 | 714 | ||
719 | while ((cmd = next_cmd(&buf))) { | 715 | while ((cmd = next_cmd(&buf))) { |
@@ -742,28 +738,27 @@ static struct ibm_struct bluetooth_driver_data = { | |||
742 | * Wan subdriver | 738 | * Wan subdriver |
743 | */ | 739 | */ |
744 | 740 | ||
745 | static int wan_supported; | ||
746 | |||
747 | static int __init wan_init(struct ibm_init_struct *iibm) | 741 | static int __init wan_init(struct ibm_init_struct *iibm) |
748 | { | 742 | { |
749 | vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n"); | 743 | vdbg_printk(TPACPI_DBG_INIT, "initializing wan subdriver\n"); |
750 | 744 | ||
751 | IBM_HANDLE_INIT(hkey); | 745 | IBM_HANDLE_INIT(hkey); |
752 | 746 | ||
753 | wan_supported = hkey_handle && | 747 | tp_features.wan = hkey_handle && |
754 | acpi_evalf(hkey_handle, NULL, "GWAN", "qv"); | 748 | acpi_evalf(hkey_handle, NULL, "GWAN", "qv"); |
755 | 749 | ||
756 | vdbg_printk(TPACPI_DBG_INIT, "wan is %s\n", | 750 | vdbg_printk(TPACPI_DBG_INIT, "wan is %s\n", |
757 | str_supported(wan_supported)); | 751 | str_supported(tp_features.wan)); |
758 | 752 | ||
759 | return (wan_supported)? 0 : 1; | 753 | return (tp_features.wan)? 0 : 1; |
760 | } | 754 | } |
761 | 755 | ||
762 | static int wan_status(void) | 756 | static int wan_status(void) |
763 | { | 757 | { |
764 | int status; | 758 | int status; |
765 | 759 | ||
766 | if (!wan_supported || !acpi_evalf(hkey_handle, &status, "GWAN", "d")) | 760 | if (!tp_features.wan || |
761 | !acpi_evalf(hkey_handle, &status, "GWAN", "d")) | ||
767 | status = 0; | 762 | status = 0; |
768 | 763 | ||
769 | return status; | 764 | return status; |
@@ -774,7 +769,7 @@ static int wan_read(char *p) | |||
774 | int len = 0; | 769 | int len = 0; |
775 | int status = wan_status(); | 770 | int status = wan_status(); |
776 | 771 | ||
777 | if (!wan_supported) | 772 | if (!tp_features.wan) |
778 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 773 | len += sprintf(p + len, "status:\t\tnot supported\n"); |
779 | else if (!(status & 1)) | 774 | else if (!(status & 1)) |
780 | len += sprintf(p + len, "status:\t\tnot installed\n"); | 775 | len += sprintf(p + len, "status:\t\tnot installed\n"); |
@@ -792,7 +787,7 @@ static int wan_write(char *buf) | |||
792 | char *cmd; | 787 | char *cmd; |
793 | int do_cmd = 0; | 788 | int do_cmd = 0; |
794 | 789 | ||
795 | if (!wan_supported) | 790 | if (!tp_features.wan) |
796 | return -ENODEV; | 791 | return -ENODEV; |
797 | 792 | ||
798 | while ((cmd = next_cmd(&buf))) { | 793 | while ((cmd = next_cmd(&buf))) { |
@@ -1051,9 +1046,6 @@ static struct ibm_struct video_driver_data = { | |||
1051 | * Light (thinklight) subdriver | 1046 | * Light (thinklight) subdriver |
1052 | */ | 1047 | */ |
1053 | 1048 | ||
1054 | static int light_supported; | ||
1055 | static int light_status_supported; | ||
1056 | |||
1057 | IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */ | 1049 | IBM_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */ |
1058 | IBM_HANDLE(ledb, ec, "LEDB"); /* G4x */ | 1050 | IBM_HANDLE(ledb, ec, "LEDB"); /* G4x */ |
1059 | 1051 | ||
@@ -1066,18 +1058,18 @@ static int __init light_init(struct ibm_init_struct *iibm) | |||
1066 | IBM_HANDLE_INIT(cmos); | 1058 | IBM_HANDLE_INIT(cmos); |
1067 | 1059 | ||
1068 | /* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */ | 1060 | /* light not supported on 570, 600e/x, 770e, 770x, G4x, R30, R31 */ |
1069 | light_supported = (cmos_handle || lght_handle) && !ledb_handle; | 1061 | tp_features.light = (cmos_handle || lght_handle) && !ledb_handle; |
1070 | 1062 | ||
1071 | if (light_supported) | 1063 | if (tp_features.light) |
1072 | /* light status not supported on | 1064 | /* light status not supported on |
1073 | 570, 600e/x, 770e, 770x, G4x, R30, R31, R32, X20 */ | 1065 | 570, 600e/x, 770e, 770x, G4x, R30, R31, R32, X20 */ |
1074 | light_status_supported = acpi_evalf(ec_handle, NULL, | 1066 | tp_features.light_status = |
1075 | "KBLT", "qv"); | 1067 | acpi_evalf(ec_handle, NULL, "KBLT", "qv"); |
1076 | 1068 | ||
1077 | vdbg_printk(TPACPI_DBG_INIT, "light is %s\n", | 1069 | vdbg_printk(TPACPI_DBG_INIT, "light is %s\n", |
1078 | str_supported(light_supported)); | 1070 | str_supported(tp_features.light)); |
1079 | 1071 | ||
1080 | return (light_supported)? 0 : 1; | 1072 | return (tp_features.light)? 0 : 1; |
1081 | } | 1073 | } |
1082 | 1074 | ||
1083 | static int light_read(char *p) | 1075 | static int light_read(char *p) |
@@ -1085,9 +1077,9 @@ static int light_read(char *p) | |||
1085 | int len = 0; | 1077 | int len = 0; |
1086 | int status = 0; | 1078 | int status = 0; |
1087 | 1079 | ||
1088 | if (!light_supported) { | 1080 | if (!tp_features.light) { |
1089 | len += sprintf(p + len, "status:\t\tnot supported\n"); | 1081 | len += sprintf(p + len, "status:\t\tnot supported\n"); |
1090 | } else if (!light_status_supported) { | 1082 | } else if (!tp_features.light_status) { |
1091 | len += sprintf(p + len, "status:\t\tunknown\n"); | 1083 | len += sprintf(p + len, "status:\t\tunknown\n"); |
1092 | len += sprintf(p + len, "commands:\ton, off\n"); | 1084 | len += sprintf(p + len, "commands:\ton, off\n"); |
1093 | } else { | 1085 | } else { |
@@ -1106,7 +1098,7 @@ static int light_write(char *buf) | |||
1106 | char *cmd; | 1098 | char *cmd; |
1107 | int success; | 1099 | int success; |
1108 | 1100 | ||
1109 | if (!light_supported) | 1101 | if (!tp_features.light) |
1110 | return -ENODEV; | 1102 | return -ENODEV; |
1111 | 1103 | ||
1112 | while ((cmd = next_cmd(&buf))) { | 1104 | while ((cmd = next_cmd(&buf))) { |
@@ -1251,11 +1243,6 @@ static struct ibm_struct dock_driver_data[2] = { | |||
1251 | */ | 1243 | */ |
1252 | 1244 | ||
1253 | #ifdef CONFIG_THINKPAD_ACPI_BAY | 1245 | #ifdef CONFIG_THINKPAD_ACPI_BAY |
1254 | static int bay_status_supported; | ||
1255 | static int bay_status2_supported; | ||
1256 | static int bay_eject_supported; | ||
1257 | static int bay_eject2_supported; | ||
1258 | |||
1259 | IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */ | 1246 | IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */ |
1260 | "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */ | 1247 | "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */ |
1261 | "\\_SB.PCI0.SATA.SCND.MSTR", /* T60, X60, Z60 */ | 1248 | "\\_SB.PCI0.SATA.SCND.MSTR", /* T60, X60, Z60 */ |
@@ -1282,25 +1269,25 @@ static int __init bay_init(struct ibm_init_struct *iibm) | |||
1282 | if (bay2_handle) | 1269 | if (bay2_handle) |
1283 | IBM_HANDLE_INIT(bay2_ej); | 1270 | IBM_HANDLE_INIT(bay2_ej); |
1284 | 1271 | ||
1285 | bay_status_supported = bay_handle && | 1272 | tp_features.bay_status = bay_handle && |
1286 | acpi_evalf(bay_handle, NULL, "_STA", "qv"); | 1273 | acpi_evalf(bay_handle, NULL, "_STA", "qv"); |
1287 | bay_status2_supported = bay2_handle && | 1274 | tp_features.bay_status2 = bay2_handle && |
1288 | acpi_evalf(bay2_handle, NULL, "_STA", "qv"); | 1275 | acpi_evalf(bay2_handle, NULL, "_STA", "qv"); |
1289 | 1276 | ||
1290 | bay_eject_supported = bay_handle && bay_ej_handle && | 1277 | tp_features.bay_eject = bay_handle && bay_ej_handle && |
1291 | (strlencmp(bay_ej_path, "_EJ0") == 0 || experimental); | 1278 | (strlencmp(bay_ej_path, "_EJ0") == 0 || experimental); |
1292 | bay_eject2_supported = bay2_handle && bay2_ej_handle && | 1279 | tp_features.bay_eject2 = bay2_handle && bay2_ej_handle && |
1293 | (strlencmp(bay2_ej_path, "_EJ0") == 0 || experimental); | 1280 | (strlencmp(bay2_ej_path, "_EJ0") == 0 || experimental); |
1294 | 1281 | ||
1295 | vdbg_printk(TPACPI_DBG_INIT, | 1282 | vdbg_printk(TPACPI_DBG_INIT, |
1296 | "bay 1: status %s, eject %s; bay 2: status %s, eject %s\n", | 1283 | "bay 1: status %s, eject %s; bay 2: status %s, eject %s\n", |
1297 | str_supported(bay_status_supported), | 1284 | str_supported(tp_features.bay_status), |
1298 | str_supported(bay_eject_supported), | 1285 | str_supported(tp_features.bay_eject), |
1299 | str_supported(bay_status2_supported), | 1286 | str_supported(tp_features.bay_status2), |
1300 | str_supported(bay_eject2_supported)); | 1287 | str_supported(tp_features.bay_eject2)); |
1301 | 1288 | ||
1302 | return (bay_status_supported || bay_eject_supported || | 1289 | return (tp_features.bay_status || tp_features.bay_eject || |
1303 | bay_status2_supported || bay_eject2_supported)? 0 : 1; | 1290 | tp_features.bay_status2 || tp_features.bay_eject2)? 0 : 1; |
1304 | } | 1291 | } |
1305 | 1292 | ||
1306 | static void bay_notify(struct ibm_struct *ibm, u32 event) | 1293 | static void bay_notify(struct ibm_struct *ibm, u32 event) |
@@ -1317,15 +1304,16 @@ static int bay_read(char *p) | |||
1317 | int occupied2 = bay_occupied(bay2); | 1304 | int occupied2 = bay_occupied(bay2); |
1318 | int eject, eject2; | 1305 | int eject, eject2; |
1319 | 1306 | ||
1320 | len += sprintf(p + len, "status:\t\t%s\n", bay_status_supported ? | 1307 | len += sprintf(p + len, "status:\t\t%s\n", |
1321 | (occupied ? "occupied" : "unoccupied") : | 1308 | tp_features.bay_status ? |
1322 | "not supported"); | 1309 | (occupied ? "occupied" : "unoccupied") : |
1323 | if (bay_status2_supported) | 1310 | "not supported"); |
1311 | if (tp_features.bay_status2) | ||
1324 | len += sprintf(p + len, "status2:\t%s\n", occupied2 ? | 1312 | len += sprintf(p + len, "status2:\t%s\n", occupied2 ? |
1325 | "occupied" : "unoccupied"); | 1313 | "occupied" : "unoccupied"); |
1326 | 1314 | ||
1327 | eject = bay_eject_supported && occupied; | 1315 | eject = tp_features.bay_eject && occupied; |
1328 | eject2 = bay_eject2_supported && occupied2; | 1316 | eject2 = tp_features.bay_eject2 && occupied2; |
1329 | 1317 | ||
1330 | if (eject && eject2) | 1318 | if (eject && eject2) |
1331 | len += sprintf(p + len, "commands:\teject, eject2\n"); | 1319 | len += sprintf(p + len, "commands:\teject, eject2\n"); |
@@ -1341,14 +1329,14 @@ static int bay_write(char *buf) | |||
1341 | { | 1329 | { |
1342 | char *cmd; | 1330 | char *cmd; |
1343 | 1331 | ||
1344 | if (!bay_eject_supported && !bay_eject2_supported) | 1332 | if (!tp_features.bay_eject && !tp_features.bay_eject2) |
1345 | return -ENODEV; | 1333 | return -ENODEV; |
1346 | 1334 | ||
1347 | while ((cmd = next_cmd(&buf))) { | 1335 | while ((cmd = next_cmd(&buf))) { |
1348 | if (bay_eject_supported && strlencmp(cmd, "eject") == 0) { | 1336 | if (tp_features.bay_eject && strlencmp(cmd, "eject") == 0) { |
1349 | if (!acpi_evalf(bay_ej_handle, NULL, NULL, "vd", 1)) | 1337 | if (!acpi_evalf(bay_ej_handle, NULL, NULL, "vd", 1)) |
1350 | return -EIO; | 1338 | return -EIO; |
1351 | } else if (bay_eject2_supported && | 1339 | } else if (tp_features.bay_eject2 && |
1352 | strlencmp(cmd, "eject2") == 0) { | 1340 | strlencmp(cmd, "eject2") == 0) { |
1353 | if (!acpi_evalf(bay2_ej_handle, NULL, NULL, "vd", 1)) | 1341 | if (!acpi_evalf(bay2_ej_handle, NULL, NULL, "vd", 1)) |
1354 | return -EIO; | 1342 | return -EIO; |
@@ -2188,7 +2176,6 @@ static enum fan_status_access_mode fan_status_access_mode; | |||
2188 | static enum fan_control_access_mode fan_control_access_mode; | 2176 | static enum fan_control_access_mode fan_control_access_mode; |
2189 | static enum fan_control_commands fan_control_commands; | 2177 | static enum fan_control_commands fan_control_commands; |
2190 | 2178 | ||
2191 | static int fan_control_status_known; | ||
2192 | static u8 fan_control_initial_status; | 2179 | static u8 fan_control_initial_status; |
2193 | 2180 | ||
2194 | static void fan_watchdog_fire(struct work_struct *ignored); | 2181 | static void fan_watchdog_fire(struct work_struct *ignored); |
@@ -2210,8 +2197,8 @@ static int __init fan_init(struct ibm_init_struct *iibm) | |||
2210 | fan_status_access_mode = TPACPI_FAN_NONE; | 2197 | fan_status_access_mode = TPACPI_FAN_NONE; |
2211 | fan_control_access_mode = TPACPI_FAN_WR_NONE; | 2198 | fan_control_access_mode = TPACPI_FAN_WR_NONE; |
2212 | fan_control_commands = 0; | 2199 | fan_control_commands = 0; |
2213 | fan_control_status_known = 1; | ||
2214 | fan_watchdog_maxinterval = 0; | 2200 | fan_watchdog_maxinterval = 0; |
2201 | tp_features.fan_ctrl_status_undef = 0; | ||
2215 | 2202 | ||
2216 | IBM_HANDLE_INIT(fans); | 2203 | IBM_HANDLE_INIT(fans); |
2217 | IBM_HANDLE_INIT(gfan); | 2204 | IBM_HANDLE_INIT(gfan); |
@@ -2248,7 +2235,7 @@ static int __init fan_init(struct ibm_init_struct *iibm) | |||
2248 | "fan_init: initial fan status is " | 2235 | "fan_init: initial fan status is " |
2249 | "unknown, assuming it is in auto " | 2236 | "unknown, assuming it is in auto " |
2250 | "mode\n"); | 2237 | "mode\n"); |
2251 | fan_control_status_known = 0; | 2238 | tp_features.fan_ctrl_status_undef = 1; |
2252 | } | 2239 | } |
2253 | } else { | 2240 | } else { |
2254 | printk(IBM_ERR | 2241 | printk(IBM_ERR |
@@ -2411,7 +2398,7 @@ static int fan_set_level(int level) | |||
2411 | if (!acpi_ec_write(fan_status_offset, level)) | 2398 | if (!acpi_ec_write(fan_status_offset, level)) |
2412 | return -EIO; | 2399 | return -EIO; |
2413 | else | 2400 | else |
2414 | fan_control_status_known = 1; | 2401 | tp_features.fan_ctrl_status_undef = 0; |
2415 | break; | 2402 | break; |
2416 | 2403 | ||
2417 | default: | 2404 | default: |
@@ -2438,7 +2425,7 @@ static int fan_set_enable(void) | |||
2438 | if (!acpi_ec_write(fan_status_offset, s)) | 2425 | if (!acpi_ec_write(fan_status_offset, s)) |
2439 | return -EIO; | 2426 | return -EIO; |
2440 | else | 2427 | else |
2441 | fan_control_status_known = 1; | 2428 | tp_features.fan_ctrl_status_undef = 0; |
2442 | break; | 2429 | break; |
2443 | 2430 | ||
2444 | case TPACPI_FAN_WR_ACPI_SFAN: | 2431 | case TPACPI_FAN_WR_ACPI_SFAN: |
@@ -2469,7 +2456,7 @@ static int fan_set_disable(void) | |||
2469 | if (!acpi_ec_write(fan_status_offset, 0x00)) | 2456 | if (!acpi_ec_write(fan_status_offset, 0x00)) |
2470 | return -EIO; | 2457 | return -EIO; |
2471 | else | 2458 | else |
2472 | fan_control_status_known = 1; | 2459 | tp_features.fan_ctrl_status_undef = 0; |
2473 | break; | 2460 | break; |
2474 | 2461 | ||
2475 | case TPACPI_FAN_WR_ACPI_SFAN: | 2462 | case TPACPI_FAN_WR_ACPI_SFAN: |
@@ -2524,9 +2511,9 @@ static int fan_read(char *p) | |||
2524 | if ((rc = fan_get_status(&status)) < 0) | 2511 | if ((rc = fan_get_status(&status)) < 0) |
2525 | return rc; | 2512 | return rc; |
2526 | 2513 | ||
2527 | if (unlikely(!fan_control_status_known)) { | 2514 | if (unlikely(tp_features.fan_ctrl_status_undef)) { |
2528 | if (status != fan_control_initial_status) | 2515 | if (status != fan_control_initial_status) |
2529 | fan_control_status_known = 1; | 2516 | tp_features.fan_ctrl_status_undef = 0; |
2530 | else | 2517 | else |
2531 | /* Return most likely status. In fact, it | 2518 | /* Return most likely status. In fact, it |
2532 | * might be the only possible status */ | 2519 | * might be the only possible status */ |
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h index 8b72061d8f0e..4d3ab4015ff2 100644 --- a/drivers/misc/thinkpad_acpi.h +++ b/drivers/misc/thinkpad_acpi.h | |||
@@ -173,6 +173,22 @@ struct ibm_init_struct { | |||
173 | struct ibm_struct *data; | 173 | struct ibm_struct *data; |
174 | }; | 174 | }; |
175 | 175 | ||
176 | static struct { | ||
177 | #ifdef CONFIG_THINKPAD_ACPI_BAY | ||
178 | u16 bay_status:1; | ||
179 | u16 bay_eject:1; | ||
180 | u16 bay_status2:1; | ||
181 | u16 bay_eject2:1; | ||
182 | #endif | ||
183 | u16 bluetooth:1; | ||
184 | u16 hotkey:1; | ||
185 | u16 hotkey_mask:1; | ||
186 | u16 light:1; | ||
187 | u16 light_status:1; | ||
188 | u16 wan:1; | ||
189 | u16 fan_ctrl_status_undef:1; | ||
190 | } tp_features; | ||
191 | |||
176 | static struct list_head tpacpi_all_drivers; | 192 | static struct list_head tpacpi_all_drivers; |
177 | 193 | ||
178 | static struct ibm_init_struct ibms_init[]; | 194 | static struct ibm_init_struct ibms_init[]; |
@@ -193,9 +209,6 @@ static int thinkpad_acpi_driver_read(char *p); | |||
193 | */ | 209 | */ |
194 | 210 | ||
195 | #ifdef CONFIG_THINKPAD_ACPI_BAY | 211 | #ifdef CONFIG_THINKPAD_ACPI_BAY |
196 | static int bay_status_supported, bay_eject_supported; | ||
197 | static int bay_status2_supported, bay_eject2_supported; | ||
198 | |||
199 | static acpi_handle bay_handle, bay_ej_handle; | 212 | static acpi_handle bay_handle, bay_ej_handle; |
200 | static acpi_handle bay2_handle, bay2_ej_handle; | 213 | static acpi_handle bay2_handle, bay2_ej_handle; |
201 | 214 | ||
@@ -220,8 +233,6 @@ static int beep_write(char *buf); | |||
220 | * Bluetooth subdriver | 233 | * Bluetooth subdriver |
221 | */ | 234 | */ |
222 | 235 | ||
223 | static int bluetooth_supported; | ||
224 | |||
225 | static int bluetooth_init(struct ibm_init_struct *iibm); | 236 | static int bluetooth_init(struct ibm_init_struct *iibm); |
226 | static int bluetooth_status(void); | 237 | static int bluetooth_status(void); |
227 | static int bluetooth_read(char *p); | 238 | static int bluetooth_read(char *p); |
@@ -311,7 +322,6 @@ enum fan_control_commands { | |||
311 | static enum fan_status_access_mode fan_status_access_mode; | 322 | static enum fan_status_access_mode fan_status_access_mode; |
312 | static enum fan_control_access_mode fan_control_access_mode; | 323 | static enum fan_control_access_mode fan_control_access_mode; |
313 | static enum fan_control_commands fan_control_commands; | 324 | static enum fan_control_commands fan_control_commands; |
314 | static int fan_control_status_known; | ||
315 | static u8 fan_control_initial_status; | 325 | static u8 fan_control_initial_status; |
316 | static int fan_watchdog_maxinterval; | 326 | static int fan_watchdog_maxinterval; |
317 | 327 | ||
@@ -340,8 +350,6 @@ static int fan_write_cmd_watchdog(const char *cmd, int *rc); | |||
340 | * Hotkey subdriver | 350 | * Hotkey subdriver |
341 | */ | 351 | */ |
342 | 352 | ||
343 | static int hotkey_supported; | ||
344 | static int hotkey_mask_supported; | ||
345 | static int hotkey_orig_status; | 353 | static int hotkey_orig_status; |
346 | static int hotkey_orig_mask; | 354 | static int hotkey_orig_mask; |
347 | 355 | ||
@@ -382,8 +390,6 @@ static int led_write(char *buf); | |||
382 | * Light (thinklight) subdriver | 390 | * Light (thinklight) subdriver |
383 | */ | 391 | */ |
384 | 392 | ||
385 | static int light_supported; | ||
386 | static int light_status_supported; | ||
387 | static acpi_handle lght_handle, ledb_handle; | 393 | static acpi_handle lght_handle, ledb_handle; |
388 | 394 | ||
389 | static int light_init(struct ibm_init_struct *iibm); | 395 | static int light_init(struct ibm_init_struct *iibm); |
@@ -453,8 +459,6 @@ static int volume_write(char *buf); | |||
453 | * Wan subdriver | 459 | * Wan subdriver |
454 | */ | 460 | */ |
455 | 461 | ||
456 | static int wan_supported; | ||
457 | |||
458 | static int wan_init(struct ibm_init_struct *iibm); | 462 | static int wan_init(struct ibm_init_struct *iibm); |
459 | static int wan_status(void); | 463 | static int wan_status(void); |
460 | static int wan_read(char *p); | 464 | static int wan_read(char *p); |