diff options
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r-- | drivers/acpi/scan.c | 437 |
1 files changed, 194 insertions, 243 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index cbcda30c172d..8a3ea41063ec 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -9,14 +9,10 @@ | |||
9 | #include <acpi/acpi_drivers.h> | 9 | #include <acpi/acpi_drivers.h> |
10 | #include <acpi/acinterp.h> /* for acpi_ex_eisa_id_to_string() */ | 10 | #include <acpi/acinterp.h> /* for acpi_ex_eisa_id_to_string() */ |
11 | 11 | ||
12 | |||
13 | #define _COMPONENT ACPI_BUS_COMPONENT | 12 | #define _COMPONENT ACPI_BUS_COMPONENT |
14 | ACPI_MODULE_NAME ("scan") | 13 | ACPI_MODULE_NAME("scan") |
15 | |||
16 | #define STRUCT_TO_INT(s) (*((int*)&s)) | 14 | #define STRUCT_TO_INT(s) (*((int*)&s)) |
17 | 15 | extern struct acpi_device *acpi_root; | |
18 | extern struct acpi_device *acpi_root; | ||
19 | |||
20 | 16 | ||
21 | #define ACPI_BUS_CLASS "system_bus" | 17 | #define ACPI_BUS_CLASS "system_bus" |
22 | #define ACPI_BUS_HID "ACPI_BUS" | 18 | #define ACPI_BUS_HID "ACPI_BUS" |
@@ -27,13 +23,11 @@ static LIST_HEAD(acpi_device_list); | |||
27 | DEFINE_SPINLOCK(acpi_device_lock); | 23 | DEFINE_SPINLOCK(acpi_device_lock); |
28 | LIST_HEAD(acpi_wakeup_device_list); | 24 | LIST_HEAD(acpi_wakeup_device_list); |
29 | 25 | ||
30 | static int | 26 | static int acpi_bus_trim(struct acpi_device *start, int rmdevice); |
31 | acpi_bus_trim(struct acpi_device *start, | ||
32 | int rmdevice); | ||
33 | 27 | ||
34 | static void acpi_device_release(struct kobject * kobj) | 28 | static void acpi_device_release(struct kobject *kobj) |
35 | { | 29 | { |
36 | struct acpi_device * dev = container_of(kobj,struct acpi_device,kobj); | 30 | struct acpi_device *dev = container_of(kobj, struct acpi_device, kobj); |
37 | if (dev->pnp.cid_list) | 31 | if (dev->pnp.cid_list) |
38 | kfree(dev->pnp.cid_list); | 32 | kfree(dev->pnp.cid_list); |
39 | kfree(dev); | 33 | kfree(dev); |
@@ -41,34 +35,34 @@ static void acpi_device_release(struct kobject * kobj) | |||
41 | 35 | ||
42 | struct acpi_device_attribute { | 36 | struct acpi_device_attribute { |
43 | struct attribute attr; | 37 | struct attribute attr; |
44 | ssize_t (*show)(struct acpi_device *, char *); | 38 | ssize_t(*show) (struct acpi_device *, char *); |
45 | ssize_t (*store)(struct acpi_device *, const char *, size_t); | 39 | ssize_t(*store) (struct acpi_device *, const char *, size_t); |
46 | }; | 40 | }; |
47 | 41 | ||
48 | typedef void acpi_device_sysfs_files(struct kobject *, | 42 | typedef void acpi_device_sysfs_files(struct kobject *, |
49 | const struct attribute *); | 43 | const struct attribute *); |
50 | 44 | ||
51 | static void setup_sys_fs_device_files(struct acpi_device *dev, | 45 | static void setup_sys_fs_device_files(struct acpi_device *dev, |
52 | acpi_device_sysfs_files *func); | 46 | acpi_device_sysfs_files * func); |
53 | 47 | ||
54 | #define create_sysfs_device_files(dev) \ | 48 | #define create_sysfs_device_files(dev) \ |
55 | setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_create_file) | 49 | setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_create_file) |
56 | #define remove_sysfs_device_files(dev) \ | 50 | #define remove_sysfs_device_files(dev) \ |
57 | setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_remove_file) | 51 | setup_sys_fs_device_files(dev, (acpi_device_sysfs_files *)&sysfs_remove_file) |
58 | 52 | ||
59 | |||
60 | #define to_acpi_device(n) container_of(n, struct acpi_device, kobj) | 53 | #define to_acpi_device(n) container_of(n, struct acpi_device, kobj) |
61 | #define to_handle_attr(n) container_of(n, struct acpi_device_attribute, attr); | 54 | #define to_handle_attr(n) container_of(n, struct acpi_device_attribute, attr); |
62 | 55 | ||
63 | static ssize_t acpi_device_attr_show(struct kobject *kobj, | 56 | static ssize_t acpi_device_attr_show(struct kobject *kobj, |
64 | struct attribute *attr, char *buf) | 57 | struct attribute *attr, char *buf) |
65 | { | 58 | { |
66 | struct acpi_device *device = to_acpi_device(kobj); | 59 | struct acpi_device *device = to_acpi_device(kobj); |
67 | struct acpi_device_attribute *attribute = to_handle_attr(attr); | 60 | struct acpi_device_attribute *attribute = to_handle_attr(attr); |
68 | return attribute->show ? attribute->show(device, buf) : -EIO; | 61 | return attribute->show ? attribute->show(device, buf) : -EIO; |
69 | } | 62 | } |
70 | static ssize_t acpi_device_attr_store(struct kobject *kobj, | 63 | static ssize_t acpi_device_attr_store(struct kobject *kobj, |
71 | struct attribute *attr, const char *buf, size_t len) | 64 | struct attribute *attr, const char *buf, |
65 | size_t len) | ||
72 | { | 66 | { |
73 | struct acpi_device *device = to_acpi_device(kobj); | 67 | struct acpi_device *device = to_acpi_device(kobj); |
74 | struct acpi_device_attribute *attribute = to_handle_attr(attr); | 68 | struct acpi_device_attribute *attribute = to_handle_attr(attr); |
@@ -76,13 +70,13 @@ static ssize_t acpi_device_attr_store(struct kobject *kobj, | |||
76 | } | 70 | } |
77 | 71 | ||
78 | static struct sysfs_ops acpi_device_sysfs_ops = { | 72 | static struct sysfs_ops acpi_device_sysfs_ops = { |
79 | .show = acpi_device_attr_show, | 73 | .show = acpi_device_attr_show, |
80 | .store = acpi_device_attr_store, | 74 | .store = acpi_device_attr_store, |
81 | }; | 75 | }; |
82 | 76 | ||
83 | static struct kobj_type ktype_acpi_ns = { | 77 | static struct kobj_type ktype_acpi_ns = { |
84 | .sysfs_ops = &acpi_device_sysfs_ops, | 78 | .sysfs_ops = &acpi_device_sysfs_ops, |
85 | .release = acpi_device_release, | 79 | .release = acpi_device_release, |
86 | }; | 80 | }; |
87 | 81 | ||
88 | static int namespace_hotplug(struct kset *kset, struct kobject *kobj, | 82 | static int namespace_hotplug(struct kset *kset, struct kobject *kobj, |
@@ -110,16 +104,16 @@ static struct kset_hotplug_ops namespace_hotplug_ops = { | |||
110 | }; | 104 | }; |
111 | 105 | ||
112 | static struct kset acpi_namespace_kset = { | 106 | static struct kset acpi_namespace_kset = { |
113 | .kobj = { | 107 | .kobj = { |
114 | .name = "namespace", | 108 | .name = "namespace", |
115 | }, | 109 | }, |
116 | .subsys = &acpi_subsys, | 110 | .subsys = &acpi_subsys, |
117 | .ktype = &ktype_acpi_ns, | 111 | .ktype = &ktype_acpi_ns, |
118 | .hotplug_ops = &namespace_hotplug_ops, | 112 | .hotplug_ops = &namespace_hotplug_ops, |
119 | }; | 113 | }; |
120 | 114 | ||
121 | 115 | static void acpi_device_register(struct acpi_device *device, | |
122 | static void acpi_device_register(struct acpi_device * device, struct acpi_device * parent) | 116 | struct acpi_device *parent) |
123 | { | 117 | { |
124 | /* | 118 | /* |
125 | * Linkage | 119 | * Linkage |
@@ -134,14 +128,14 @@ static void acpi_device_register(struct acpi_device * device, struct acpi_device | |||
134 | spin_lock(&acpi_device_lock); | 128 | spin_lock(&acpi_device_lock); |
135 | if (device->parent) { | 129 | if (device->parent) { |
136 | list_add_tail(&device->node, &device->parent->children); | 130 | list_add_tail(&device->node, &device->parent->children); |
137 | list_add_tail(&device->g_list,&device->parent->g_list); | 131 | list_add_tail(&device->g_list, &device->parent->g_list); |
138 | } else | 132 | } else |
139 | list_add_tail(&device->g_list,&acpi_device_list); | 133 | list_add_tail(&device->g_list, &acpi_device_list); |
140 | if (device->wakeup.flags.valid) | 134 | if (device->wakeup.flags.valid) |
141 | list_add_tail(&device->wakeup_list,&acpi_wakeup_device_list); | 135 | list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list); |
142 | spin_unlock(&acpi_device_lock); | 136 | spin_unlock(&acpi_device_lock); |
143 | 137 | ||
144 | strlcpy(device->kobj.name,device->pnp.bus_id,KOBJ_NAME_LEN); | 138 | strlcpy(device->kobj.name, device->pnp.bus_id, KOBJ_NAME_LEN); |
145 | if (parent) | 139 | if (parent) |
146 | device->kobj.parent = &parent->kobj; | 140 | device->kobj.parent = &parent->kobj; |
147 | device->kobj.ktype = &ktype_acpi_ns; | 141 | device->kobj.ktype = &ktype_acpi_ns; |
@@ -150,10 +144,7 @@ static void acpi_device_register(struct acpi_device * device, struct acpi_device | |||
150 | create_sysfs_device_files(device); | 144 | create_sysfs_device_files(device); |
151 | } | 145 | } |
152 | 146 | ||
153 | static int | 147 | static int acpi_device_unregister(struct acpi_device *device, int type) |
154 | acpi_device_unregister ( | ||
155 | struct acpi_device *device, | ||
156 | int type) | ||
157 | { | 148 | { |
158 | spin_lock(&acpi_device_lock); | 149 | spin_lock(&acpi_device_lock); |
159 | if (device->parent) { | 150 | if (device->parent) { |
@@ -172,11 +163,7 @@ acpi_device_unregister ( | |||
172 | return 0; | 163 | return 0; |
173 | } | 164 | } |
174 | 165 | ||
175 | void | 166 | void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context) |
176 | acpi_bus_data_handler ( | ||
177 | acpi_handle handle, | ||
178 | u32 function, | ||
179 | void *context) | ||
180 | { | 167 | { |
181 | ACPI_FUNCTION_TRACE("acpi_bus_data_handler"); | 168 | ACPI_FUNCTION_TRACE("acpi_bus_data_handler"); |
182 | 169 | ||
@@ -185,13 +172,11 @@ acpi_bus_data_handler ( | |||
185 | return_VOID; | 172 | return_VOID; |
186 | } | 173 | } |
187 | 174 | ||
188 | static int | 175 | static int acpi_bus_get_power_flags(struct acpi_device *device) |
189 | acpi_bus_get_power_flags ( | ||
190 | struct acpi_device *device) | ||
191 | { | 176 | { |
192 | acpi_status status = 0; | 177 | acpi_status status = 0; |
193 | acpi_handle handle = NULL; | 178 | acpi_handle handle = NULL; |
194 | u32 i = 0; | 179 | u32 i = 0; |
195 | 180 | ||
196 | ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags"); | 181 | ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags"); |
197 | 182 | ||
@@ -210,11 +195,11 @@ acpi_bus_get_power_flags ( | |||
210 | */ | 195 | */ |
211 | for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) { | 196 | for (i = ACPI_STATE_D0; i <= ACPI_STATE_D3; i++) { |
212 | struct acpi_device_power_state *ps = &device->power.states[i]; | 197 | struct acpi_device_power_state *ps = &device->power.states[i]; |
213 | char object_name[5] = {'_','P','R','0'+i,'\0'}; | 198 | char object_name[5] = { '_', 'P', 'R', '0' + i, '\0' }; |
214 | 199 | ||
215 | /* Evaluate "_PRx" to se if power resources are referenced */ | 200 | /* Evaluate "_PRx" to se if power resources are referenced */ |
216 | acpi_evaluate_reference(device->handle, object_name, NULL, | 201 | acpi_evaluate_reference(device->handle, object_name, NULL, |
217 | &ps->resources); | 202 | &ps->resources); |
218 | if (ps->resources.count) { | 203 | if (ps->resources.count) { |
219 | device->power.flags.power_resources = 1; | 204 | device->power.flags.power_resources = 1; |
220 | ps->flags.valid = 1; | 205 | ps->flags.valid = 1; |
@@ -232,7 +217,7 @@ acpi_bus_get_power_flags ( | |||
232 | if (ps->resources.count || ps->flags.explicit_set) | 217 | if (ps->resources.count || ps->flags.explicit_set) |
233 | ps->flags.valid = 1; | 218 | ps->flags.valid = 1; |
234 | 219 | ||
235 | ps->power = -1; /* Unknown - driver assigned */ | 220 | ps->power = -1; /* Unknown - driver assigned */ |
236 | ps->latency = -1; /* Unknown - driver assigned */ | 221 | ps->latency = -1; /* Unknown - driver assigned */ |
237 | } | 222 | } |
238 | 223 | ||
@@ -249,13 +234,10 @@ acpi_bus_get_power_flags ( | |||
249 | return_VALUE(0); | 234 | return_VALUE(0); |
250 | } | 235 | } |
251 | 236 | ||
252 | int | 237 | int acpi_match_ids(struct acpi_device *device, char *ids) |
253 | acpi_match_ids ( | ||
254 | struct acpi_device *device, | ||
255 | char *ids) | ||
256 | { | 238 | { |
257 | int error = 0; | 239 | int error = 0; |
258 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | 240 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
259 | 241 | ||
260 | if (device->flags.hardware_id) | 242 | if (device->flags.hardware_id) |
261 | if (strstr(ids, device->pnp.hardware_id)) | 243 | if (strstr(ids, device->pnp.hardware_id)) |
@@ -266,27 +248,25 @@ acpi_match_ids ( | |||
266 | int i; | 248 | int i; |
267 | 249 | ||
268 | /* compare multiple _CID entries against driver ids */ | 250 | /* compare multiple _CID entries against driver ids */ |
269 | for (i = 0; i < cid_list->count; i++) | 251 | for (i = 0; i < cid_list->count; i++) { |
270 | { | ||
271 | if (strstr(ids, cid_list->id[i].value)) | 252 | if (strstr(ids, cid_list->id[i].value)) |
272 | goto Done; | 253 | goto Done; |
273 | } | 254 | } |
274 | } | 255 | } |
275 | error = -ENOENT; | 256 | error = -ENOENT; |
276 | 257 | ||
277 | Done: | 258 | Done: |
278 | if (buffer.pointer) | 259 | if (buffer.pointer) |
279 | acpi_os_free(buffer.pointer); | 260 | acpi_os_free(buffer.pointer); |
280 | return error; | 261 | return error; |
281 | } | 262 | } |
282 | 263 | ||
283 | static acpi_status | 264 | static acpi_status |
284 | acpi_bus_extract_wakeup_device_power_package ( | 265 | acpi_bus_extract_wakeup_device_power_package(struct acpi_device *device, |
285 | struct acpi_device *device, | 266 | union acpi_object *package) |
286 | union acpi_object *package) | ||
287 | { | 267 | { |
288 | int i = 0; | 268 | int i = 0; |
289 | union acpi_object *element = NULL; | 269 | union acpi_object *element = NULL; |
290 | 270 | ||
291 | if (!device || !package || (package->package.count < 2)) | 271 | if (!device || !package || (package->package.count < 2)) |
292 | return AE_BAD_PARAMETER; | 272 | return AE_BAD_PARAMETER; |
@@ -296,14 +276,17 @@ acpi_bus_extract_wakeup_device_power_package ( | |||
296 | return AE_BAD_PARAMETER; | 276 | return AE_BAD_PARAMETER; |
297 | if (element->type == ACPI_TYPE_PACKAGE) { | 277 | if (element->type == ACPI_TYPE_PACKAGE) { |
298 | if ((element->package.count < 2) || | 278 | if ((element->package.count < 2) || |
299 | (element->package.elements[0].type != ACPI_TYPE_LOCAL_REFERENCE) || | 279 | (element->package.elements[0].type != |
300 | (element->package.elements[1].type != ACPI_TYPE_INTEGER)) | 280 | ACPI_TYPE_LOCAL_REFERENCE) |
281 | || (element->package.elements[1].type != ACPI_TYPE_INTEGER)) | ||
301 | return AE_BAD_DATA; | 282 | return AE_BAD_DATA; |
302 | device->wakeup.gpe_device = element->package.elements[0].reference.handle; | 283 | device->wakeup.gpe_device = |
303 | device->wakeup.gpe_number = (u32)element->package.elements[1].integer.value; | 284 | element->package.elements[0].reference.handle; |
304 | }else if (element->type == ACPI_TYPE_INTEGER) { | 285 | device->wakeup.gpe_number = |
286 | (u32) element->package.elements[1].integer.value; | ||
287 | } else if (element->type == ACPI_TYPE_INTEGER) { | ||
305 | device->wakeup.gpe_number = element->integer.value; | 288 | device->wakeup.gpe_number = element->integer.value; |
306 | }else | 289 | } else |
307 | return AE_BAD_DATA; | 290 | return AE_BAD_DATA; |
308 | 291 | ||
309 | element = &(package->package.elements[1]); | 292 | element = &(package->package.elements[1]); |
@@ -316,9 +299,9 @@ acpi_bus_extract_wakeup_device_power_package ( | |||
316 | return AE_NO_MEMORY; | 299 | return AE_NO_MEMORY; |
317 | } | 300 | } |
318 | device->wakeup.resources.count = package->package.count - 2; | 301 | device->wakeup.resources.count = package->package.count - 2; |
319 | for (i=0; i < device->wakeup.resources.count; i++) { | 302 | for (i = 0; i < device->wakeup.resources.count; i++) { |
320 | element = &(package->package.elements[i + 2]); | 303 | element = &(package->package.elements[i + 2]); |
321 | if (element->type != ACPI_TYPE_ANY ) { | 304 | if (element->type != ACPI_TYPE_ANY) { |
322 | return AE_BAD_DATA; | 305 | return AE_BAD_DATA; |
323 | } | 306 | } |
324 | 307 | ||
@@ -328,13 +311,11 @@ acpi_bus_extract_wakeup_device_power_package ( | |||
328 | return AE_OK; | 311 | return AE_OK; |
329 | } | 312 | } |
330 | 313 | ||
331 | static int | 314 | static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device) |
332 | acpi_bus_get_wakeup_device_flags ( | ||
333 | struct acpi_device *device) | ||
334 | { | 315 | { |
335 | acpi_status status = 0; | 316 | acpi_status status = 0; |
336 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | 317 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
337 | union acpi_object *package = NULL; | 318 | union acpi_object *package = NULL; |
338 | 319 | ||
339 | ACPI_FUNCTION_TRACE("acpi_bus_get_wakeup_flags"); | 320 | ACPI_FUNCTION_TRACE("acpi_bus_get_wakeup_flags"); |
340 | 321 | ||
@@ -345,21 +326,22 @@ acpi_bus_get_wakeup_device_flags ( | |||
345 | goto end; | 326 | goto end; |
346 | } | 327 | } |
347 | 328 | ||
348 | package = (union acpi_object *) buffer.pointer; | 329 | package = (union acpi_object *)buffer.pointer; |
349 | status = acpi_bus_extract_wakeup_device_power_package(device, package); | 330 | status = acpi_bus_extract_wakeup_device_power_package(device, package); |
350 | if (ACPI_FAILURE(status)) { | 331 | if (ACPI_FAILURE(status)) { |
351 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error extracting _PRW package\n")); | 332 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR, |
333 | "Error extracting _PRW package\n")); | ||
352 | goto end; | 334 | goto end; |
353 | } | 335 | } |
354 | 336 | ||
355 | acpi_os_free(buffer.pointer); | 337 | acpi_os_free(buffer.pointer); |
356 | 338 | ||
357 | device->wakeup.flags.valid = 1; | 339 | device->wakeup.flags.valid = 1; |
358 | /* Power button, Lid switch always enable wakeup*/ | 340 | /* Power button, Lid switch always enable wakeup */ |
359 | if (!acpi_match_ids(device, "PNP0C0D,PNP0C0C,PNP0C0E")) | 341 | if (!acpi_match_ids(device, "PNP0C0D,PNP0C0C,PNP0C0E")) |
360 | device->wakeup.flags.run_wake = 1; | 342 | device->wakeup.flags.run_wake = 1; |
361 | 343 | ||
362 | end: | 344 | end: |
363 | if (ACPI_FAILURE(status)) | 345 | if (ACPI_FAILURE(status)) |
364 | device->flags.wake_capable = 0; | 346 | device->flags.wake_capable = 0; |
365 | return_VALUE(0); | 347 | return_VALUE(0); |
@@ -368,8 +350,8 @@ end: | |||
368 | /* -------------------------------------------------------------------------- | 350 | /* -------------------------------------------------------------------------- |
369 | ACPI hotplug sysfs device file support | 351 | ACPI hotplug sysfs device file support |
370 | -------------------------------------------------------------------------- */ | 352 | -------------------------------------------------------------------------- */ |
371 | static ssize_t acpi_eject_store(struct acpi_device *device, | 353 | static ssize_t acpi_eject_store(struct acpi_device *device, |
372 | const char *buf, size_t count); | 354 | const char *buf, size_t count); |
373 | 355 | ||
374 | #define ACPI_DEVICE_ATTR(_name,_mode,_show,_store) \ | 356 | #define ACPI_DEVICE_ATTR(_name,_mode,_show,_store) \ |
375 | static struct acpi_device_attribute acpi_device_attr_##_name = \ | 357 | static struct acpi_device_attribute acpi_device_attr_##_name = \ |
@@ -383,12 +365,11 @@ ACPI_DEVICE_ATTR(eject, 0200, NULL, acpi_eject_store); | |||
383 | * @func: function pointer to create or destroy the device file | 365 | * @func: function pointer to create or destroy the device file |
384 | */ | 366 | */ |
385 | static void | 367 | static void |
386 | setup_sys_fs_device_files ( | 368 | setup_sys_fs_device_files(struct acpi_device *dev, |
387 | struct acpi_device *dev, | 369 | acpi_device_sysfs_files * func) |
388 | acpi_device_sysfs_files *func) | ||
389 | { | 370 | { |
390 | acpi_status status; | 371 | acpi_status status; |
391 | acpi_handle temp = NULL; | 372 | acpi_handle temp = NULL; |
392 | 373 | ||
393 | /* | 374 | /* |
394 | * If device has _EJ0, 'eject' file is created that is used to trigger | 375 | * If device has _EJ0, 'eject' file is created that is used to trigger |
@@ -396,11 +377,10 @@ setup_sys_fs_device_files ( | |||
396 | */ | 377 | */ |
397 | status = acpi_get_handle(dev->handle, "_EJ0", &temp); | 378 | status = acpi_get_handle(dev->handle, "_EJ0", &temp); |
398 | if (ACPI_SUCCESS(status)) | 379 | if (ACPI_SUCCESS(status)) |
399 | (*(func))(&dev->kobj,&acpi_device_attr_eject.attr); | 380 | (*(func)) (&dev->kobj, &acpi_device_attr_eject.attr); |
400 | } | 381 | } |
401 | 382 | ||
402 | static int | 383 | static int acpi_eject_operation(acpi_handle handle, int lockable) |
403 | acpi_eject_operation(acpi_handle handle, int lockable) | ||
404 | { | 384 | { |
405 | struct acpi_object_list arg_list; | 385 | struct acpi_object_list arg_list; |
406 | union acpi_object arg; | 386 | union acpi_object arg; |
@@ -429,27 +409,25 @@ acpi_eject_operation(acpi_handle handle, int lockable) | |||
429 | 409 | ||
430 | status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); | 410 | status = acpi_evaluate_object(handle, "_EJ0", &arg_list, NULL); |
431 | if (ACPI_FAILURE(status)) { | 411 | if (ACPI_FAILURE(status)) { |
432 | return(-ENODEV); | 412 | return (-ENODEV); |
433 | } | 413 | } |
434 | 414 | ||
435 | return(0); | 415 | return (0); |
436 | } | 416 | } |
437 | 417 | ||
438 | |||
439 | static ssize_t | 418 | static ssize_t |
440 | acpi_eject_store(struct acpi_device *device, const char *buf, size_t count) | 419 | acpi_eject_store(struct acpi_device *device, const char *buf, size_t count) |
441 | { | 420 | { |
442 | int result; | 421 | int result; |
443 | int ret = count; | 422 | int ret = count; |
444 | int islockable; | 423 | int islockable; |
445 | acpi_status status; | 424 | acpi_status status; |
446 | acpi_handle handle; | 425 | acpi_handle handle; |
447 | acpi_object_type type = 0; | 426 | acpi_object_type type = 0; |
448 | 427 | ||
449 | if ((!count) || (buf[0] != '1')) { | 428 | if ((!count) || (buf[0] != '1')) { |
450 | return -EINVAL; | 429 | return -EINVAL; |
451 | } | 430 | } |
452 | |||
453 | #ifndef FORCE_EJECT | 431 | #ifndef FORCE_EJECT |
454 | if (device->driver == NULL) { | 432 | if (device->driver == NULL) { |
455 | ret = -ENODEV; | 433 | ret = -ENODEV; |
@@ -457,7 +435,7 @@ acpi_eject_store(struct acpi_device *device, const char *buf, size_t count) | |||
457 | } | 435 | } |
458 | #endif | 436 | #endif |
459 | status = acpi_get_type(device->handle, &type); | 437 | status = acpi_get_type(device->handle, &type); |
460 | if (ACPI_FAILURE(status) || (!device->flags.ejectable) ) { | 438 | if (ACPI_FAILURE(status) || (!device->flags.ejectable)) { |
461 | ret = -ENODEV; | 439 | ret = -ENODEV; |
462 | goto err; | 440 | goto err; |
463 | } | 441 | } |
@@ -476,18 +454,15 @@ acpi_eject_store(struct acpi_device *device, const char *buf, size_t count) | |||
476 | if (result) { | 454 | if (result) { |
477 | ret = -EBUSY; | 455 | ret = -EBUSY; |
478 | } | 456 | } |
479 | err: | 457 | err: |
480 | return ret; | 458 | return ret; |
481 | } | 459 | } |
482 | 460 | ||
483 | |||
484 | /* -------------------------------------------------------------------------- | 461 | /* -------------------------------------------------------------------------- |
485 | Performance Management | 462 | Performance Management |
486 | -------------------------------------------------------------------------- */ | 463 | -------------------------------------------------------------------------- */ |
487 | 464 | ||
488 | static int | 465 | static int acpi_bus_get_perf_flags(struct acpi_device *device) |
489 | acpi_bus_get_perf_flags ( | ||
490 | struct acpi_device *device) | ||
491 | { | 466 | { |
492 | device->performance.state = ACPI_STATE_UNKNOWN; | 467 | device->performance.state = ACPI_STATE_UNKNOWN; |
493 | return 0; | 468 | return 0; |
@@ -500,7 +475,6 @@ acpi_bus_get_perf_flags ( | |||
500 | static LIST_HEAD(acpi_bus_drivers); | 475 | static LIST_HEAD(acpi_bus_drivers); |
501 | static DECLARE_MUTEX(acpi_bus_drivers_lock); | 476 | static DECLARE_MUTEX(acpi_bus_drivers_lock); |
502 | 477 | ||
503 | |||
504 | /** | 478 | /** |
505 | * acpi_bus_match | 479 | * acpi_bus_match |
506 | * -------------- | 480 | * -------------- |
@@ -508,16 +482,13 @@ static DECLARE_MUTEX(acpi_bus_drivers_lock); | |||
508 | * matches the specified driver's criteria. | 482 | * matches the specified driver's criteria. |
509 | */ | 483 | */ |
510 | static int | 484 | static int |
511 | acpi_bus_match ( | 485 | acpi_bus_match(struct acpi_device *device, struct acpi_driver *driver) |
512 | struct acpi_device *device, | ||
513 | struct acpi_driver *driver) | ||
514 | { | 486 | { |
515 | if (driver && driver->ops.match) | 487 | if (driver && driver->ops.match) |
516 | return driver->ops.match(device, driver); | 488 | return driver->ops.match(device, driver); |
517 | return acpi_match_ids(device, driver->ids); | 489 | return acpi_match_ids(device, driver->ids); |
518 | } | 490 | } |
519 | 491 | ||
520 | |||
521 | /** | 492 | /** |
522 | * acpi_bus_driver_init | 493 | * acpi_bus_driver_init |
523 | * -------------------- | 494 | * -------------------- |
@@ -525,11 +496,9 @@ acpi_bus_match ( | |||
525 | * driver is bound to a device. Invokes the driver's add() and start() ops. | 496 | * driver is bound to a device. Invokes the driver's add() and start() ops. |
526 | */ | 497 | */ |
527 | static int | 498 | static int |
528 | acpi_bus_driver_init ( | 499 | acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver) |
529 | struct acpi_device *device, | ||
530 | struct acpi_driver *driver) | ||
531 | { | 500 | { |
532 | int result = 0; | 501 | int result = 0; |
533 | 502 | ||
534 | ACPI_FUNCTION_TRACE("acpi_bus_driver_init"); | 503 | ACPI_FUNCTION_TRACE("acpi_bus_driver_init"); |
535 | 504 | ||
@@ -553,13 +522,12 @@ acpi_bus_driver_init ( | |||
553 | * upon possible configuration and currently allocated resources. | 522 | * upon possible configuration and currently allocated resources. |
554 | */ | 523 | */ |
555 | 524 | ||
556 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Driver successfully bound to device\n")); | 525 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
526 | "Driver successfully bound to device\n")); | ||
557 | return_VALUE(0); | 527 | return_VALUE(0); |
558 | } | 528 | } |
559 | 529 | ||
560 | int | 530 | int acpi_start_single_object(struct acpi_device *device) |
561 | acpi_start_single_object ( | ||
562 | struct acpi_device *device) | ||
563 | { | 531 | { |
564 | int result = 0; | 532 | int result = 0; |
565 | struct acpi_driver *driver; | 533 | struct acpi_driver *driver; |
@@ -578,16 +546,17 @@ acpi_start_single_object ( | |||
578 | return_VALUE(result); | 546 | return_VALUE(result); |
579 | } | 547 | } |
580 | 548 | ||
581 | static int acpi_driver_attach(struct acpi_driver * drv) | 549 | static int acpi_driver_attach(struct acpi_driver *drv) |
582 | { | 550 | { |
583 | struct list_head * node, * next; | 551 | struct list_head *node, *next; |
584 | int count = 0; | 552 | int count = 0; |
585 | 553 | ||
586 | ACPI_FUNCTION_TRACE("acpi_driver_attach"); | 554 | ACPI_FUNCTION_TRACE("acpi_driver_attach"); |
587 | 555 | ||
588 | spin_lock(&acpi_device_lock); | 556 | spin_lock(&acpi_device_lock); |
589 | list_for_each_safe(node, next, &acpi_device_list) { | 557 | list_for_each_safe(node, next, &acpi_device_list) { |
590 | struct acpi_device * dev = container_of(node, struct acpi_device, g_list); | 558 | struct acpi_device *dev = |
559 | container_of(node, struct acpi_device, g_list); | ||
591 | 560 | ||
592 | if (dev->driver || !dev->status.present) | 561 | if (dev->driver || !dev->status.present) |
593 | continue; | 562 | continue; |
@@ -598,7 +567,8 @@ static int acpi_driver_attach(struct acpi_driver * drv) | |||
598 | acpi_start_single_object(dev); | 567 | acpi_start_single_object(dev); |
599 | atomic_inc(&drv->references); | 568 | atomic_inc(&drv->references); |
600 | count++; | 569 | count++; |
601 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n", | 570 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
571 | "Found driver [%s] for device [%s]\n", | ||
602 | drv->name, dev->pnp.bus_id)); | 572 | drv->name, dev->pnp.bus_id)); |
603 | } | 573 | } |
604 | } | 574 | } |
@@ -608,20 +578,21 @@ static int acpi_driver_attach(struct acpi_driver * drv) | |||
608 | return_VALUE(count); | 578 | return_VALUE(count); |
609 | } | 579 | } |
610 | 580 | ||
611 | static int acpi_driver_detach(struct acpi_driver * drv) | 581 | static int acpi_driver_detach(struct acpi_driver *drv) |
612 | { | 582 | { |
613 | struct list_head * node, * next; | 583 | struct list_head *node, *next; |
614 | 584 | ||
615 | ACPI_FUNCTION_TRACE("acpi_driver_detach"); | 585 | ACPI_FUNCTION_TRACE("acpi_driver_detach"); |
616 | 586 | ||
617 | spin_lock(&acpi_device_lock); | 587 | spin_lock(&acpi_device_lock); |
618 | list_for_each_safe(node,next,&acpi_device_list) { | 588 | list_for_each_safe(node, next, &acpi_device_list) { |
619 | struct acpi_device * dev = container_of(node,struct acpi_device,g_list); | 589 | struct acpi_device *dev = |
590 | container_of(node, struct acpi_device, g_list); | ||
620 | 591 | ||
621 | if (dev->driver == drv) { | 592 | if (dev->driver == drv) { |
622 | spin_unlock(&acpi_device_lock); | 593 | spin_unlock(&acpi_device_lock); |
623 | if (drv->ops.remove) | 594 | if (drv->ops.remove) |
624 | drv->ops.remove(dev,ACPI_BUS_REMOVAL_NORMAL); | 595 | drv->ops.remove(dev, ACPI_BUS_REMOVAL_NORMAL); |
625 | spin_lock(&acpi_device_lock); | 596 | spin_lock(&acpi_device_lock); |
626 | dev->driver = NULL; | 597 | dev->driver = NULL; |
627 | dev->driver_data = NULL; | 598 | dev->driver_data = NULL; |
@@ -640,9 +611,7 @@ static int acpi_driver_detach(struct acpi_driver * drv) | |||
640 | * number of devices that were claimed by the driver, or a negative | 611 | * number of devices that were claimed by the driver, or a negative |
641 | * error status for failure. | 612 | * error status for failure. |
642 | */ | 613 | */ |
643 | int | 614 | int acpi_bus_register_driver(struct acpi_driver *driver) |
644 | acpi_bus_register_driver ( | ||
645 | struct acpi_driver *driver) | ||
646 | { | 615 | { |
647 | int count; | 616 | int count; |
648 | 617 | ||
@@ -661,8 +630,8 @@ acpi_bus_register_driver ( | |||
661 | 630 | ||
662 | return_VALUE(count); | 631 | return_VALUE(count); |
663 | } | 632 | } |
664 | EXPORT_SYMBOL(acpi_bus_register_driver); | ||
665 | 633 | ||
634 | EXPORT_SYMBOL(acpi_bus_register_driver); | ||
666 | 635 | ||
667 | /** | 636 | /** |
668 | * acpi_bus_unregister_driver | 637 | * acpi_bus_unregister_driver |
@@ -670,9 +639,7 @@ EXPORT_SYMBOL(acpi_bus_register_driver); | |||
670 | * Unregisters a driver with the ACPI bus. Searches the namespace for all | 639 | * Unregisters a driver with the ACPI bus. Searches the namespace for all |
671 | * devices that match the driver's criteria and unbinds. | 640 | * devices that match the driver's criteria and unbinds. |
672 | */ | 641 | */ |
673 | int | 642 | int acpi_bus_unregister_driver(struct acpi_driver *driver) |
674 | acpi_bus_unregister_driver ( | ||
675 | struct acpi_driver *driver) | ||
676 | { | 643 | { |
677 | int error = 0; | 644 | int error = 0; |
678 | 645 | ||
@@ -685,11 +652,12 @@ acpi_bus_unregister_driver ( | |||
685 | spin_lock(&acpi_device_lock); | 652 | spin_lock(&acpi_device_lock); |
686 | list_del_init(&driver->node); | 653 | list_del_init(&driver->node); |
687 | spin_unlock(&acpi_device_lock); | 654 | spin_unlock(&acpi_device_lock); |
688 | } | 655 | } |
689 | } else | 656 | } else |
690 | error = -EINVAL; | 657 | error = -EINVAL; |
691 | return_VALUE(error); | 658 | return_VALUE(error); |
692 | } | 659 | } |
660 | |||
693 | EXPORT_SYMBOL(acpi_bus_unregister_driver); | 661 | EXPORT_SYMBOL(acpi_bus_unregister_driver); |
694 | 662 | ||
695 | /** | 663 | /** |
@@ -698,18 +666,17 @@ EXPORT_SYMBOL(acpi_bus_unregister_driver); | |||
698 | * Parses the list of registered drivers looking for a driver applicable for | 666 | * Parses the list of registered drivers looking for a driver applicable for |
699 | * the specified device. | 667 | * the specified device. |
700 | */ | 668 | */ |
701 | static int | 669 | static int acpi_bus_find_driver(struct acpi_device *device) |
702 | acpi_bus_find_driver ( | ||
703 | struct acpi_device *device) | ||
704 | { | 670 | { |
705 | int result = 0; | 671 | int result = 0; |
706 | struct list_head * node, *next; | 672 | struct list_head *node, *next; |
707 | 673 | ||
708 | ACPI_FUNCTION_TRACE("acpi_bus_find_driver"); | 674 | ACPI_FUNCTION_TRACE("acpi_bus_find_driver"); |
709 | 675 | ||
710 | spin_lock(&acpi_device_lock); | 676 | spin_lock(&acpi_device_lock); |
711 | list_for_each_safe(node,next,&acpi_bus_drivers) { | 677 | list_for_each_safe(node, next, &acpi_bus_drivers) { |
712 | struct acpi_driver * driver = container_of(node,struct acpi_driver,node); | 678 | struct acpi_driver *driver = |
679 | container_of(node, struct acpi_driver, node); | ||
713 | 680 | ||
714 | atomic_inc(&driver->references); | 681 | atomic_inc(&driver->references); |
715 | spin_unlock(&acpi_device_lock); | 682 | spin_unlock(&acpi_device_lock); |
@@ -723,21 +690,18 @@ acpi_bus_find_driver ( | |||
723 | } | 690 | } |
724 | spin_unlock(&acpi_device_lock); | 691 | spin_unlock(&acpi_device_lock); |
725 | 692 | ||
726 | Done: | 693 | Done: |
727 | return_VALUE(result); | 694 | return_VALUE(result); |
728 | } | 695 | } |
729 | 696 | ||
730 | |||
731 | /* -------------------------------------------------------------------------- | 697 | /* -------------------------------------------------------------------------- |
732 | Device Enumeration | 698 | Device Enumeration |
733 | -------------------------------------------------------------------------- */ | 699 | -------------------------------------------------------------------------- */ |
734 | 700 | ||
735 | static int | 701 | static int acpi_bus_get_flags(struct acpi_device *device) |
736 | acpi_bus_get_flags ( | ||
737 | struct acpi_device *device) | ||
738 | { | 702 | { |
739 | acpi_status status = AE_OK; | 703 | acpi_status status = AE_OK; |
740 | acpi_handle temp = NULL; | 704 | acpi_handle temp = NULL; |
741 | 705 | ||
742 | ACPI_FUNCTION_TRACE("acpi_bus_get_flags"); | 706 | ACPI_FUNCTION_TRACE("acpi_bus_get_flags"); |
743 | 707 | ||
@@ -788,11 +752,12 @@ acpi_bus_get_flags ( | |||
788 | return_VALUE(0); | 752 | return_VALUE(0); |
789 | } | 753 | } |
790 | 754 | ||
791 | static void acpi_device_get_busid(struct acpi_device * device, acpi_handle handle, int type) | 755 | static void acpi_device_get_busid(struct acpi_device *device, |
756 | acpi_handle handle, int type) | ||
792 | { | 757 | { |
793 | char bus_id[5] = {'?',0}; | 758 | char bus_id[5] = { '?', 0 }; |
794 | struct acpi_buffer buffer = {sizeof(bus_id), bus_id}; | 759 | struct acpi_buffer buffer = { sizeof(bus_id), bus_id }; |
795 | int i = 0; | 760 | int i = 0; |
796 | 761 | ||
797 | /* | 762 | /* |
798 | * Bus ID | 763 | * Bus ID |
@@ -824,21 +789,22 @@ static void acpi_device_get_busid(struct acpi_device * device, acpi_handle handl | |||
824 | } | 789 | } |
825 | } | 790 | } |
826 | 791 | ||
827 | static void acpi_device_set_id(struct acpi_device * device, struct acpi_device * parent, | 792 | static void acpi_device_set_id(struct acpi_device *device, |
828 | acpi_handle handle, int type) | 793 | struct acpi_device *parent, acpi_handle handle, |
794 | int type) | ||
829 | { | 795 | { |
830 | struct acpi_device_info *info; | 796 | struct acpi_device_info *info; |
831 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | 797 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
832 | char *hid = NULL; | 798 | char *hid = NULL; |
833 | char *uid = NULL; | 799 | char *uid = NULL; |
834 | struct acpi_compatible_id_list *cid_list = NULL; | 800 | struct acpi_compatible_id_list *cid_list = NULL; |
835 | acpi_status status; | 801 | acpi_status status; |
836 | 802 | ||
837 | switch (type) { | 803 | switch (type) { |
838 | case ACPI_BUS_TYPE_DEVICE: | 804 | case ACPI_BUS_TYPE_DEVICE: |
839 | status = acpi_get_object_info(handle, &buffer); | 805 | status = acpi_get_object_info(handle, &buffer); |
840 | if (ACPI_FAILURE(status)) { | 806 | if (ACPI_FAILURE(status)) { |
841 | printk("%s: Error reading device info\n",__FUNCTION__); | 807 | printk("%s: Error reading device info\n", __FUNCTION__); |
842 | return; | 808 | return; |
843 | } | 809 | } |
844 | 810 | ||
@@ -904,7 +870,7 @@ static void acpi_device_set_id(struct acpi_device * device, struct acpi_device * | |||
904 | acpi_os_free(buffer.pointer); | 870 | acpi_os_free(buffer.pointer); |
905 | } | 871 | } |
906 | 872 | ||
907 | static int acpi_device_set_context(struct acpi_device * device, int type) | 873 | static int acpi_device_set_context(struct acpi_device *device, int type) |
908 | { | 874 | { |
909 | acpi_status status = AE_OK; | 875 | acpi_status status = AE_OK; |
910 | int result = 0; | 876 | int result = 0; |
@@ -916,10 +882,10 @@ static int acpi_device_set_context(struct acpi_device * device, int type) | |||
916 | * to be careful with fixed-feature devices as they all attach to the | 882 | * to be careful with fixed-feature devices as they all attach to the |
917 | * root object. | 883 | * root object. |
918 | */ | 884 | */ |
919 | if (type != ACPI_BUS_TYPE_POWER_BUTTON && | 885 | if (type != ACPI_BUS_TYPE_POWER_BUTTON && |
920 | type != ACPI_BUS_TYPE_SLEEP_BUTTON) { | 886 | type != ACPI_BUS_TYPE_SLEEP_BUTTON) { |
921 | status = acpi_attach_data(device->handle, | 887 | status = acpi_attach_data(device->handle, |
922 | acpi_bus_data_handler, device); | 888 | acpi_bus_data_handler, device); |
923 | 889 | ||
924 | if (ACPI_FAILURE(status)) { | 890 | if (ACPI_FAILURE(status)) { |
925 | printk("Error attaching device data\n"); | 891 | printk("Error attaching device data\n"); |
@@ -929,12 +895,13 @@ static int acpi_device_set_context(struct acpi_device * device, int type) | |||
929 | return result; | 895 | return result; |
930 | } | 896 | } |
931 | 897 | ||
932 | static void acpi_device_get_debug_info(struct acpi_device * device, acpi_handle handle, int type) | 898 | static void acpi_device_get_debug_info(struct acpi_device *device, |
899 | acpi_handle handle, int type) | ||
933 | { | 900 | { |
934 | #ifdef CONFIG_ACPI_DEBUG_OUTPUT | 901 | #ifdef CONFIG_ACPI_DEBUG_OUTPUT |
935 | char *type_string = NULL; | 902 | char *type_string = NULL; |
936 | char name[80] = {'?','\0'}; | 903 | char name[80] = { '?', '\0' }; |
937 | struct acpi_buffer buffer = {sizeof(name), name}; | 904 | struct acpi_buffer buffer = { sizeof(name), name }; |
938 | 905 | ||
939 | switch (type) { | 906 | switch (type) { |
940 | case ACPI_BUS_TYPE_DEVICE: | 907 | case ACPI_BUS_TYPE_DEVICE: |
@@ -968,18 +935,14 @@ static void acpi_device_get_debug_info(struct acpi_device * device, acpi_handle | |||
968 | } | 935 | } |
969 | 936 | ||
970 | printk(KERN_DEBUG "Found %s %s [%p]\n", type_string, name, handle); | 937 | printk(KERN_DEBUG "Found %s %s [%p]\n", type_string, name, handle); |
971 | #endif /*CONFIG_ACPI_DEBUG_OUTPUT*/ | 938 | #endif /*CONFIG_ACPI_DEBUG_OUTPUT */ |
972 | } | 939 | } |
973 | 940 | ||
974 | 941 | static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) | |
975 | static int | ||
976 | acpi_bus_remove ( | ||
977 | struct acpi_device *dev, | ||
978 | int rmdevice) | ||
979 | { | 942 | { |
980 | int result = 0; | 943 | int result = 0; |
981 | struct acpi_driver *driver; | 944 | struct acpi_driver *driver; |
982 | 945 | ||
983 | ACPI_FUNCTION_TRACE("acpi_bus_remove"); | 946 | ACPI_FUNCTION_TRACE("acpi_bus_remove"); |
984 | 947 | ||
985 | if (!dev) | 948 | if (!dev) |
@@ -1012,22 +975,18 @@ acpi_bus_remove ( | |||
1012 | if ((dev->parent) && (dev->parent->ops.unbind)) | 975 | if ((dev->parent) && (dev->parent->ops.unbind)) |
1013 | dev->parent->ops.unbind(dev); | 976 | dev->parent->ops.unbind(dev); |
1014 | } | 977 | } |
1015 | 978 | ||
1016 | acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); | 979 | acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); |
1017 | 980 | ||
1018 | return_VALUE(0); | 981 | return_VALUE(0); |
1019 | } | 982 | } |
1020 | 983 | ||
1021 | |||
1022 | static int | 984 | static int |
1023 | acpi_add_single_object ( | 985 | acpi_add_single_object(struct acpi_device **child, |
1024 | struct acpi_device **child, | 986 | struct acpi_device *parent, acpi_handle handle, int type) |
1025 | struct acpi_device *parent, | ||
1026 | acpi_handle handle, | ||
1027 | int type) | ||
1028 | { | 987 | { |
1029 | int result = 0; | 988 | int result = 0; |
1030 | struct acpi_device *device = NULL; | 989 | struct acpi_device *device = NULL; |
1031 | 990 | ||
1032 | ACPI_FUNCTION_TRACE("acpi_add_single_object"); | 991 | ACPI_FUNCTION_TRACE("acpi_add_single_object"); |
1033 | 992 | ||
@@ -1044,7 +1003,7 @@ acpi_add_single_object ( | |||
1044 | device->handle = handle; | 1003 | device->handle = handle; |
1045 | device->parent = parent; | 1004 | device->parent = parent; |
1046 | 1005 | ||
1047 | acpi_device_get_busid(device,handle,type); | 1006 | acpi_device_get_busid(device, handle, type); |
1048 | 1007 | ||
1049 | /* | 1008 | /* |
1050 | * Flags | 1009 | * Flags |
@@ -1092,7 +1051,7 @@ acpi_add_single_object ( | |||
1092 | * Hardware ID, Unique ID, & Bus Address | 1051 | * Hardware ID, Unique ID, & Bus Address |
1093 | * ------------------------------------- | 1052 | * ------------------------------------- |
1094 | */ | 1053 | */ |
1095 | acpi_device_set_id(device,parent,handle,type); | 1054 | acpi_device_set_id(device, parent, handle, type); |
1096 | 1055 | ||
1097 | /* | 1056 | /* |
1098 | * Power Management | 1057 | * Power Management |
@@ -1104,7 +1063,7 @@ acpi_add_single_object ( | |||
1104 | goto end; | 1063 | goto end; |
1105 | } | 1064 | } |
1106 | 1065 | ||
1107 | /* | 1066 | /* |
1108 | * Wakeup device management | 1067 | * Wakeup device management |
1109 | *----------------------- | 1068 | *----------------------- |
1110 | */ | 1069 | */ |
@@ -1124,12 +1083,12 @@ acpi_add_single_object ( | |||
1124 | goto end; | 1083 | goto end; |
1125 | } | 1084 | } |
1126 | 1085 | ||
1127 | if ((result = acpi_device_set_context(device,type))) | 1086 | if ((result = acpi_device_set_context(device, type))) |
1128 | goto end; | 1087 | goto end; |
1129 | 1088 | ||
1130 | acpi_device_get_debug_info(device,handle,type); | 1089 | acpi_device_get_debug_info(device, handle, type); |
1131 | 1090 | ||
1132 | acpi_device_register(device,parent); | 1091 | acpi_device_register(device, parent); |
1133 | 1092 | ||
1134 | /* | 1093 | /* |
1135 | * Bind _ADR-Based Devices | 1094 | * Bind _ADR-Based Devices |
@@ -1154,7 +1113,7 @@ acpi_add_single_object ( | |||
1154 | */ | 1113 | */ |
1155 | result = acpi_bus_find_driver(device); | 1114 | result = acpi_bus_find_driver(device); |
1156 | 1115 | ||
1157 | end: | 1116 | end: |
1158 | if (!result) | 1117 | if (!result) |
1159 | *child = device; | 1118 | *child = device; |
1160 | else { | 1119 | else { |
@@ -1166,17 +1125,15 @@ end: | |||
1166 | return_VALUE(result); | 1125 | return_VALUE(result); |
1167 | } | 1126 | } |
1168 | 1127 | ||
1169 | 1128 | static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) | |
1170 | static int acpi_bus_scan (struct acpi_device *start, | ||
1171 | struct acpi_bus_ops *ops) | ||
1172 | { | 1129 | { |
1173 | acpi_status status = AE_OK; | 1130 | acpi_status status = AE_OK; |
1174 | struct acpi_device *parent = NULL; | 1131 | struct acpi_device *parent = NULL; |
1175 | struct acpi_device *child = NULL; | 1132 | struct acpi_device *child = NULL; |
1176 | acpi_handle phandle = NULL; | 1133 | acpi_handle phandle = NULL; |
1177 | acpi_handle chandle = NULL; | 1134 | acpi_handle chandle = NULL; |
1178 | acpi_object_type type = 0; | 1135 | acpi_object_type type = 0; |
1179 | u32 level = 1; | 1136 | u32 level = 1; |
1180 | 1137 | ||
1181 | ACPI_FUNCTION_TRACE("acpi_bus_scan"); | 1138 | ACPI_FUNCTION_TRACE("acpi_bus_scan"); |
1182 | 1139 | ||
@@ -1185,7 +1142,7 @@ static int acpi_bus_scan (struct acpi_device *start, | |||
1185 | 1142 | ||
1186 | parent = start; | 1143 | parent = start; |
1187 | phandle = start->handle; | 1144 | phandle = start->handle; |
1188 | 1145 | ||
1189 | /* | 1146 | /* |
1190 | * Parse through the ACPI namespace, identify all 'devices', and | 1147 | * Parse through the ACPI namespace, identify all 'devices', and |
1191 | * create a new 'struct acpi_device' for each. | 1148 | * create a new 'struct acpi_device' for each. |
@@ -1193,7 +1150,7 @@ static int acpi_bus_scan (struct acpi_device *start, | |||
1193 | while ((level > 0) && parent) { | 1150 | while ((level > 0) && parent) { |
1194 | 1151 | ||
1195 | status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, | 1152 | status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, |
1196 | chandle, &chandle); | 1153 | chandle, &chandle); |
1197 | 1154 | ||
1198 | /* | 1155 | /* |
1199 | * If this scope is exhausted then move our way back up. | 1156 | * If this scope is exhausted then move our way back up. |
@@ -1243,12 +1200,12 @@ static int acpi_bus_scan (struct acpi_device *start, | |||
1243 | 1200 | ||
1244 | if (ops->acpi_op_add) | 1201 | if (ops->acpi_op_add) |
1245 | status = acpi_add_single_object(&child, parent, | 1202 | status = acpi_add_single_object(&child, parent, |
1246 | chandle, type); | 1203 | chandle, type); |
1247 | else | 1204 | else |
1248 | status = acpi_bus_get_device(chandle, &child); | 1205 | status = acpi_bus_get_device(chandle, &child); |
1249 | 1206 | ||
1250 | if (ACPI_FAILURE(status)) | 1207 | if (ACPI_FAILURE(status)) |
1251 | continue; | 1208 | continue; |
1252 | 1209 | ||
1253 | if (ops->acpi_op_start) { | 1210 | if (ops->acpi_op_start) { |
1254 | status = acpi_start_single_object(child); | 1211 | status = acpi_start_single_object(child); |
@@ -1264,7 +1221,7 @@ static int acpi_bus_scan (struct acpi_device *start, | |||
1264 | * which will be enumerated when the parent is inserted). | 1221 | * which will be enumerated when the parent is inserted). |
1265 | * | 1222 | * |
1266 | * TBD: Need notifications and other detection mechanisms | 1223 | * TBD: Need notifications and other detection mechanisms |
1267 | * in place before we can fully implement this. | 1224 | * in place before we can fully implement this. |
1268 | */ | 1225 | */ |
1269 | if (child->status.present) { | 1226 | if (child->status.present) { |
1270 | status = acpi_get_next_object(ACPI_TYPE_ANY, chandle, | 1227 | status = acpi_get_next_object(ACPI_TYPE_ANY, chandle, |
@@ -1282,11 +1239,8 @@ static int acpi_bus_scan (struct acpi_device *start, | |||
1282 | } | 1239 | } |
1283 | 1240 | ||
1284 | int | 1241 | int |
1285 | acpi_bus_add ( | 1242 | acpi_bus_add(struct acpi_device **child, |
1286 | struct acpi_device **child, | 1243 | struct acpi_device *parent, acpi_handle handle, int type) |
1287 | struct acpi_device *parent, | ||
1288 | acpi_handle handle, | ||
1289 | int type) | ||
1290 | { | 1244 | { |
1291 | int result; | 1245 | int result; |
1292 | struct acpi_bus_ops ops; | 1246 | struct acpi_bus_ops ops; |
@@ -1301,11 +1255,10 @@ acpi_bus_add ( | |||
1301 | } | 1255 | } |
1302 | return_VALUE(result); | 1256 | return_VALUE(result); |
1303 | } | 1257 | } |
1258 | |||
1304 | EXPORT_SYMBOL(acpi_bus_add); | 1259 | EXPORT_SYMBOL(acpi_bus_add); |
1305 | 1260 | ||
1306 | int | 1261 | int acpi_bus_start(struct acpi_device *device) |
1307 | acpi_bus_start ( | ||
1308 | struct acpi_device *device) | ||
1309 | { | 1262 | { |
1310 | int result; | 1263 | int result; |
1311 | struct acpi_bus_ops ops; | 1264 | struct acpi_bus_ops ops; |
@@ -1323,26 +1276,25 @@ acpi_bus_start ( | |||
1323 | } | 1276 | } |
1324 | return_VALUE(result); | 1277 | return_VALUE(result); |
1325 | } | 1278 | } |
1279 | |||
1326 | EXPORT_SYMBOL(acpi_bus_start); | 1280 | EXPORT_SYMBOL(acpi_bus_start); |
1327 | 1281 | ||
1328 | static int | 1282 | static int acpi_bus_trim(struct acpi_device *start, int rmdevice) |
1329 | acpi_bus_trim(struct acpi_device *start, | ||
1330 | int rmdevice) | ||
1331 | { | 1283 | { |
1332 | acpi_status status; | 1284 | acpi_status status; |
1333 | struct acpi_device *parent, *child; | 1285 | struct acpi_device *parent, *child; |
1334 | acpi_handle phandle, chandle; | 1286 | acpi_handle phandle, chandle; |
1335 | acpi_object_type type; | 1287 | acpi_object_type type; |
1336 | u32 level = 1; | 1288 | u32 level = 1; |
1337 | int err = 0; | 1289 | int err = 0; |
1338 | 1290 | ||
1339 | parent = start; | 1291 | parent = start; |
1340 | phandle = start->handle; | 1292 | phandle = start->handle; |
1341 | child = chandle = NULL; | 1293 | child = chandle = NULL; |
1342 | 1294 | ||
1343 | while ((level > 0) && parent && (!err)) { | 1295 | while ((level > 0) && parent && (!err)) { |
1344 | status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, | 1296 | status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, |
1345 | chandle, &chandle); | 1297 | chandle, &chandle); |
1346 | 1298 | ||
1347 | /* | 1299 | /* |
1348 | * If this scope is exhausted then move our way back up. | 1300 | * If this scope is exhausted then move our way back up. |
@@ -1381,12 +1333,10 @@ acpi_bus_trim(struct acpi_device *start, | |||
1381 | return err; | 1333 | return err; |
1382 | } | 1334 | } |
1383 | 1335 | ||
1384 | static int | 1336 | static int acpi_bus_scan_fixed(struct acpi_device *root) |
1385 | acpi_bus_scan_fixed ( | ||
1386 | struct acpi_device *root) | ||
1387 | { | 1337 | { |
1388 | int result = 0; | 1338 | int result = 0; |
1389 | struct acpi_device *device = NULL; | 1339 | struct acpi_device *device = NULL; |
1390 | 1340 | ||
1391 | ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed"); | 1341 | ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed"); |
1392 | 1342 | ||
@@ -1398,14 +1348,16 @@ acpi_bus_scan_fixed ( | |||
1398 | */ | 1348 | */ |
1399 | if (acpi_fadt.pwr_button == 0) { | 1349 | if (acpi_fadt.pwr_button == 0) { |
1400 | result = acpi_add_single_object(&device, acpi_root, | 1350 | result = acpi_add_single_object(&device, acpi_root, |
1401 | NULL, ACPI_BUS_TYPE_POWER_BUTTON); | 1351 | NULL, |
1352 | ACPI_BUS_TYPE_POWER_BUTTON); | ||
1402 | if (!result) | 1353 | if (!result) |
1403 | result = acpi_start_single_object(device); | 1354 | result = acpi_start_single_object(device); |
1404 | } | 1355 | } |
1405 | 1356 | ||
1406 | if (acpi_fadt.sleep_button == 0) { | 1357 | if (acpi_fadt.sleep_button == 0) { |
1407 | result = acpi_add_single_object(&device, acpi_root, | 1358 | result = acpi_add_single_object(&device, acpi_root, |
1408 | NULL, ACPI_BUS_TYPE_SLEEP_BUTTON); | 1359 | NULL, |
1360 | ACPI_BUS_TYPE_SLEEP_BUTTON); | ||
1409 | if (!result) | 1361 | if (!result) |
1410 | result = acpi_start_single_object(device); | 1362 | result = acpi_start_single_object(device); |
1411 | } | 1363 | } |
@@ -1413,7 +1365,6 @@ acpi_bus_scan_fixed ( | |||
1413 | return_VALUE(result); | 1365 | return_VALUE(result); |
1414 | } | 1366 | } |
1415 | 1367 | ||
1416 | |||
1417 | static int __init acpi_scan_init(void) | 1368 | static int __init acpi_scan_init(void) |
1418 | { | 1369 | { |
1419 | int result; | 1370 | int result; |
@@ -1430,7 +1381,7 @@ static int __init acpi_scan_init(void) | |||
1430 | * Create the root device in the bus's device tree | 1381 | * Create the root device in the bus's device tree |
1431 | */ | 1382 | */ |
1432 | result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT, | 1383 | result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT, |
1433 | ACPI_BUS_TYPE_SYSTEM); | 1384 | ACPI_BUS_TYPE_SYSTEM); |
1434 | if (result) | 1385 | if (result) |
1435 | goto Done; | 1386 | goto Done; |
1436 | 1387 | ||
@@ -1450,7 +1401,7 @@ static int __init acpi_scan_init(void) | |||
1450 | if (result) | 1401 | if (result) |
1451 | acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); | 1402 | acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); |
1452 | 1403 | ||
1453 | Done: | 1404 | Done: |
1454 | return_VALUE(result); | 1405 | return_VALUE(result); |
1455 | } | 1406 | } |
1456 | 1407 | ||