aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/thinkpad_acpi.c
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2008-07-21 08:15:50 -0400
committerHenrique de Moraes Holschuh <hmh@hmh.eng.br>2008-07-21 08:15:50 -0400
commit07431ec82bf9dc74b470a1d820b41c92c4d86e6f (patch)
tree57bda560a5c216a0a32451657e6a2b855c181d9e /drivers/misc/thinkpad_acpi.c
parent733e27c1cc86afae2d9481838693661b3d839950 (diff)
ACPI: thinkpad-acpi: prepare for bluetooth and wwan rfkill support
Get rid of some forward definitions by moving code around, this will make the rfkill conversion of wwan and bluetooth a bit cleaner. Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Diffstat (limited to 'drivers/misc/thinkpad_acpi.c')
-rw-r--r--drivers/misc/thinkpad_acpi.c154
1 files changed, 74 insertions, 80 deletions
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 9179f2367d42..743a4d6098e8 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -2581,8 +2581,37 @@ enum {
2581 TP_ACPI_BLUETOOTH_UNK = 0x04, /* unknown function */ 2581 TP_ACPI_BLUETOOTH_UNK = 0x04, /* unknown function */
2582}; 2582};
2583 2583
2584static int bluetooth_get_radiosw(void); 2584static int bluetooth_get_radiosw(void)
2585static int bluetooth_set_radiosw(int radio_on); 2585{
2586 int status;
2587
2588 if (!tp_features.bluetooth)
2589 return -ENODEV;
2590
2591 if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
2592 return -EIO;
2593
2594 return (status & TP_ACPI_BLUETOOTH_RADIOSSW) != 0;
2595}
2596
2597static int bluetooth_set_radiosw(int radio_on)
2598{
2599 int status;
2600
2601 if (!tp_features.bluetooth)
2602 return -ENODEV;
2603
2604 if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
2605 return -EIO;
2606 if (radio_on)
2607 status |= TP_ACPI_BLUETOOTH_RADIOSSW;
2608 else
2609 status &= ~TP_ACPI_BLUETOOTH_RADIOSSW;
2610 if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
2611 return -EIO;
2612
2613 return 0;
2614}
2586 2615
2587/* sysfs bluetooth enable ---------------------------------------------- */ 2616/* sysfs bluetooth enable ---------------------------------------------- */
2588static ssize_t bluetooth_enable_show(struct device *dev, 2617static ssize_t bluetooth_enable_show(struct device *dev,
@@ -2628,6 +2657,12 @@ static const struct attribute_group bluetooth_attr_group = {
2628 .attrs = bluetooth_attributes, 2657 .attrs = bluetooth_attributes,
2629}; 2658};
2630 2659
2660static void bluetooth_exit(void)
2661{
2662 sysfs_remove_group(&tpacpi_pdev->dev.kobj,
2663 &bluetooth_attr_group);
2664}
2665
2631static int __init bluetooth_init(struct ibm_init_struct *iibm) 2666static int __init bluetooth_init(struct ibm_init_struct *iibm)
2632{ 2667{
2633 int res; 2668 int res;
@@ -2664,44 +2699,6 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
2664 return (tp_features.bluetooth)? 0 : 1; 2699 return (tp_features.bluetooth)? 0 : 1;
2665} 2700}
2666 2701
2667static void bluetooth_exit(void)
2668{
2669 sysfs_remove_group(&tpacpi_pdev->dev.kobj,
2670 &bluetooth_attr_group);
2671}
2672
2673static int bluetooth_get_radiosw(void)
2674{
2675 int status;
2676
2677 if (!tp_features.bluetooth)
2678 return -ENODEV;
2679
2680 if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
2681 return -EIO;
2682
2683 return ((status & TP_ACPI_BLUETOOTH_RADIOSSW) != 0);
2684}
2685
2686static int bluetooth_set_radiosw(int radio_on)
2687{
2688 int status;
2689
2690 if (!tp_features.bluetooth)
2691 return -ENODEV;
2692
2693 if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
2694 return -EIO;
2695 if (radio_on)
2696 status |= TP_ACPI_BLUETOOTH_RADIOSSW;
2697 else
2698 status &= ~TP_ACPI_BLUETOOTH_RADIOSSW;
2699 if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
2700 return -EIO;
2701
2702 return 0;
2703}
2704
2705/* procfs -------------------------------------------------------------- */ 2702/* procfs -------------------------------------------------------------- */
2706static int bluetooth_read(char *p) 2703static int bluetooth_read(char *p)
2707{ 2704{
@@ -2756,8 +2753,37 @@ enum {
2756 TP_ACPI_WANCARD_UNK = 0x04, /* unknown function */ 2753 TP_ACPI_WANCARD_UNK = 0x04, /* unknown function */
2757}; 2754};
2758 2755
2759static int wan_get_radiosw(void); 2756static int wan_get_radiosw(void)
2760static int wan_set_radiosw(int radio_on); 2757{
2758 int status;
2759
2760 if (!tp_features.wan)
2761 return -ENODEV;
2762
2763 if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
2764 return -EIO;
2765
2766 return (status & TP_ACPI_WANCARD_RADIOSSW) != 0;
2767}
2768
2769static int wan_set_radiosw(int radio_on)
2770{
2771 int status;
2772
2773 if (!tp_features.wan)
2774 return -ENODEV;
2775
2776 if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
2777 return -EIO;
2778 if (radio_on)
2779 status |= TP_ACPI_WANCARD_RADIOSSW;
2780 else
2781 status &= ~TP_ACPI_WANCARD_RADIOSSW;
2782 if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
2783 return -EIO;
2784
2785 return 0;
2786}
2761 2787
2762/* sysfs wan enable ---------------------------------------------------- */ 2788/* sysfs wan enable ---------------------------------------------------- */
2763static ssize_t wan_enable_show(struct device *dev, 2789static ssize_t wan_enable_show(struct device *dev,
@@ -2803,6 +2829,12 @@ static const struct attribute_group wan_attr_group = {
2803 .attrs = wan_attributes, 2829 .attrs = wan_attributes,
2804}; 2830};
2805 2831
2832static void wan_exit(void)
2833{
2834 sysfs_remove_group(&tpacpi_pdev->dev.kobj,
2835 &wan_attr_group);
2836}
2837
2806static int __init wan_init(struct ibm_init_struct *iibm) 2838static int __init wan_init(struct ibm_init_struct *iibm)
2807{ 2839{
2808 int res; 2840 int res;
@@ -2837,44 +2869,6 @@ static int __init wan_init(struct ibm_init_struct *iibm)
2837 return (tp_features.wan)? 0 : 1; 2869 return (tp_features.wan)? 0 : 1;
2838} 2870}
2839 2871
2840static void wan_exit(void)
2841{
2842 sysfs_remove_group(&tpacpi_pdev->dev.kobj,
2843 &wan_attr_group);
2844}
2845
2846static int wan_get_radiosw(void)
2847{
2848 int status;
2849
2850 if (!tp_features.wan)
2851 return -ENODEV;
2852
2853 if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
2854 return -EIO;
2855
2856 return ((status & TP_ACPI_WANCARD_RADIOSSW) != 0);
2857}
2858
2859static int wan_set_radiosw(int radio_on)
2860{
2861 int status;
2862
2863 if (!tp_features.wan)
2864 return -ENODEV;
2865
2866 if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
2867 return -EIO;
2868 if (radio_on)
2869 status |= TP_ACPI_WANCARD_RADIOSSW;
2870 else
2871 status &= ~TP_ACPI_WANCARD_RADIOSSW;
2872 if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
2873 return -EIO;
2874
2875 return 0;
2876}
2877
2878/* procfs -------------------------------------------------------------- */ 2872/* procfs -------------------------------------------------------------- */
2879static int wan_read(char *p) 2873static int wan_read(char *p)
2880{ 2874{