diff options
author | Ike Panhc <ike.pan@canonical.com> | 2010-10-01 03:39:29 -0400 |
---|---|---|
committer | Matthew Garrett <mjg@redhat.com> | 2010-10-21 09:36:50 -0400 |
commit | dfa7f6fe0ad7697ba43303bf37487987409b1b91 (patch) | |
tree | 0541fae10b2e0c56fb8e6abc94ff29eeb89e799a /drivers | |
parent | 6f8371c05e64138c305aa1b6a21857cd7a50e147 (diff) |
ideapad: use return value of _CFG to tell if device exist or not
There are several bits of the return value of _CFG shows if RF/Camera devices
exist or not.
Signed-off-by: Ike Panhc <ike.pan@canonical.com>
Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/platform/x86/ideapad_acpi.c | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/drivers/platform/x86/ideapad_acpi.c b/drivers/platform/x86/ideapad_acpi.c index bf684f421290..1f736d143022 100644 --- a/drivers/platform/x86/ideapad_acpi.c +++ b/drivers/platform/x86/ideapad_acpi.c | |||
@@ -40,13 +40,14 @@ struct ideapad_private { | |||
40 | 40 | ||
41 | static struct { | 41 | static struct { |
42 | char *name; | 42 | char *name; |
43 | int cfgbit; | ||
43 | int type; | 44 | int type; |
44 | } ideapad_rfk_data[] = { | 45 | } ideapad_rfk_data[] = { |
45 | /* camera has no rfkill */ | 46 | { "ideapad_camera", 19, NUM_RFKILL_TYPES }, |
46 | { "ideapad_wlan", RFKILL_TYPE_WLAN }, | 47 | { "ideapad_wlan", 18, RFKILL_TYPE_WLAN }, |
47 | { "ideapad_bluetooth", RFKILL_TYPE_BLUETOOTH }, | 48 | { "ideapad_bluetooth", 16, RFKILL_TYPE_BLUETOOTH }, |
48 | { "ideapad_3g", RFKILL_TYPE_WWAN }, | 49 | { "ideapad_3g", 17, RFKILL_TYPE_WWAN }, |
49 | { "ideapad_killsw", RFKILL_TYPE_WLAN } | 50 | { "ideapad_killsw", 0, RFKILL_TYPE_WLAN } |
50 | }; | 51 | }; |
51 | 52 | ||
52 | /* | 53 | /* |
@@ -158,32 +159,6 @@ static int write_ec_cmd(acpi_handle handle, int cmd, unsigned long data) | |||
158 | } | 159 | } |
159 | /* the above is ACPI helpers */ | 160 | /* the above is ACPI helpers */ |
160 | 161 | ||
161 | static int ideapad_dev_exists(int device) | ||
162 | { | ||
163 | acpi_status status; | ||
164 | union acpi_object in_param; | ||
165 | struct acpi_object_list input = { 1, &in_param }; | ||
166 | struct acpi_buffer output; | ||
167 | union acpi_object out_obj; | ||
168 | |||
169 | output.length = sizeof(out_obj); | ||
170 | output.pointer = &out_obj; | ||
171 | |||
172 | in_param.type = ACPI_TYPE_INTEGER; | ||
173 | in_param.integer.value = device + 1; | ||
174 | |||
175 | status = acpi_evaluate_object(NULL, "\\_SB_.DECN", &input, &output); | ||
176 | if (ACPI_FAILURE(status)) { | ||
177 | printk(KERN_WARNING "IdeaPAD \\_SB_.DECN method failed %d. Is this an IdeaPAD?\n", status); | ||
178 | return -ENODEV; | ||
179 | } | ||
180 | if (out_obj.type != ACPI_TYPE_INTEGER) { | ||
181 | printk(KERN_WARNING "IdeaPAD \\_SB_.DECN method returned unexpected type\n"); | ||
182 | return -ENODEV; | ||
183 | } | ||
184 | return out_obj.integer.value; | ||
185 | } | ||
186 | |||
187 | static int ideapad_dev_get_state(int device) | 162 | static int ideapad_dev_get_state(int device) |
188 | { | 163 | { |
189 | acpi_status status; | 164 | acpi_status status; |
@@ -334,9 +309,10 @@ static int ideapad_acpi_add(struct acpi_device *adevice) | |||
334 | return -ENODEV; | 309 | return -ENODEV; |
335 | 310 | ||
336 | for (i = IDEAPAD_DEV_CAMERA; i < IDEAPAD_DEV_KILLSW; i++) { | 311 | for (i = IDEAPAD_DEV_CAMERA; i < IDEAPAD_DEV_KILLSW; i++) { |
337 | devs_present[i] = ideapad_dev_exists(i); | 312 | if (test_bit(ideapad_rfk_data[i].cfgbit, (unsigned long *)&cfg)) |
338 | if (devs_present[i] < 0) | 313 | devs_present[i] = 1; |
339 | return devs_present[i]; | 314 | else |
315 | devs_present[i] = 0; | ||
340 | } | 316 | } |
341 | 317 | ||
342 | /* The hardware switch is always present */ | 318 | /* The hardware switch is always present */ |