Add patches accepted for 2.6.27-rc1
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / releases / upstream / 2.6.27-rc1 / 0003-ACPI-thinkpad-acpi-prepare-for-bluetooth-and-wwan.patch
blob39fde4eb0552493afab81c0e7b90ee352258d7a3
1 From 07431ec82bf9dc74b470a1d820b41c92c4d86e6f Mon Sep 17 00:00:00 2001
2 From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
3 Date: Mon, 21 Jul 2008 09:15:50 -0300
4 Subject: ACPI: thinkpad-acpi: prepare for bluetooth and wwan rfkill support
6 Get rid of some forward definitions by moving code around, this will make
7 the rfkill conversion of wwan and bluetooth a bit cleaner.
9 Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
10 ---
11 drivers/misc/thinkpad_acpi.c | 154 ++++++++++++++++++++----------------------
12 1 files changed, 74 insertions(+), 80 deletions(-)
14 diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
15 index 9179f23..743a4d6 100644
16 --- a/drivers/misc/thinkpad_acpi.c
17 +++ b/drivers/misc/thinkpad_acpi.c
18 @@ -2581,8 +2581,37 @@ enum {
19 TP_ACPI_BLUETOOTH_UNK = 0x04, /* unknown function */
22 -static int bluetooth_get_radiosw(void);
23 -static int bluetooth_set_radiosw(int radio_on);
24 +static int bluetooth_get_radiosw(void)
26 + int status;
28 + if (!tp_features.bluetooth)
29 + return -ENODEV;
31 + if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
32 + return -EIO;
34 + return (status & TP_ACPI_BLUETOOTH_RADIOSSW) != 0;
37 +static int bluetooth_set_radiosw(int radio_on)
39 + int status;
41 + if (!tp_features.bluetooth)
42 + return -ENODEV;
44 + if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
45 + return -EIO;
46 + if (radio_on)
47 + status |= TP_ACPI_BLUETOOTH_RADIOSSW;
48 + else
49 + status &= ~TP_ACPI_BLUETOOTH_RADIOSSW;
50 + if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
51 + return -EIO;
53 + return 0;
56 /* sysfs bluetooth enable ---------------------------------------------- */
57 static ssize_t bluetooth_enable_show(struct device *dev,
58 @@ -2628,6 +2657,12 @@ static const struct attribute_group bluetooth_attr_group = {
59 .attrs = bluetooth_attributes,
62 +static void bluetooth_exit(void)
64 + sysfs_remove_group(&tpacpi_pdev->dev.kobj,
65 + &bluetooth_attr_group);
68 static int __init bluetooth_init(struct ibm_init_struct *iibm)
70 int res;
71 @@ -2664,44 +2699,6 @@ static int __init bluetooth_init(struct ibm_init_struct *iibm)
72 return (tp_features.bluetooth)? 0 : 1;
75 -static void bluetooth_exit(void)
77 - sysfs_remove_group(&tpacpi_pdev->dev.kobj,
78 - &bluetooth_attr_group);
81 -static int bluetooth_get_radiosw(void)
83 - int status;
85 - if (!tp_features.bluetooth)
86 - return -ENODEV;
88 - if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
89 - return -EIO;
91 - return ((status & TP_ACPI_BLUETOOTH_RADIOSSW) != 0);
94 -static int bluetooth_set_radiosw(int radio_on)
96 - int status;
98 - if (!tp_features.bluetooth)
99 - return -ENODEV;
101 - if (!acpi_evalf(hkey_handle, &status, "GBDC", "d"))
102 - return -EIO;
103 - if (radio_on)
104 - status |= TP_ACPI_BLUETOOTH_RADIOSSW;
105 - else
106 - status &= ~TP_ACPI_BLUETOOTH_RADIOSSW;
107 - if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status))
108 - return -EIO;
110 - return 0;
113 /* procfs -------------------------------------------------------------- */
114 static int bluetooth_read(char *p)
116 @@ -2756,8 +2753,37 @@ enum {
117 TP_ACPI_WANCARD_UNK = 0x04, /* unknown function */
120 -static int wan_get_radiosw(void);
121 -static int wan_set_radiosw(int radio_on);
122 +static int wan_get_radiosw(void)
124 + int status;
126 + if (!tp_features.wan)
127 + return -ENODEV;
129 + if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
130 + return -EIO;
132 + return (status & TP_ACPI_WANCARD_RADIOSSW) != 0;
135 +static int wan_set_radiosw(int radio_on)
137 + int status;
139 + if (!tp_features.wan)
140 + return -ENODEV;
142 + if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
143 + return -EIO;
144 + if (radio_on)
145 + status |= TP_ACPI_WANCARD_RADIOSSW;
146 + else
147 + status &= ~TP_ACPI_WANCARD_RADIOSSW;
148 + if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
149 + return -EIO;
151 + return 0;
154 /* sysfs wan enable ---------------------------------------------------- */
155 static ssize_t wan_enable_show(struct device *dev,
156 @@ -2803,6 +2829,12 @@ static const struct attribute_group wan_attr_group = {
157 .attrs = wan_attributes,
160 +static void wan_exit(void)
162 + sysfs_remove_group(&tpacpi_pdev->dev.kobj,
163 + &wan_attr_group);
166 static int __init wan_init(struct ibm_init_struct *iibm)
168 int res;
169 @@ -2837,44 +2869,6 @@ static int __init wan_init(struct ibm_init_struct *iibm)
170 return (tp_features.wan)? 0 : 1;
173 -static void wan_exit(void)
175 - sysfs_remove_group(&tpacpi_pdev->dev.kobj,
176 - &wan_attr_group);
179 -static int wan_get_radiosw(void)
181 - int status;
183 - if (!tp_features.wan)
184 - return -ENODEV;
186 - if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
187 - return -EIO;
189 - return ((status & TP_ACPI_WANCARD_RADIOSSW) != 0);
192 -static int wan_set_radiosw(int radio_on)
194 - int status;
196 - if (!tp_features.wan)
197 - return -ENODEV;
199 - if (!acpi_evalf(hkey_handle, &status, "GWAN", "d"))
200 - return -EIO;
201 - if (radio_on)
202 - status |= TP_ACPI_WANCARD_RADIOSSW;
203 - else
204 - status &= ~TP_ACPI_WANCARD_RADIOSSW;
205 - if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status))
206 - return -EIO;
208 - return 0;
211 /* procfs -------------------------------------------------------------- */
212 static int wan_read(char *p)
215 1.5.6.2