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.c109
1 files changed, 57 insertions, 52 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index f8316a05ede7..861ac378ce42 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -162,11 +162,10 @@ static void acpi_device_unregister(struct acpi_device *device, int type)
162 162
163void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context) 163void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context)
164{ 164{
165 ACPI_FUNCTION_TRACE("acpi_bus_data_handler");
166 165
167 /* TBD */ 166 /* TBD */
168 167
169 return_VOID; 168 return;
170} 169}
171 170
172static int acpi_bus_get_power_flags(struct acpi_device *device) 171static int acpi_bus_get_power_flags(struct acpi_device *device)
@@ -175,7 +174,6 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
175 acpi_handle handle = NULL; 174 acpi_handle handle = NULL;
176 u32 i = 0; 175 u32 i = 0;
177 176
178 ACPI_FUNCTION_TRACE("acpi_bus_get_power_flags");
179 177
180 /* 178 /*
181 * Power Management Flags 179 * Power Management Flags
@@ -228,7 +226,7 @@ static int acpi_bus_get_power_flags(struct acpi_device *device)
228 226
229 device->power.state = ACPI_STATE_UNKNOWN; 227 device->power.state = ACPI_STATE_UNKNOWN;
230 228
231 return_VALUE(0); 229 return 0;
232} 230}
233 231
234int acpi_match_ids(struct acpi_device *device, char *ids) 232int acpi_match_ids(struct acpi_device *device, char *ids)
@@ -306,20 +304,18 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
306 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 304 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
307 union acpi_object *package = NULL; 305 union acpi_object *package = NULL;
308 306
309 ACPI_FUNCTION_TRACE("acpi_bus_get_wakeup_flags");
310 307
311 /* _PRW */ 308 /* _PRW */
312 status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer); 309 status = acpi_evaluate_object(device->handle, "_PRW", NULL, &buffer);
313 if (ACPI_FAILURE(status)) { 310 if (ACPI_FAILURE(status)) {
314 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error evaluating _PRW\n")); 311 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRW"));
315 goto end; 312 goto end;
316 } 313 }
317 314
318 package = (union acpi_object *)buffer.pointer; 315 package = (union acpi_object *)buffer.pointer;
319 status = acpi_bus_extract_wakeup_device_power_package(device, package); 316 status = acpi_bus_extract_wakeup_device_power_package(device, package);
320 if (ACPI_FAILURE(status)) { 317 if (ACPI_FAILURE(status)) {
321 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 318 ACPI_EXCEPTION((AE_INFO, status, "Extracting _PRW package"));
322 "Error extracting _PRW package\n"));
323 goto end; 319 goto end;
324 } 320 }
325 321
@@ -333,7 +329,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
333 end: 329 end:
334 if (ACPI_FAILURE(status)) 330 if (ACPI_FAILURE(status))
335 device->flags.wake_capable = 0; 331 device->flags.wake_capable = 0;
336 return_VALUE(0); 332 return 0;
337} 333}
338 334
339/* -------------------------------------------------------------------------- 335/* --------------------------------------------------------------------------
@@ -489,19 +485,18 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
489{ 485{
490 int result = 0; 486 int result = 0;
491 487
492 ACPI_FUNCTION_TRACE("acpi_bus_driver_init");
493 488
494 if (!device || !driver) 489 if (!device || !driver)
495 return_VALUE(-EINVAL); 490 return -EINVAL;
496 491
497 if (!driver->ops.add) 492 if (!driver->ops.add)
498 return_VALUE(-ENOSYS); 493 return -ENOSYS;
499 494
500 result = driver->ops.add(device); 495 result = driver->ops.add(device);
501 if (result) { 496 if (result) {
502 device->driver = NULL; 497 device->driver = NULL;
503 acpi_driver_data(device) = NULL; 498 acpi_driver_data(device) = NULL;
504 return_VALUE(result); 499 return result;
505 } 500 }
506 501
507 device->driver = driver; 502 device->driver = driver;
@@ -513,7 +508,7 @@ acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
513 508
514 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 509 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
515 "Driver successfully bound to device\n")); 510 "Driver successfully bound to device\n"));
516 return_VALUE(0); 511 return 0;
517} 512}
518 513
519static int acpi_start_single_object(struct acpi_device *device) 514static int acpi_start_single_object(struct acpi_device *device)
@@ -521,10 +516,9 @@ static int acpi_start_single_object(struct acpi_device *device)
521 int result = 0; 516 int result = 0;
522 struct acpi_driver *driver; 517 struct acpi_driver *driver;
523 518
524 ACPI_FUNCTION_TRACE("acpi_start_single_object");
525 519
526 if (!(driver = device->driver)) 520 if (!(driver = device->driver))
527 return_VALUE(0); 521 return 0;
528 522
529 if (driver->ops.start) { 523 if (driver->ops.start) {
530 result = driver->ops.start(device); 524 result = driver->ops.start(device);
@@ -532,14 +526,13 @@ static int acpi_start_single_object(struct acpi_device *device)
532 driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL); 526 driver->ops.remove(device, ACPI_BUS_REMOVAL_NORMAL);
533 } 527 }
534 528
535 return_VALUE(result); 529 return result;
536} 530}
537 531
538static void acpi_driver_attach(struct acpi_driver *drv) 532static void acpi_driver_attach(struct acpi_driver *drv)
539{ 533{
540 struct list_head *node, *next; 534 struct list_head *node, *next;
541 535
542 ACPI_FUNCTION_TRACE("acpi_driver_attach");
543 536
544 spin_lock(&acpi_device_lock); 537 spin_lock(&acpi_device_lock);
545 list_for_each_safe(node, next, &acpi_device_list) { 538 list_for_each_safe(node, next, &acpi_device_list) {
@@ -568,7 +561,6 @@ static void acpi_driver_detach(struct acpi_driver *drv)
568{ 561{
569 struct list_head *node, *next; 562 struct list_head *node, *next;
570 563
571 ACPI_FUNCTION_TRACE("acpi_driver_detach");
572 564
573 spin_lock(&acpi_device_lock); 565 spin_lock(&acpi_device_lock);
574 list_for_each_safe(node, next, &acpi_device_list) { 566 list_for_each_safe(node, next, &acpi_device_list) {
@@ -598,17 +590,16 @@ static void acpi_driver_detach(struct acpi_driver *drv)
598 */ 590 */
599int acpi_bus_register_driver(struct acpi_driver *driver) 591int acpi_bus_register_driver(struct acpi_driver *driver)
600{ 592{
601 ACPI_FUNCTION_TRACE("acpi_bus_register_driver");
602 593
603 if (acpi_disabled) 594 if (acpi_disabled)
604 return_VALUE(-ENODEV); 595 return -ENODEV;
605 596
606 spin_lock(&acpi_device_lock); 597 spin_lock(&acpi_device_lock);
607 list_add_tail(&driver->node, &acpi_bus_drivers); 598 list_add_tail(&driver->node, &acpi_bus_drivers);
608 spin_unlock(&acpi_device_lock); 599 spin_unlock(&acpi_device_lock);
609 acpi_driver_attach(driver); 600 acpi_driver_attach(driver);
610 601
611 return_VALUE(0); 602 return 0;
612} 603}
613 604
614EXPORT_SYMBOL(acpi_bus_register_driver); 605EXPORT_SYMBOL(acpi_bus_register_driver);
@@ -646,7 +637,6 @@ static int acpi_bus_find_driver(struct acpi_device *device)
646 int result = 0; 637 int result = 0;
647 struct list_head *node, *next; 638 struct list_head *node, *next;
648 639
649 ACPI_FUNCTION_TRACE("acpi_bus_find_driver");
650 640
651 spin_lock(&acpi_device_lock); 641 spin_lock(&acpi_device_lock);
652 list_for_each_safe(node, next, &acpi_bus_drivers) { 642 list_for_each_safe(node, next, &acpi_bus_drivers) {
@@ -666,19 +656,41 @@ static int acpi_bus_find_driver(struct acpi_device *device)
666 spin_unlock(&acpi_device_lock); 656 spin_unlock(&acpi_device_lock);
667 657
668 Done: 658 Done:
669 return_VALUE(result); 659 return result;
670} 660}
671 661
672/* -------------------------------------------------------------------------- 662/* --------------------------------------------------------------------------
673 Device Enumeration 663 Device Enumeration
674 -------------------------------------------------------------------------- */ 664 -------------------------------------------------------------------------- */
675 665
666acpi_status
667acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd)
668{
669 acpi_status status;
670 acpi_handle tmp;
671 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
672 union acpi_object *obj;
673
674 status = acpi_get_handle(handle, "_EJD", &tmp);
675 if (ACPI_FAILURE(status))
676 return status;
677
678 status = acpi_evaluate_object(handle, "_EJD", NULL, &buffer);
679 if (ACPI_SUCCESS(status)) {
680 obj = buffer.pointer;
681 status = acpi_get_handle(NULL, obj->string.pointer, ejd);
682 kfree(buffer.pointer);
683 }
684 return status;
685}
686EXPORT_SYMBOL_GPL(acpi_bus_get_ejd);
687
688
676static int acpi_bus_get_flags(struct acpi_device *device) 689static int acpi_bus_get_flags(struct acpi_device *device)
677{ 690{
678 acpi_status status = AE_OK; 691 acpi_status status = AE_OK;
679 acpi_handle temp = NULL; 692 acpi_handle temp = NULL;
680 693
681 ACPI_FUNCTION_TRACE("acpi_bus_get_flags");
682 694
683 /* Presence of _STA indicates 'dynamic_status' */ 695 /* Presence of _STA indicates 'dynamic_status' */
684 status = acpi_get_handle(device->handle, "_STA", &temp); 696 status = acpi_get_handle(device->handle, "_STA", &temp);
@@ -724,7 +736,7 @@ static int acpi_bus_get_flags(struct acpi_device *device)
724 736
725 /* TBD: Peformance management */ 737 /* TBD: Peformance management */
726 738
727 return_VALUE(0); 739 return 0;
728} 740}
729 741
730static void acpi_device_get_busid(struct acpi_device *device, 742static void acpi_device_get_busid(struct acpi_device *device,
@@ -918,10 +930,9 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
918 int result = 0; 930 int result = 0;
919 struct acpi_driver *driver; 931 struct acpi_driver *driver;
920 932
921 ACPI_FUNCTION_TRACE("acpi_bus_remove");
922 933
923 if (!dev) 934 if (!dev)
924 return_VALUE(-EINVAL); 935 return -EINVAL;
925 936
926 driver = dev->driver; 937 driver = dev->driver;
927 938
@@ -930,12 +941,12 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
930 if (driver->ops.stop) { 941 if (driver->ops.stop) {
931 result = driver->ops.stop(dev, ACPI_BUS_REMOVAL_EJECT); 942 result = driver->ops.stop(dev, ACPI_BUS_REMOVAL_EJECT);
932 if (result) 943 if (result)
933 return_VALUE(result); 944 return result;
934 } 945 }
935 946
936 result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT); 947 result = dev->driver->ops.remove(dev, ACPI_BUS_REMOVAL_EJECT);
937 if (result) { 948 if (result) {
938 return_VALUE(result); 949 return result;
939 } 950 }
940 951
941 atomic_dec(&dev->driver->references); 952 atomic_dec(&dev->driver->references);
@@ -944,7 +955,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
944 } 955 }
945 956
946 if (!rmdevice) 957 if (!rmdevice)
947 return_VALUE(0); 958 return 0;
948 959
949 if (dev->flags.bus_address) { 960 if (dev->flags.bus_address) {
950 if ((dev->parent) && (dev->parent->ops.unbind)) 961 if ((dev->parent) && (dev->parent->ops.unbind))
@@ -953,7 +964,7 @@ static int acpi_bus_remove(struct acpi_device *dev, int rmdevice)
953 964
954 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT); 965 acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
955 966
956 return_VALUE(0); 967 return 0;
957} 968}
958 969
959static int 970static int
@@ -963,15 +974,14 @@ acpi_add_single_object(struct acpi_device **child,
963 int result = 0; 974 int result = 0;
964 struct acpi_device *device = NULL; 975 struct acpi_device *device = NULL;
965 976
966 ACPI_FUNCTION_TRACE("acpi_add_single_object");
967 977
968 if (!child) 978 if (!child)
969 return_VALUE(-EINVAL); 979 return -EINVAL;
970 980
971 device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL); 981 device = kmalloc(sizeof(struct acpi_device), GFP_KERNEL);
972 if (!device) { 982 if (!device) {
973 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Memory allocation error\n")); 983 printk(KERN_ERR PREFIX "Memory allocation error\n");
974 return_VALUE(-ENOMEM); 984 return -ENOMEM;
975 } 985 }
976 memset(device, 0, sizeof(struct acpi_device)); 986 memset(device, 0, sizeof(struct acpi_device));
977 987
@@ -1096,7 +1106,7 @@ acpi_add_single_object(struct acpi_device **child,
1096 kfree(device); 1106 kfree(device);
1097 } 1107 }
1098 1108
1099 return_VALUE(result); 1109 return result;
1100} 1110}
1101 1111
1102static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops) 1112static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
@@ -1109,10 +1119,9 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
1109 acpi_object_type type = 0; 1119 acpi_object_type type = 0;
1110 u32 level = 1; 1120 u32 level = 1;
1111 1121
1112 ACPI_FUNCTION_TRACE("acpi_bus_scan");
1113 1122
1114 if (!start) 1123 if (!start)
1115 return_VALUE(-EINVAL); 1124 return -EINVAL;
1116 1125
1117 parent = start; 1126 parent = start;
1118 phandle = start->handle; 1127 phandle = start->handle;
@@ -1209,7 +1218,7 @@ static int acpi_bus_scan(struct acpi_device *start, struct acpi_bus_ops *ops)
1209 } 1218 }
1210 } 1219 }
1211 1220
1212 return_VALUE(0); 1221 return 0;
1213} 1222}
1214 1223
1215int 1224int
@@ -1219,7 +1228,6 @@ acpi_bus_add(struct acpi_device **child,
1219 int result; 1228 int result;
1220 struct acpi_bus_ops ops; 1229 struct acpi_bus_ops ops;
1221 1230
1222 ACPI_FUNCTION_TRACE("acpi_bus_add");
1223 1231
1224 result = acpi_add_single_object(child, parent, handle, type); 1232 result = acpi_add_single_object(child, parent, handle, type);
1225 if (!result) { 1233 if (!result) {
@@ -1227,7 +1235,7 @@ acpi_bus_add(struct acpi_device **child,
1227 ops.acpi_op_add = 1; 1235 ops.acpi_op_add = 1;
1228 result = acpi_bus_scan(*child, &ops); 1236 result = acpi_bus_scan(*child, &ops);
1229 } 1237 }
1230 return_VALUE(result); 1238 return result;
1231} 1239}
1232 1240
1233EXPORT_SYMBOL(acpi_bus_add); 1241EXPORT_SYMBOL(acpi_bus_add);
@@ -1237,10 +1245,9 @@ int acpi_bus_start(struct acpi_device *device)
1237 int result; 1245 int result;
1238 struct acpi_bus_ops ops; 1246 struct acpi_bus_ops ops;
1239 1247
1240 ACPI_FUNCTION_TRACE("acpi_bus_start");
1241 1248
1242 if (!device) 1249 if (!device)
1243 return_VALUE(-EINVAL); 1250 return -EINVAL;
1244 1251
1245 result = acpi_start_single_object(device); 1252 result = acpi_start_single_object(device);
1246 if (!result) { 1253 if (!result) {
@@ -1248,7 +1255,7 @@ int acpi_bus_start(struct acpi_device *device)
1248 ops.acpi_op_start = 1; 1255 ops.acpi_op_start = 1;
1249 result = acpi_bus_scan(device, &ops); 1256 result = acpi_bus_scan(device, &ops);
1250 } 1257 }
1251 return_VALUE(result); 1258 return result;
1252} 1259}
1253 1260
1254EXPORT_SYMBOL(acpi_bus_start); 1261EXPORT_SYMBOL(acpi_bus_start);
@@ -1314,10 +1321,9 @@ static int acpi_bus_scan_fixed(struct acpi_device *root)
1314 int result = 0; 1321 int result = 0;
1315 struct acpi_device *device = NULL; 1322 struct acpi_device *device = NULL;
1316 1323
1317 ACPI_FUNCTION_TRACE("acpi_bus_scan_fixed");
1318 1324
1319 if (!root) 1325 if (!root)
1320 return_VALUE(-ENODEV); 1326 return -ENODEV;
1321 1327
1322 /* 1328 /*
1323 * Enumerate all fixed-feature devices. 1329 * Enumerate all fixed-feature devices.
@@ -1338,7 +1344,7 @@ static int acpi_bus_scan_fixed(struct acpi_device *root)
1338 result = acpi_start_single_object(device); 1344 result = acpi_start_single_object(device);
1339 } 1345 }
1340 1346
1341 return_VALUE(result); 1347 return result;
1342} 1348}
1343 1349
1344 1350
@@ -1427,7 +1433,7 @@ static int acpi_device_resume(struct device * dev)
1427} 1433}
1428 1434
1429 1435
1430struct bus_type acpi_bus_type = { 1436static struct bus_type acpi_bus_type = {
1431 .name = "acpi", 1437 .name = "acpi",
1432 .suspend = acpi_device_suspend, 1438 .suspend = acpi_device_suspend,
1433 .resume = acpi_device_resume, 1439 .resume = acpi_device_resume,
@@ -1440,10 +1446,9 @@ static int __init acpi_scan_init(void)
1440 int result; 1446 int result;
1441 struct acpi_bus_ops ops; 1447 struct acpi_bus_ops ops;
1442 1448
1443 ACPI_FUNCTION_TRACE("acpi_scan_init");
1444 1449
1445 if (acpi_disabled) 1450 if (acpi_disabled)
1446 return_VALUE(0); 1451 return 0;
1447 1452
1448 kset_register(&acpi_namespace_kset); 1453 kset_register(&acpi_namespace_kset);
1449 1454
@@ -1488,7 +1493,7 @@ static int __init acpi_scan_init(void)
1488 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL); 1493 acpi_device_unregister(acpi_root, ACPI_BUS_REMOVAL_NORMAL);
1489 1494
1490 Done: 1495 Done:
1491 return_VALUE(result); 1496 return result;
1492} 1497}
1493 1498
1494subsys_initcall(acpi_scan_init); 1499subsys_initcall(acpi_scan_init);