aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/scan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r--drivers/acpi/scan.c704
1 files changed, 270 insertions, 434 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 408ebde18986..14a7481c97d7 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -22,6 +22,8 @@ extern struct acpi_device *acpi_root;
22#define ACPI_BUS_HID "LNXSYBUS" 22#define ACPI_BUS_HID "LNXSYBUS"
23#define ACPI_BUS_DEVICE_NAME "System Bus" 23#define ACPI_BUS_DEVICE_NAME "System Bus"
24 24
25#define ACPI_IS_ROOT_DEVICE(device) (!(device)->parent)
26
25static LIST_HEAD(acpi_device_list); 27static LIST_HEAD(acpi_device_list);
26static LIST_HEAD(acpi_bus_id_list); 28static LIST_HEAD(acpi_bus_id_list);
27DEFINE_MUTEX(acpi_device_lock); 29DEFINE_MUTEX(acpi_device_lock);
@@ -43,40 +45,19 @@ static int create_modalias(struct acpi_device *acpi_dev, char *modalias,
43{ 45{
44 int len; 46 int len;
45 int count; 47 int count;
46 48 struct acpi_hardware_id *id;
47 if (!acpi_dev->flags.hardware_id && !acpi_dev->flags.compatible_ids)
48 return -ENODEV;
49 49
50 len = snprintf(modalias, size, "acpi:"); 50 len = snprintf(modalias, size, "acpi:");
51 size -= len; 51 size -= len;
52 52
53 if (acpi_dev->flags.hardware_id) { 53 list_for_each_entry(id, &acpi_dev->pnp.ids, list) {
54 count = snprintf(&modalias[len], size, "%s:", 54 count = snprintf(&modalias[len], size, "%s:", id->id);
55 acpi_dev->pnp.hardware_id);
56 if (count < 0 || count >= size) 55 if (count < 0 || count >= size)
57 return -EINVAL; 56 return -EINVAL;
58 len += count; 57 len += count;
59 size -= count; 58 size -= count;
60 } 59 }
61 60
62 if (acpi_dev->flags.compatible_ids) {
63 struct acpica_device_id_list *cid_list;
64 int i;
65
66 cid_list = acpi_dev->pnp.cid_list;
67 for (i = 0; i < cid_list->count; i++) {
68 count = snprintf(&modalias[len], size, "%s:",
69 cid_list->ids[i].string);
70 if (count < 0 || count >= size) {
71 printk(KERN_ERR PREFIX "%s cid[%i] exceeds event buffer size",
72 acpi_dev->pnp.device_name, i);
73 break;
74 }
75 len += count;
76 size -= count;
77 }
78 }
79
80 modalias[len] = '\0'; 61 modalias[len] = '\0';
81 return len; 62 return len;
82} 63}
@@ -183,7 +164,7 @@ static ssize_t
183acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) { 164acpi_device_hid_show(struct device *dev, struct device_attribute *attr, char *buf) {
184 struct acpi_device *acpi_dev = to_acpi_device(dev); 165 struct acpi_device *acpi_dev = to_acpi_device(dev);
185 166
186 return sprintf(buf, "%s\n", acpi_dev->pnp.hardware_id); 167 return sprintf(buf, "%s\n", acpi_device_hid(acpi_dev));
187} 168}
188static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL); 169static DEVICE_ATTR(hid, 0444, acpi_device_hid_show, NULL);
189 170
@@ -219,17 +200,13 @@ static int acpi_device_setup_files(struct acpi_device *dev)
219 goto end; 200 goto end;
220 } 201 }
221 202
222 if (dev->flags.hardware_id) { 203 result = device_create_file(&dev->dev, &dev_attr_hid);
223 result = device_create_file(&dev->dev, &dev_attr_hid); 204 if (result)
224 if (result) 205 goto end;
225 goto end;
226 }
227 206
228 if (dev->flags.hardware_id || dev->flags.compatible_ids) { 207 result = device_create_file(&dev->dev, &dev_attr_modalias);
229 result = device_create_file(&dev->dev, &dev_attr_modalias); 208 if (result)
230 if (result) 209 goto end;
231 goto end;
232 }
233 210
234 /* 211 /*
235 * If device has _EJ0, 'eject' file is created that is used to trigger 212 * If device has _EJ0, 'eject' file is created that is used to trigger
@@ -255,11 +232,8 @@ static void acpi_device_remove_files(struct acpi_device *dev)
255 if (ACPI_SUCCESS(status)) 232 if (ACPI_SUCCESS(status))
256 device_remove_file(&dev->dev, &dev_attr_eject); 233 device_remove_file(&dev->dev, &dev_attr_eject);
257 234
258 if (dev->flags.hardware_id || dev->flags.compatible_ids) 235 device_remove_file(&dev->dev, &dev_attr_modalias);
259 device_remove_file(&dev->dev, &dev_attr_modalias); 236 device_remove_file(&dev->dev, &dev_attr_hid);
260
261 if (dev->flags.hardware_id)
262 device_remove_file(&dev->dev, &dev_attr_hid);
263 if (dev->handle) 237 if (dev->handle)
264 device_remove_file(&dev->dev, &dev_attr_path); 238 device_remove_file(&dev->dev, &dev_attr_path);
265} 239}
@@ -271,6 +245,7 @@ int acpi_match_device_ids(struct acpi_device *device,
271 const struct acpi_device_id *ids) 245 const struct acpi_device_id *ids)
272{ 246{
273 const struct acpi_device_id *id; 247 const struct acpi_device_id *id;
248 struct acpi_hardware_id *hwid;
274 249
275 /* 250 /*
276 * If the device is not present, it is unnecessary to load device 251 * If the device is not present, it is unnecessary to load device
@@ -279,40 +254,30 @@ int acpi_match_device_ids(struct acpi_device *device,
279 if (!device->status.present) 254 if (!device->status.present)
280 return -ENODEV; 255 return -ENODEV;
281 256
282 if (device->flags.hardware_id) { 257 for (id = ids; id->id[0]; id++)
283 for (id = ids; id->id[0]; id++) { 258 list_for_each_entry(hwid, &device->pnp.ids, list)
284 if (!strcmp((char*)id->id, device->pnp.hardware_id)) 259 if (!strcmp((char *) id->id, hwid->id))
285 return 0; 260 return 0;
286 }
287 }
288
289 if (device->flags.compatible_ids) {
290 struct acpica_device_id_list *cid_list = device->pnp.cid_list;
291 int i;
292
293 for (id = ids; id->id[0]; id++) {
294 /* compare multiple _CID entries against driver ids */
295 for (i = 0; i < cid_list->count; i++) {
296 if (!strcmp((char*)id->id,
297 cid_list->ids[i].string))
298 return 0;
299 }
300 }
301 }
302 261
303 return -ENOENT; 262 return -ENOENT;
304} 263}
305EXPORT_SYMBOL(acpi_match_device_ids); 264EXPORT_SYMBOL(acpi_match_device_ids);
306 265
266static void acpi_free_ids(struct acpi_device *device)
267{
268 struct acpi_hardware_id *id, *tmp;
269
270 list_for_each_entry_safe(id, tmp, &device->pnp.ids, list) {
271 kfree(id->id);
272 kfree(id);
273 }
274}
275
307static void acpi_device_release(struct device *dev) 276static void acpi_device_release(struct device *dev)
308{ 277{
309 struct acpi_device *acpi_dev = to_acpi_device(dev); 278 struct acpi_device *acpi_dev = to_acpi_device(dev);
310 279
311 kfree(acpi_dev->pnp.cid_list); 280 acpi_free_ids(acpi_dev);
312 if (acpi_dev->flags.hardware_id)
313 kfree(acpi_dev->pnp.hardware_id);
314 if (acpi_dev->flags.unique_id)
315 kfree(acpi_dev->pnp.unique_id);
316 kfree(acpi_dev); 281 kfree(acpi_dev);
317} 282}
318 283
@@ -378,15 +343,13 @@ static acpi_status acpi_device_notify_fixed(void *data)
378static int acpi_device_install_notify_handler(struct acpi_device *device) 343static int acpi_device_install_notify_handler(struct acpi_device *device)
379{ 344{
380 acpi_status status; 345 acpi_status status;
381 char *hid;
382 346
383 hid = acpi_device_hid(device); 347 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
384 if (!strcmp(hid, ACPI_BUTTON_HID_POWERF))
385 status = 348 status =
386 acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, 349 acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
387 acpi_device_notify_fixed, 350 acpi_device_notify_fixed,
388 device); 351 device);
389 else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEPF)) 352 else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
390 status = 353 status =
391 acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, 354 acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
392 acpi_device_notify_fixed, 355 acpi_device_notify_fixed,
@@ -404,10 +367,10 @@ static int acpi_device_install_notify_handler(struct acpi_device *device)
404 367
405static void acpi_device_remove_notify_handler(struct acpi_device *device) 368static void acpi_device_remove_notify_handler(struct acpi_device *device)
406{ 369{
407 if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF)) 370 if (device->device_type == ACPI_BUS_TYPE_POWER_BUTTON)
408 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON, 371 acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
409 acpi_device_notify_fixed); 372 acpi_device_notify_fixed);
410 else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF)) 373 else if (device->device_type == ACPI_BUS_TYPE_SLEEP_BUTTON)
411 acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON, 374 acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
412 acpi_device_notify_fixed); 375 acpi_device_notify_fixed);
413 else 376 else
@@ -474,12 +437,12 @@ struct bus_type acpi_bus_type = {
474 .uevent = acpi_device_uevent, 437 .uevent = acpi_device_uevent,
475}; 438};
476 439
477static int acpi_device_register(struct acpi_device *device, 440static int acpi_device_register(struct acpi_device *device)
478 struct acpi_device *parent)
479{ 441{
480 int result; 442 int result;
481 struct acpi_device_bus_id *acpi_device_bus_id, *new_bus_id; 443 struct acpi_device_bus_id *acpi_device_bus_id, *new_bus_id;
482 int found = 0; 444 int found = 0;
445
483 /* 446 /*
484 * Linkage 447 * Linkage
485 * ------- 448 * -------
@@ -501,8 +464,9 @@ static int acpi_device_register(struct acpi_device *device,
501 * If failed, create one and link it into acpi_bus_id_list 464 * If failed, create one and link it into acpi_bus_id_list
502 */ 465 */
503 list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node) { 466 list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node) {
504 if(!strcmp(acpi_device_bus_id->bus_id, device->flags.hardware_id? device->pnp.hardware_id : "device")) { 467 if (!strcmp(acpi_device_bus_id->bus_id,
505 acpi_device_bus_id->instance_no ++; 468 acpi_device_hid(device))) {
469 acpi_device_bus_id->instance_no++;
506 found = 1; 470 found = 1;
507 kfree(new_bus_id); 471 kfree(new_bus_id);
508 break; 472 break;
@@ -510,7 +474,7 @@ static int acpi_device_register(struct acpi_device *device,
510 } 474 }
511 if (!found) { 475 if (!found) {
512 acpi_device_bus_id = new_bus_id; 476 acpi_device_bus_id = new_bus_id;
513 strcpy(acpi_device_bus_id->bus_id, device->flags.hardware_id ? device->pnp.hardware_id : "device"); 477 strcpy(acpi_device_bus_id->bus_id, acpi_device_hid(device));
514 acpi_device_bus_id->instance_no = 0; 478 acpi_device_bus_id->instance_no = 0;
515 list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); 479 list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list);
516 } 480 }
@@ -524,7 +488,7 @@ static int acpi_device_register(struct acpi_device *device,
524 mutex_unlock(&acpi_device_lock); 488 mutex_unlock(&acpi_device_lock);
525 489
526 if (device->parent) 490 if (device->parent)
527 device->dev.parent = &parent->dev; 491 device->dev.parent = &device->parent->dev;
528 device->dev.bus = &acpi_bus_type; 492 device->dev.bus = &acpi_bus_type;
529 device->dev.release = &acpi_device_release; 493 device->dev.release = &acpi_device_release;
530 result = device_register(&device->dev); 494 result = device_register(&device->dev);
@@ -664,6 +628,33 @@ EXPORT_SYMBOL(acpi_bus_unregister_driver);
664/* -------------------------------------------------------------------------- 628/* --------------------------------------------------------------------------
665 Device Enumeration 629 Device Enumeration
666 -------------------------------------------------------------------------- */ 630 -------------------------------------------------------------------------- */
631static struct acpi_device *acpi_bus_get_parent(acpi_handle handle)
632{
633 acpi_status status;
634 int ret;
635 struct acpi_device *device;
636
637 /*
638 * Fixed hardware devices do not appear in the namespace and do not
639 * have handles, but we fabricate acpi_devices for them, so we have
640 * to deal with them specially.
641 */
642 if (handle == NULL)
643 return acpi_root;
644
645 do {
646 status = acpi_get_parent(handle, &handle);
647 if (status == AE_NULL_ENTRY)
648 return NULL;
649 if (ACPI_FAILURE(status))
650 return acpi_root;
651
652 ret = acpi_bus_get_device(handle, &device);
653 if (ret == 0)
654 return device;
655 } while (1);
656}
657
667acpi_status 658acpi_status
668acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd) 659acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd)
669{ 660{
@@ -876,11 +867,6 @@ static int acpi_bus_get_flags(struct acpi_device *device)
876 if (ACPI_SUCCESS(status)) 867 if (ACPI_SUCCESS(status))
877 device->flags.dynamic_status = 1; 868 device->flags.dynamic_status = 1;
878 869
879 /* Presence of _CID indicates 'compatible_ids' */
880 status = acpi_get_handle(device->handle, "_CID", &temp);
881 if (ACPI_SUCCESS(status))
882 device->flags.compatible_ids = 1;
883
884 /* Presence of _RMV indicates 'removable' */ 870 /* Presence of _RMV indicates 'removable' */
885 status = acpi_get_handle(device->handle, "_RMV", &temp); 871 status = acpi_get_handle(device->handle, "_RMV", &temp);
886 if (ACPI_SUCCESS(status)) 872 if (ACPI_SUCCESS(status))
@@ -918,8 +904,7 @@ static int acpi_bus_get_flags(struct acpi_device *device)
918 return 0; 904 return 0;
919} 905}
920 906
921static void acpi_device_get_busid(struct acpi_device *device, 907static void acpi_device_get_busid(struct acpi_device *device)
922 acpi_handle handle, int type)
923{ 908{
924 char bus_id[5] = { '?', 0 }; 909 char bus_id[5] = { '?', 0 };
925 struct acpi_buffer buffer = { sizeof(bus_id), bus_id }; 910 struct acpi_buffer buffer = { sizeof(bus_id), bus_id };
@@ -931,10 +916,12 @@ static void acpi_device_get_busid(struct acpi_device *device,
931 * The device's Bus ID is simply the object name. 916 * The device's Bus ID is simply the object name.
932 * TBD: Shouldn't this value be unique (within the ACPI namespace)? 917 * TBD: Shouldn't this value be unique (within the ACPI namespace)?
933 */ 918 */
934 switch (type) { 919 if (ACPI_IS_ROOT_DEVICE(device)) {
935 case ACPI_BUS_TYPE_SYSTEM:
936 strcpy(device->pnp.bus_id, "ACPI"); 920 strcpy(device->pnp.bus_id, "ACPI");
937 break; 921 return;
922 }
923
924 switch (device->device_type) {
938 case ACPI_BUS_TYPE_POWER_BUTTON: 925 case ACPI_BUS_TYPE_POWER_BUTTON:
939 strcpy(device->pnp.bus_id, "PWRF"); 926 strcpy(device->pnp.bus_id, "PWRF");
940 break; 927 break;
@@ -942,7 +929,7 @@ static void acpi_device_get_busid(struct acpi_device *device,
942 strcpy(device->pnp.bus_id, "SLPF"); 929 strcpy(device->pnp.bus_id, "SLPF");
943 break; 930 break;
944 default: 931 default:
945 acpi_get_name(handle, ACPI_SINGLE_NAME, &buffer); 932 acpi_get_name(device->handle, ACPI_SINGLE_NAME, &buffer);
946 /* Clean up trailing underscores (if any) */ 933 /* Clean up trailing underscores (if any) */
947 for (i = 3; i > 1; i--) { 934 for (i = 3; i > 1; i--) {
948 if (bus_id[i] == '_') 935 if (bus_id[i] == '_')
@@ -1000,204 +987,134 @@ static int acpi_dock_match(struct acpi_device *device)
1000 return acpi_get_handle(device->handle, "_DCK", &tmp); 987 return acpi_get_handle(device->handle, "_DCK", &tmp);
1001} 988}
1002 989
1003static struct acpica_device_id_list* 990char *acpi_device_hid(struct acpi_device *device)
1004acpi_add_cid(
1005 struct acpi_device_info *info,
1006 struct acpica_device_id *new_cid)
1007{ 991{
1008 struct acpica_device_id_list *cid; 992 struct acpi_hardware_id *hid;
1009 char *next_id_string;
1010 acpi_size cid_length;
1011 acpi_size new_cid_length;
1012 u32 i;
1013
1014
1015 /* Allocate new CID list with room for the new CID */
1016
1017 if (!new_cid)
1018 new_cid_length = info->compatible_id_list.list_size;
1019 else if (info->compatible_id_list.list_size)
1020 new_cid_length = info->compatible_id_list.list_size +
1021 new_cid->length + sizeof(struct acpica_device_id);
1022 else
1023 new_cid_length = sizeof(struct acpica_device_id_list) + new_cid->length;
1024
1025 cid = ACPI_ALLOCATE_ZEROED(new_cid_length);
1026 if (!cid) {
1027 return NULL;
1028 }
1029
1030 cid->list_size = new_cid_length;
1031 cid->count = info->compatible_id_list.count;
1032 if (new_cid)
1033 cid->count++;
1034 next_id_string = (char *) cid->ids + (cid->count * sizeof(struct acpica_device_id));
1035
1036 /* Copy all existing CIDs */
1037
1038 for (i = 0; i < info->compatible_id_list.count; i++) {
1039 cid_length = info->compatible_id_list.ids[i].length;
1040 cid->ids[i].string = next_id_string;
1041 cid->ids[i].length = cid_length;
1042 993
1043 ACPI_MEMCPY(next_id_string, info->compatible_id_list.ids[i].string, 994 hid = list_first_entry(&device->pnp.ids, struct acpi_hardware_id, list);
1044 cid_length); 995 return hid->id;
1045 996}
1046 next_id_string += cid_length; 997EXPORT_SYMBOL(acpi_device_hid);
1047 }
1048 998
1049 /* Append the new CID */ 999static void acpi_add_id(struct acpi_device *device, const char *dev_id)
1000{
1001 struct acpi_hardware_id *id;
1050 1002
1051 if (new_cid) { 1003 id = kmalloc(sizeof(*id), GFP_KERNEL);
1052 cid->ids[i].string = next_id_string; 1004 if (!id)
1053 cid->ids[i].length = new_cid->length; 1005 return;
1054 1006
1055 ACPI_MEMCPY(next_id_string, new_cid->string, new_cid->length); 1007 id->id = kmalloc(strlen(dev_id) + 1, GFP_KERNEL);
1008 if (!id->id) {
1009 kfree(id);
1010 return;
1056 } 1011 }
1057 1012
1058 return cid; 1013 strcpy(id->id, dev_id);
1014 list_add_tail(&id->list, &device->pnp.ids);
1059} 1015}
1060 1016
1061static void acpi_device_set_id(struct acpi_device *device, 1017static void acpi_device_set_id(struct acpi_device *device)
1062 struct acpi_device *parent, acpi_handle handle,
1063 int type)
1064{ 1018{
1065 struct acpi_device_info *info = NULL;
1066 char *hid = NULL;
1067 char *uid = NULL;
1068 struct acpica_device_id_list *cid_list = NULL;
1069 char *cid_add = NULL;
1070 acpi_status status; 1019 acpi_status status;
1020 struct acpi_device_info *info;
1021 struct acpica_device_id_list *cid_list;
1022 int i;
1071 1023
1072 switch (type) { 1024 switch (device->device_type) {
1073 case ACPI_BUS_TYPE_DEVICE: 1025 case ACPI_BUS_TYPE_DEVICE:
1074 status = acpi_get_object_info(handle, &info); 1026 if (ACPI_IS_ROOT_DEVICE(device)) {
1027 acpi_add_id(device, ACPI_SYSTEM_HID);
1028 break;
1029 } else if (ACPI_IS_ROOT_DEVICE(device->parent)) {
1030 /* \_SB_, the only root-level namespace device */
1031 acpi_add_id(device, ACPI_BUS_HID);
1032 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
1033 strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
1034 break;
1035 }
1036
1037 status = acpi_get_object_info(device->handle, &info);
1075 if (ACPI_FAILURE(status)) { 1038 if (ACPI_FAILURE(status)) {
1076 printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__); 1039 printk(KERN_ERR PREFIX "%s: Error reading device info\n", __func__);
1077 return; 1040 return;
1078 } 1041 }
1079 1042
1080 if (info->valid & ACPI_VALID_HID) 1043 if (info->valid & ACPI_VALID_HID)
1081 hid = info->hardware_id.string; 1044 acpi_add_id(device, info->hardware_id.string);
1082 if (info->valid & ACPI_VALID_UID) 1045 if (info->valid & ACPI_VALID_CID) {
1083 uid = info->unique_id.string;
1084 if (info->valid & ACPI_VALID_CID)
1085 cid_list = &info->compatible_id_list; 1046 cid_list = &info->compatible_id_list;
1047 for (i = 0; i < cid_list->count; i++)
1048 acpi_add_id(device, cid_list->ids[i].string);
1049 }
1086 if (info->valid & ACPI_VALID_ADR) { 1050 if (info->valid & ACPI_VALID_ADR) {
1087 device->pnp.bus_address = info->address; 1051 device->pnp.bus_address = info->address;
1088 device->flags.bus_address = 1; 1052 device->flags.bus_address = 1;
1089 } 1053 }
1090 1054
1091 /* If we have a video/bay/dock device, add our selfdefined 1055 kfree(info);
1092 HID to the CID list. Like that the video/bay/dock drivers 1056
1093 will get autoloaded and the device might still match 1057 /*
1094 against another driver. 1058 * Some devices don't reliably have _HIDs & _CIDs, so add
1095 */ 1059 * synthetic HIDs to make sure drivers can find them.
1060 */
1096 if (acpi_is_video_device(device)) 1061 if (acpi_is_video_device(device))
1097 cid_add = ACPI_VIDEO_HID; 1062 acpi_add_id(device, ACPI_VIDEO_HID);
1098 else if (ACPI_SUCCESS(acpi_bay_match(device))) 1063 else if (ACPI_SUCCESS(acpi_bay_match(device)))
1099 cid_add = ACPI_BAY_HID; 1064 acpi_add_id(device, ACPI_BAY_HID);
1100 else if (ACPI_SUCCESS(acpi_dock_match(device))) 1065 else if (ACPI_SUCCESS(acpi_dock_match(device)))
1101 cid_add = ACPI_DOCK_HID; 1066 acpi_add_id(device, ACPI_DOCK_HID);
1102 1067
1103 break; 1068 break;
1104 case ACPI_BUS_TYPE_POWER: 1069 case ACPI_BUS_TYPE_POWER:
1105 hid = ACPI_POWER_HID; 1070 acpi_add_id(device, ACPI_POWER_HID);
1106 break; 1071 break;
1107 case ACPI_BUS_TYPE_PROCESSOR: 1072 case ACPI_BUS_TYPE_PROCESSOR:
1108 hid = ACPI_PROCESSOR_OBJECT_HID; 1073 acpi_add_id(device, ACPI_PROCESSOR_OBJECT_HID);
1109 break;
1110 case ACPI_BUS_TYPE_SYSTEM:
1111 hid = ACPI_SYSTEM_HID;
1112 break; 1074 break;
1113 case ACPI_BUS_TYPE_THERMAL: 1075 case ACPI_BUS_TYPE_THERMAL:
1114 hid = ACPI_THERMAL_HID; 1076 acpi_add_id(device, ACPI_THERMAL_HID);
1115 break; 1077 break;
1116 case ACPI_BUS_TYPE_POWER_BUTTON: 1078 case ACPI_BUS_TYPE_POWER_BUTTON:
1117 hid = ACPI_BUTTON_HID_POWERF; 1079 acpi_add_id(device, ACPI_BUTTON_HID_POWERF);
1118 break; 1080 break;
1119 case ACPI_BUS_TYPE_SLEEP_BUTTON: 1081 case ACPI_BUS_TYPE_SLEEP_BUTTON:
1120 hid = ACPI_BUTTON_HID_SLEEPF; 1082 acpi_add_id(device, ACPI_BUTTON_HID_SLEEPF);
1121 break; 1083 break;
1122 } 1084 }
1123 1085
1124 /* 1086 /*
1125 * \_SB 1087 * We build acpi_devices for some objects that don't have _HID or _CID,
1126 * ---- 1088 * e.g., PCI bridges and slots. Drivers can't bind to these objects,
1127 * Fix for the system root bus device -- the only root-level device. 1089 * but we do use them indirectly by traversing the acpi_device tree.
1090 * This generic ID isn't useful for driver binding, but it provides
1091 * the useful property that "every acpi_device has an ID."
1128 */ 1092 */
1129 if (((acpi_handle)parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) { 1093 if (list_empty(&device->pnp.ids))
1130 hid = ACPI_BUS_HID; 1094 acpi_add_id(device, "device");
1131 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
1132 strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
1133 }
1134
1135 if (hid) {
1136 device->pnp.hardware_id = ACPI_ALLOCATE_ZEROED(strlen (hid) + 1);
1137 if (device->pnp.hardware_id) {
1138 strcpy(device->pnp.hardware_id, hid);
1139 device->flags.hardware_id = 1;
1140 }
1141 }
1142 if (!device->flags.hardware_id)
1143 device->pnp.hardware_id = "";
1144
1145 if (uid) {
1146 device->pnp.unique_id = ACPI_ALLOCATE_ZEROED(strlen (uid) + 1);
1147 if (device->pnp.unique_id) {
1148 strcpy(device->pnp.unique_id, uid);
1149 device->flags.unique_id = 1;
1150 }
1151 }
1152 if (!device->flags.unique_id)
1153 device->pnp.unique_id = "";
1154
1155 if (cid_list || cid_add) {
1156 struct acpica_device_id_list *list;
1157
1158 if (cid_add) {
1159 struct acpica_device_id cid;
1160 cid.length = strlen (cid_add) + 1;
1161 cid.string = cid_add;
1162
1163 list = acpi_add_cid(info, &cid);
1164 } else {
1165 list = acpi_add_cid(info, NULL);
1166 }
1167
1168 if (list) {
1169 device->pnp.cid_list = list;
1170 if (cid_add)
1171 device->flags.compatible_ids = 1;
1172 }
1173 }
1174
1175 kfree(info);
1176} 1095}
1177 1096
1178static int acpi_device_set_context(struct acpi_device *device, int type) 1097static int acpi_device_set_context(struct acpi_device *device)
1179{ 1098{
1180 acpi_status status = AE_OK; 1099 acpi_status status;
1181 int result = 0; 1100
1182 /* 1101 /*
1183 * Context 1102 * Context
1184 * ------- 1103 * -------
1185 * Attach this 'struct acpi_device' to the ACPI object. This makes 1104 * Attach this 'struct acpi_device' to the ACPI object. This makes
1186 * resolutions from handle->device very efficient. Note that we need 1105 * resolutions from handle->device very efficient. Fixed hardware
1187 * to be careful with fixed-feature devices as they all attach to the 1106 * devices have no handles, so we skip them.
1188 * root object.
1189 */ 1107 */
1190 if (type != ACPI_BUS_TYPE_POWER_BUTTON && 1108 if (!device->handle)
1191 type != ACPI_BUS_TYPE_SLEEP_BUTTON) { 1109 return 0;
1192 status = acpi_attach_data(device->handle,
1193 acpi_bus_data_handler, device);
1194 1110
1195 if (ACPI_FAILURE(status)) { 1111 status = acpi_attach_data(device->handle,
1196 printk(KERN_ERR PREFIX "Error attaching device data\n"); 1112 acpi_bus_data_handler, device);
1197 result = -ENODEV; 1113 if (ACPI_SUCCESS(status))
1198 } 1114 return 0;
1199 } 1115
1200 return result; 1116 printk(KERN_ERR PREFIX "Error attaching device data\n");
1117 return -ENODEV;
1201} 1118}
1202 1119
1203static int acpi_bus_remove(struct acpi_device *dev, int rmdevice) 1120static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
@@ -1223,17 +1140,14 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
1223 return 0; 1140 return 0;
1224} 1141}
1225 1142
1226static int 1143static int acpi_add_single_object(struct acpi_device **child,
1227acpi_add_single_object(struct acpi_device **child, 1144 acpi_handle handle, int type,
1228 struct acpi_device *parent, acpi_handle handle, int type, 1145 unsigned long long sta,
1229 struct acpi_bus_ops *ops) 1146 struct acpi_bus_ops *ops)
1230{ 1147{
1231 int result = 0; 1148 int result;
1232 struct acpi_device *device = NULL; 1149 struct acpi_device *device;
1233 1150 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
1234
1235 if (!child)
1236 return -EINVAL;
1237 1151
1238 device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL); 1152 device = kzalloc(sizeof(struct acpi_device), GFP_KERNEL);
1239 if (!device) { 1153 if (!device) {
@@ -1241,75 +1155,31 @@ acpi_add_single_object(struct acpi_device **child,
1241 return -ENOMEM; 1155 return -ENOMEM;
1242 } 1156 }
1243 1157
1158 INIT_LIST_HEAD(&device->pnp.ids);
1159 device->device_type = type;
1244 device->handle = handle; 1160 device->handle = handle;
1245 device->parent = parent; 1161 device->parent = acpi_bus_get_parent(handle);
1246 device->bus_ops = *ops; /* workround for not call .start */ 1162 device->bus_ops = *ops; /* workround for not call .start */
1163 STRUCT_TO_INT(device->status) = sta;
1247 1164
1248 1165 acpi_device_get_busid(device);
1249 acpi_device_get_busid(device, handle, type);
1250 1166
1251 /* 1167 /*
1252 * Flags 1168 * Flags
1253 * ----- 1169 * -----
1254 * Get prior to calling acpi_bus_get_status() so we know whether 1170 * Note that we only look for object handles -- cannot evaluate objects
1255 * or not _STA is present. Note that we only look for object 1171 * until we know the device is present and properly initialized.
1256 * handles -- cannot evaluate objects until we know the device is
1257 * present and properly initialized.
1258 */ 1172 */
1259 result = acpi_bus_get_flags(device); 1173 result = acpi_bus_get_flags(device);
1260 if (result) 1174 if (result)
1261 goto end; 1175 goto end;
1262 1176
1263 /* 1177 /*
1264 * Status
1265 * ------
1266 * See if the device is present. We always assume that non-Device
1267 * and non-Processor objects (e.g. thermal zones, power resources,
1268 * etc.) are present, functioning, etc. (at least when parent object
1269 * is present). Note that _STA has a different meaning for some
1270 * objects (e.g. power resources) so we need to be careful how we use
1271 * it.
1272 */
1273 switch (type) {
1274 case ACPI_BUS_TYPE_PROCESSOR:
1275 case ACPI_BUS_TYPE_DEVICE:
1276 result = acpi_bus_get_status(device);
1277 if (ACPI_FAILURE(result)) {
1278 result = -ENODEV;
1279 goto end;
1280 }
1281 /*
1282 * When the device is neither present nor functional, the
1283 * device should not be added to Linux ACPI device tree.
1284 * When the status of the device is not present but functinal,
1285 * it should be added to Linux ACPI tree. For example : bay
1286 * device , dock device.
1287 * In such conditions it is unncessary to check whether it is
1288 * bay device or dock device.
1289 */
1290 if (!device->status.present && !device->status.functional) {
1291 result = -ENODEV;
1292 goto end;
1293 }
1294 break;
1295 default:
1296 STRUCT_TO_INT(device->status) =
1297 ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED |
1298 ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING;
1299 break;
1300 }
1301
1302 /*
1303 * Initialize Device 1178 * Initialize Device
1304 * ----------------- 1179 * -----------------
1305 * TBD: Synch with Core's enumeration/initialization process. 1180 * TBD: Synch with Core's enumeration/initialization process.
1306 */ 1181 */
1307 1182 acpi_device_set_id(device);
1308 /*
1309 * Hardware ID, Unique ID, & Bus Address
1310 * -------------------------------------
1311 */
1312 acpi_device_set_id(device, parent, handle, type);
1313 1183
1314 /* 1184 /*
1315 * Power Management 1185 * Power Management
@@ -1341,10 +1211,10 @@ acpi_add_single_object(struct acpi_device **child,
1341 goto end; 1211 goto end;
1342 } 1212 }
1343 1213
1344 if ((result = acpi_device_set_context(device, type))) 1214 if ((result = acpi_device_set_context(device)))
1345 goto end; 1215 goto end;
1346 1216
1347 result = acpi_device_register(device, parent); 1217 result = acpi_device_register(device);
1348 1218
1349 /* 1219 /*
1350 * Bind _ADR-Based Devices when hot add 1220 * Bind _ADR-Based Devices when hot add
@@ -1355,128 +1225,117 @@ acpi_add_single_object(struct acpi_device **child,
1355 } 1225 }
1356 1226
1357end: 1227end:
1358 if (!result) 1228 if (!result) {
1229 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
1230 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1231 "Adding %s [%s] parent %s\n", dev_name(&device->dev),
1232 (char *) buffer.pointer,
1233 device->parent ? dev_name(&device->parent->dev) :
1234 "(null)"));
1235 kfree(buffer.pointer);
1359 *child = device; 1236 *child = device;
1360 else 1237 } else
1361 acpi_device_release(&device->dev); 1238 acpi_device_release(&device->dev);
1362 1239
1363 return result; 1240 return result;
1364} 1241}
1365 1242
1366static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) 1243#define ACPI_STA_DEFAULT (ACPI_STA_DEVICE_PRESENT | ACPI_STA_DEVICE_ENABLED | \
1367{ 1244 ACPI_STA_DEVICE_UI | ACPI_STA_DEVICE_FUNCTIONING)
1368 acpi_status status = AE_OK;
1369 struct acpi_device *parent = NULL;
1370 struct acpi_device *child = NULL;
1371 acpi_handle phandle = NULL;
1372 acpi_handle chandle = NULL;
1373 acpi_object_type type = 0;
1374 u32 level = 1;
1375
1376 1245
1377 if (!start) 1246static int acpi_bus_type_and_status(acpi_handle handle, int *type,
1378 return -EINVAL; 1247 unsigned long long *sta)
1248{
1249 acpi_status status;
1250 acpi_object_type acpi_type;
1379 1251
1380 parent = start; 1252 status = acpi_get_type(handle, &acpi_type);
1381 phandle = start->handle; 1253 if (ACPI_FAILURE(status))
1254 return -ENODEV;
1382 1255
1383 /* 1256 switch (acpi_type) {
1384 * Parse through the ACPI namespace, identify all 'devices', and 1257 case ACPI_TYPE_ANY: /* for ACPI_ROOT_OBJECT */
1385 * create a new 'struct acpi_device' for each. 1258 case ACPI_TYPE_DEVICE:
1386 */ 1259 *type = ACPI_BUS_TYPE_DEVICE;
1387 while ((level > 0) && parent) { 1260 status = acpi_bus_get_status_handle(handle, sta);
1261 if (ACPI_FAILURE(status))
1262 return -ENODEV;
1263 break;
1264 case ACPI_TYPE_PROCESSOR:
1265 *type = ACPI_BUS_TYPE_PROCESSOR;
1266 status = acpi_bus_get_status_handle(handle, sta);
1267 if (ACPI_FAILURE(status))
1268 return -ENODEV;
1269 break;
1270 case ACPI_TYPE_THERMAL:
1271 *type = ACPI_BUS_TYPE_THERMAL;
1272 *sta = ACPI_STA_DEFAULT;
1273 break;
1274 case ACPI_TYPE_POWER:
1275 *type = ACPI_BUS_TYPE_POWER;
1276 *sta = ACPI_STA_DEFAULT;
1277 break;
1278 default:
1279 return -ENODEV;
1280 }
1388 1281
1389 status = acpi_get_next_object(ACPI_TYPE_ANY, phandle, 1282 return 0;
1390 chandle, &chandle); 1283}
1391 1284
1392 /* 1285static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl,
1393 * If this scope is exhausted then move our way back up. 1286 void *context, void **return_value)
1394 */ 1287{
1395 if (ACPI_FAILURE(status)) { 1288 struct acpi_bus_ops *ops = context;
1396 level--; 1289 int type;
1397 chandle = phandle; 1290 unsigned long long sta;
1398 acpi_get_parent(phandle, &phandle); 1291 struct acpi_device *device;
1399 if (parent->parent) 1292 acpi_status status;
1400 parent = parent->parent; 1293 int result;
1401 continue;
1402 }
1403 1294
1404 status = acpi_get_type(chandle, &type); 1295 result = acpi_bus_type_and_status(handle, &type, &sta);
1405 if (ACPI_FAILURE(status)) 1296 if (result)
1406 continue; 1297 return AE_OK;
1407 1298
1408 /* 1299 if (!(sta & ACPI_STA_DEVICE_PRESENT) &&
1409 * If this is a scope object then parse it (depth-first). 1300 !(sta & ACPI_STA_DEVICE_FUNCTIONING))
1410 */ 1301 return AE_CTRL_DEPTH;
1411 if (type == ACPI_TYPE_LOCAL_SCOPE) {
1412 level++;
1413 phandle = chandle;
1414 chandle = NULL;
1415 continue;
1416 }
1417 1302
1418 /* 1303 /*
1419 * We're only interested in objects that we consider 'devices'. 1304 * We may already have an acpi_device from a previous enumeration. If
1420 */ 1305 * so, we needn't add it again, but we may still have to start it.
1421 switch (type) { 1306 */
1422 case ACPI_TYPE_DEVICE: 1307 device = NULL;
1423 type = ACPI_BUS_TYPE_DEVICE; 1308 acpi_bus_get_device(handle, &device);
1424 break; 1309 if (ops->acpi_op_add && !device)
1425 case ACPI_TYPE_PROCESSOR: 1310 acpi_add_single_object(&device, handle, type, sta, ops);
1426 type = ACPI_BUS_TYPE_PROCESSOR;
1427 break;
1428 case ACPI_TYPE_THERMAL:
1429 type = ACPI_BUS_TYPE_THERMAL;
1430 break;
1431 case ACPI_TYPE_POWER:
1432 type = ACPI_BUS_TYPE_POWER;
1433 break;
1434 default:
1435 continue;
1436 }
1437 1311
1438 if (ops->acpi_op_add) 1312 if (!device)
1439 status = acpi_add_single_object(&child, parent, 1313 return AE_CTRL_DEPTH;
1440 chandle, type, ops);
1441 else
1442 status = acpi_bus_get_device(chandle, &child);
1443 1314
1315 if (ops->acpi_op_start && !(ops->acpi_op_add)) {
1316 status = acpi_start_single_object(device);
1444 if (ACPI_FAILURE(status)) 1317 if (ACPI_FAILURE(status))
1445 continue; 1318 return AE_CTRL_DEPTH;
1319 }
1446 1320
1447 if (ops->acpi_op_start && !(ops->acpi_op_add)) { 1321 if (!*return_value)
1448 status = acpi_start_single_object(child); 1322 *return_value = device;
1449 if (ACPI_FAILURE(status)) 1323 return AE_OK;
1450 continue; 1324}
1451 }
1452 1325
1453 /* 1326static int acpi_bus_scan(acpi_handle handle, struct acpi_bus_ops *ops,
1454 * If the device is present, enabled, and functioning then 1327 struct acpi_device **child)
1455 * parse its scope (depth-first). Note that we need to 1328{
1456 * represent absent devices to facilitate PnP notifications 1329 acpi_status status;
1457 * -- but only the subtree head (not all of its children, 1330 void *device = NULL;
1458 * which will be enumerated when the parent is inserted). 1331
1459 * 1332 status = acpi_bus_check_add(handle, 0, ops, &device);
1460 * TBD: Need notifications and other detection mechanisms 1333 if (ACPI_SUCCESS(status))
1461 * in place before we can fully implement this. 1334 acpi_walk_namespace(ACPI_TYPE_ANY, handle, ACPI_UINT32_MAX,
1462 */ 1335 acpi_bus_check_add, ops, &device);
1463 /*
1464 * When the device is not present but functional, it is also
1465 * necessary to scan the children of this device.
1466 */
1467 if (child->status.present || (!child->status.present &&
1468 child->status.functional)) {
1469 status = acpi_get_next_object(ACPI_TYPE_ANY, chandle,
1470 NULL, NULL);
1471 if (ACPI_SUCCESS(status)) {
1472 level++;
1473 phandle = chandle;
1474 chandle = NULL;
1475 parent = child;
1476 }
1477 }
1478 }
1479 1336
1337 if (child)
1338 *child = device;
1480 return 0; 1339 return 0;
1481} 1340}
1482 1341
@@ -1484,36 +1343,25 @@ int
1484acpi_bus_add(struct acpi_device **child, 1343acpi_bus_add(struct acpi_device **child,
1485 struct acpi_device *parent, acpi_handle handle, int type) 1344 struct acpi_device *parent, acpi_handle handle, int type)
1486{ 1345{
1487 int result;
1488 struct acpi_bus_ops ops; 1346 struct acpi_bus_ops ops;
1489 1347
1490 memset(&ops, 0, sizeof(ops)); 1348 memset(&ops, 0, sizeof(ops));
1491 ops.acpi_op_add = 1; 1349 ops.acpi_op_add = 1;
1492 1350
1493 result = acpi_add_single_object(child, parent, handle, type, &ops); 1351 acpi_bus_scan(handle, &ops, child);
1494 if (!result) 1352 return 0;
1495 result = acpi_bus_scan(*child, &ops);
1496
1497 return result;
1498} 1353}
1499EXPORT_SYMBOL(acpi_bus_add); 1354EXPORT_SYMBOL(acpi_bus_add);
1500 1355
1501int acpi_bus_start(struct acpi_device *device) 1356int acpi_bus_start(struct acpi_device *device)
1502{ 1357{
1503 int result;
1504 struct acpi_bus_ops ops; 1358 struct acpi_bus_ops ops;
1505 1359
1360 memset(&ops, 0, sizeof(ops));
1361 ops.acpi_op_start = 1;
1506 1362
1507 if (!device) 1363 acpi_bus_scan(device->handle, &ops, NULL);
1508 return -EINVAL; 1364 return 0;
1509
1510 result = acpi_start_single_object(device);
1511 if (!result) {
1512 memset(&ops, 0, sizeof(ops));
1513 ops.acpi_op_start = 1;
1514 result = acpi_bus_scan(device, &ops);
1515 }
1516 return result;
1517} 1365}
1518EXPORT_SYMBOL(acpi_bus_start); 1366EXPORT_SYMBOL(acpi_bus_start);
1519 1367
@@ -1572,15 +1420,12 @@ int acpi_bus_trim(struct acpi_device *start, int rmdevice)
1572} 1420}
1573EXPORT_SYMBOL_GPL(acpi_bus_trim); 1421EXPORT_SYMBOL_GPL(acpi_bus_trim);
1574 1422
1575static int acpi_bus_scan_fixed(struct acpi_device *root) 1423static int acpi_bus_scan_fixed(void)
1576{ 1424{
1577 int result = 0; 1425 int result = 0;
1578 struct acpi_device *device = NULL; 1426 struct acpi_device *device = NULL;
1579 struct acpi_bus_ops ops; 1427 struct acpi_bus_ops ops;
1580 1428
1581 if (!root)
1582 return -ENODEV;
1583
1584 memset(&ops, 0, sizeof(ops)); 1429 memset(&ops, 0, sizeof(ops));
1585 ops.acpi_op_add = 1; 1430 ops.acpi_op_add = 1;
1586 ops.acpi_op_start = 1; 1431 ops.acpi_op_start = 1;
@@ -1589,16 +1434,16 @@ static int acpi_bus_scan_fixed(struct acpi_device *root)
1589 * Enumerate all fixed-feature devices. 1434 * Enumerate all fixed-feature devices.
1590 */ 1435 */
1591 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) { 1436 if ((acpi_gbl_FADT.flags & ACPI_FADT_POWER_BUTTON) == 0) {
1592 result = acpi_add_single_object(&device, acpi_root, 1437 result = acpi_add_single_object(&device, NULL,
1593 NULL,
1594 ACPI_BUS_TYPE_POWER_BUTTON, 1438 ACPI_BUS_TYPE_POWER_BUTTON,
1439 ACPI_STA_DEFAULT,
1595 &ops); 1440 &ops);
1596 } 1441 }
1597 1442
1598 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) { 1443 if ((acpi_gbl_FADT.flags & ACPI_FADT_SLEEP_BUTTON) == 0) {
1599 result = acpi_add_single_object(&device, acpi_root, 1444 result = acpi_add_single_object(&device, NULL,
1600 NULL,
1601 ACPI_BUS_TYPE_SLEEP_BUTTON, 1445 ACPI_BUS_TYPE_SLEEP_BUTTON,
1446 ACPI_STA_DEFAULT,
1602 &ops); 1447 &ops);
1603 } 1448 }
1604 1449
@@ -1621,24 +1466,15 @@ int __init acpi_scan_init(void)
1621 } 1466 }
1622 1467
1623 /* 1468 /*
1624 * Create the root device in the bus's device tree
1625 */
1626 result = acpi_add_single_object(&acpi_root, NULL, ACPI_ROOT_OBJECT,
1627 ACPI_BUS_TYPE_SYSTEM, &ops);
1628 if (result)
1629 goto Done;
1630
1631 /*
1632 * Enumerate devices in the ACPI namespace. 1469 * Enumerate devices in the ACPI namespace.
1633 */ 1470 */
1634 result = acpi_bus_scan_fixed(acpi_root); 1471 result = acpi_bus_scan(ACPI_ROOT_OBJECT, &ops, &acpi_root);
1635 1472
1636 if (!result) 1473 if (!result)
1637 result = acpi_bus_scan(acpi_root, &ops); 1474 result = acpi_bus_scan_fixed();
1638 1475
1639 if (result) 1476 if (result)
1640 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1477 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
1641 1478
1642Done:
1643 return result; 1479 return result;
1644} 1480}