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.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 20c23c049207..8ff510b91d88 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -24,7 +24,7 @@ extern struct acpi_device *acpi_root;
24 24
25static LIST_HEAD(acpi_device_list); 25static LIST_HEAD(acpi_device_list);
26static LIST_HEAD(acpi_bus_id_list); 26static LIST_HEAD(acpi_bus_id_list);
27DEFINE_SPINLOCK(acpi_device_lock); 27DEFINE_MUTEX(acpi_device_lock);
28LIST_HEAD(acpi_wakeup_device_list); 28LIST_HEAD(acpi_wakeup_device_list);
29 29
30struct acpi_device_bus_id{ 30struct acpi_device_bus_id{
@@ -491,7 +491,6 @@ static int acpi_device_register(struct acpi_device *device,
491 */ 491 */
492 INIT_LIST_HEAD(&device->children); 492 INIT_LIST_HEAD(&device->children);
493 INIT_LIST_HEAD(&device->node); 493 INIT_LIST_HEAD(&device->node);
494 INIT_LIST_HEAD(&device->g_list);
495 INIT_LIST_HEAD(&device->wakeup_list); 494 INIT_LIST_HEAD(&device->wakeup_list);
496 495
497 new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); 496 new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL);
@@ -500,7 +499,7 @@ static int acpi_device_register(struct acpi_device *device,
500 return -ENOMEM; 499 return -ENOMEM;
501 } 500 }
502 501
503 spin_lock(&acpi_device_lock); 502 mutex_lock(&acpi_device_lock);
504 /* 503 /*
505 * Find suitable bus_id and instance number in acpi_bus_id_list 504 * Find suitable bus_id and instance number in acpi_bus_id_list
506 * If failed, create one and link it into acpi_bus_id_list 505 * If failed, create one and link it into acpi_bus_id_list
@@ -521,14 +520,12 @@ static int acpi_device_register(struct acpi_device *device,
521 } 520 }
522 dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no); 521 dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no);
523 522
524 if (device->parent) { 523 if (device->parent)
525 list_add_tail(&device->node, &device->parent->children); 524 list_add_tail(&device->node, &device->parent->children);
526 list_add_tail(&device->g_list, &device->parent->g_list); 525
527 } else
528 list_add_tail(&device->g_list, &acpi_device_list);
529 if (device->wakeup.flags.valid) 526 if (device->wakeup.flags.valid)
530 list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list); 527 list_add_tail(&device->wakeup_list, &acpi_wakeup_device_list);
531 spin_unlock(&acpi_device_lock); 528 mutex_unlock(&acpi_device_lock);
532 529
533 if (device->parent) 530 if (device->parent)
534 device->dev.parent = &parent->dev; 531 device->dev.parent = &parent->dev;
@@ -549,28 +546,22 @@ static int acpi_device_register(struct acpi_device *device,
549 device->removal_type = ACPI_BUS_REMOVAL_NORMAL; 546 device->removal_type = ACPI_BUS_REMOVAL_NORMAL;
550 return 0; 547 return 0;
551 end: 548 end:
552 spin_lock(&acpi_device_lock); 549 mutex_lock(&acpi_device_lock);
553 if (device->parent) { 550 if (device->parent)
554 list_del(&device->node); 551 list_del(&device->node);
555 list_del(&device->g_list);
556 } else
557 list_del(&device->g_list);
558 list_del(&device->wakeup_list); 552 list_del(&device->wakeup_list);
559 spin_unlock(&acpi_device_lock); 553 mutex_unlock(&acpi_device_lock);
560 return result; 554 return result;
561} 555}
562 556
563static void acpi_device_unregister(struct acpi_device *device, int type) 557static void acpi_device_unregister(struct acpi_device *device, int type)
564{ 558{
565 spin_lock(&acpi_device_lock); 559 mutex_lock(&acpi_device_lock);
566 if (device->parent) { 560 if (device->parent)
567 list_del(&device->node); 561 list_del(&device->node);
568 list_del(&device->g_list);
569 } else
570 list_del(&device->g_list);
571 562
572 list_del(&device->wakeup_list); 563 list_del(&device->wakeup_list);
573 spin_unlock(&acpi_device_lock); 564 mutex_unlock(&acpi_device_lock);
574 565
575 acpi_detach_data(device->handle, acpi_bus_data_handler); 566 acpi_detach_data(device->handle, acpi_bus_data_handler);
576 567