diff options
author | Henrique de Moraes Holschuh <hmh@hmh.eng.br> | 2007-07-18 22:45:31 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-07-21 23:38:08 -0400 |
commit | 74941a69afcc06722685d492784414ec042ab492 (patch) | |
tree | 6f97b54fc18db01504cc46dc72d7f28d7d91d5a7 /drivers/misc/thinkpad_acpi.c | |
parent | 9b010de59cb6dcab7e167dd2a0fa5d3b31447fea (diff) |
ACPI: thinkpad-acpi: export to sysfs the state of the radio slider switch
Some ThinkPad models, notably the T60 and X60, have a slider switch to
enable and disable the radios. The switch has the capability of
force-disabling the radios in hardware on most models, and it is supposed
to affect all radios (WLAN, WWAN, BlueTooth).
Export the switch state as a sysfs attribute, on ThinkPads where it is
available.
Thanks to Henning Schild for asking for this feature, and for tracking down
the EC register that holds the radio switch state.
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Henning Schild <henning@wh9.tu-dresden.de>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/misc/thinkpad_acpi.c')
-rw-r--r-- | drivers/misc/thinkpad_acpi.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c index 8c088687e954..3cf37bb55e9a 100644 --- a/drivers/misc/thinkpad_acpi.c +++ b/drivers/misc/thinkpad_acpi.c | |||
@@ -733,6 +733,13 @@ static u32 hotkey_reserved_mask = 0x00778000; | |||
733 | 733 | ||
734 | static struct attribute_set *hotkey_dev_attributes; | 734 | static struct attribute_set *hotkey_dev_attributes; |
735 | 735 | ||
736 | static int hotkey_get_wlsw(int *status) | ||
737 | { | ||
738 | if (!acpi_evalf(hkey_handle, status, "WLSW", "d")) | ||
739 | return -EIO; | ||
740 | return 0; | ||
741 | } | ||
742 | |||
736 | /* sysfs hotkey enable ------------------------------------------------- */ | 743 | /* sysfs hotkey enable ------------------------------------------------- */ |
737 | static ssize_t hotkey_enable_show(struct device *dev, | 744 | static ssize_t hotkey_enable_show(struct device *dev, |
738 | struct device_attribute *attr, | 745 | struct device_attribute *attr, |
@@ -853,6 +860,22 @@ static struct device_attribute dev_attr_hotkey_recommended_mask = | |||
853 | __ATTR(hotkey_recommended_mask, S_IRUGO, | 860 | __ATTR(hotkey_recommended_mask, S_IRUGO, |
854 | hotkey_recommended_mask_show, NULL); | 861 | hotkey_recommended_mask_show, NULL); |
855 | 862 | ||
863 | /* sysfs hotkey radio_sw ----------------------------------------------- */ | ||
864 | static ssize_t hotkey_radio_sw_show(struct device *dev, | ||
865 | struct device_attribute *attr, | ||
866 | char *buf) | ||
867 | { | ||
868 | int res, s; | ||
869 | res = hotkey_get_wlsw(&s); | ||
870 | if (res < 0) | ||
871 | return res; | ||
872 | |||
873 | return snprintf(buf, PAGE_SIZE, "%d\n", !!s); | ||
874 | } | ||
875 | |||
876 | static struct device_attribute dev_attr_hotkey_radio_sw = | ||
877 | __ATTR(hotkey_radio_sw, S_IRUGO, hotkey_radio_sw_show, NULL); | ||
878 | |||
856 | /* --------------------------------------------------------------------- */ | 879 | /* --------------------------------------------------------------------- */ |
857 | 880 | ||
858 | static struct attribute *hotkey_mask_attributes[] = { | 881 | static struct attribute *hotkey_mask_attributes[] = { |
@@ -866,6 +889,7 @@ static struct attribute *hotkey_mask_attributes[] = { | |||
866 | static int __init hotkey_init(struct ibm_init_struct *iibm) | 889 | static int __init hotkey_init(struct ibm_init_struct *iibm) |
867 | { | 890 | { |
868 | int res; | 891 | int res; |
892 | int status; | ||
869 | 893 | ||
870 | vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n"); | 894 | vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n"); |
871 | 895 | ||
@@ -879,7 +903,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
879 | str_supported(tp_features.hotkey)); | 903 | str_supported(tp_features.hotkey)); |
880 | 904 | ||
881 | if (tp_features.hotkey) { | 905 | if (tp_features.hotkey) { |
882 | hotkey_dev_attributes = create_attr_set(6, NULL); | 906 | hotkey_dev_attributes = create_attr_set(7, NULL); |
883 | if (!hotkey_dev_attributes) | 907 | if (!hotkey_dev_attributes) |
884 | return -ENOMEM; | 908 | return -ENOMEM; |
885 | res = add_to_attr_set(hotkey_dev_attributes, | 909 | res = add_to_attr_set(hotkey_dev_attributes, |
@@ -908,11 +932,21 @@ static int __init hotkey_init(struct ibm_init_struct *iibm) | |||
908 | hotkey_mask_attributes, | 932 | hotkey_mask_attributes, |
909 | ARRAY_SIZE(hotkey_mask_attributes)); | 933 | ARRAY_SIZE(hotkey_mask_attributes)); |
910 | } | 934 | } |
935 | |||
936 | /* Not all thinkpads have a hardware radio switch */ | ||
937 | if (!res && acpi_evalf(hkey_handle, &status, "WLSW", "qd")) { | ||
938 | tp_features.hotkey_wlsw = 1; | ||
939 | printk(IBM_INFO | ||
940 | "radio switch found; radios are %s\n", | ||
941 | enabled(status, 0)); | ||
942 | res = add_to_attr_set(hotkey_dev_attributes, | ||
943 | &dev_attr_hotkey_radio_sw.attr); | ||
944 | } | ||
945 | |||
911 | if (!res) | 946 | if (!res) |
912 | res = register_attr_set_with_sysfs( | 947 | res = register_attr_set_with_sysfs( |
913 | hotkey_dev_attributes, | 948 | hotkey_dev_attributes, |
914 | &tpacpi_pdev->dev.kobj); | 949 | &tpacpi_pdev->dev.kobj); |
915 | |||
916 | if (res) | 950 | if (res) |
917 | return res; | 951 | return res; |
918 | } | 952 | } |