diff options
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r-- | drivers/acpi/scan.c | 67 |
1 files changed, 19 insertions, 48 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index a0ab828b2cc5..fc676ac0e3ed 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -142,7 +142,7 @@ static void acpi_device_register(struct acpi_device *device, | |||
142 | create_sysfs_device_files(device); | 142 | create_sysfs_device_files(device); |
143 | } | 143 | } |
144 | 144 | ||
145 | static int acpi_device_unregister(struct acpi_device *device, int type) | 145 | static void acpi_device_unregister(struct acpi_device *device, int type) |
146 | { | 146 | { |
147 | spin_lock(&acpi_device_lock); | 147 | spin_lock(&acpi_device_lock); |
148 | if (device->parent) { | 148 | if (device->parent) { |
@@ -158,7 +158,6 @@ static int acpi_device_unregister(struct acpi_device *device, int type) | |||
158 | acpi_detach_data(device->handle, acpi_bus_data_handler); | 158 | acpi_detach_data(device->handle, acpi_bus_data_handler); |
159 | remove_sysfs_device_files(device); | 159 | remove_sysfs_device_files(device); |
160 | kobject_unregister(&device->kobj); | 160 | kobject_unregister(&device->kobj); |
161 | return 0; | ||
162 | } | 161 | } |
163 | 162 | ||
164 | void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context) | 163 | void acpi_bus_data_handler(acpi_handle handle, u32 function, void *context) |
@@ -234,12 +233,9 @@ static int acpi_bus_get_power_flags(struct acpi_device *device) | |||
234 | 233 | ||
235 | int acpi_match_ids(struct acpi_device *device, char *ids) | 234 | int acpi_match_ids(struct acpi_device *device, char *ids) |
236 | { | 235 | { |
237 | int error = 0; | ||
238 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | ||
239 | |||
240 | if (device->flags.hardware_id) | 236 | if (device->flags.hardware_id) |
241 | if (strstr(ids, device->pnp.hardware_id)) | 237 | if (strstr(ids, device->pnp.hardware_id)) |
242 | goto Done; | 238 | return 0; |
243 | 239 | ||
244 | if (device->flags.compatible_ids) { | 240 | if (device->flags.compatible_ids) { |
245 | struct acpi_compatible_id_list *cid_list = device->pnp.cid_list; | 241 | struct acpi_compatible_id_list *cid_list = device->pnp.cid_list; |
@@ -248,15 +244,10 @@ int acpi_match_ids(struct acpi_device *device, char *ids) | |||
248 | /* compare multiple _CID entries against driver ids */ | 244 | /* compare multiple _CID entries against driver ids */ |
249 | for (i = 0; i < cid_list->count; i++) { | 245 | for (i = 0; i < cid_list->count; i++) { |
250 | if (strstr(ids, cid_list->id[i].value)) | 246 | if (strstr(ids, cid_list->id[i].value)) |
251 | goto Done; | 247 | return 0; |
252 | } | 248 | } |
253 | } | 249 | } |
254 | error = -ENOENT; | 250 | return -ENOENT; |
255 | |||
256 | Done: | ||
257 | if (buffer.pointer) | ||
258 | acpi_os_free(buffer.pointer); | ||
259 | return error; | ||
260 | } | 251 | } |
261 | 252 | ||
262 | static acpi_status | 253 | static acpi_status |
@@ -441,10 +432,7 @@ acpi_eject_store(struct acpi_device *device, const char *buf, size_t count) | |||
441 | islockable = device->flags.lockable; | 432 | islockable = device->flags.lockable; |
442 | handle = device->handle; | 433 | handle = device->handle; |
443 | 434 | ||
444 | if (type == ACPI_TYPE_PROCESSOR) | 435 | result = acpi_bus_trim(device, 1); |
445 | result = acpi_bus_trim(device, 0); | ||
446 | else | ||
447 | result = acpi_bus_trim(device, 1); | ||
448 | 436 | ||
449 | if (!result) | 437 | if (!result) |
450 | result = acpi_eject_operation(handle, islockable); | 438 | result = acpi_eject_operation(handle, islockable); |
@@ -548,10 +536,9 @@ static int acpi_start_single_object(struct acpi_device *device) | |||
548 | return_VALUE(result); | 536 | return_VALUE(result); |
549 | } | 537 | } |
550 | 538 | ||
551 | static int acpi_driver_attach(struct acpi_driver *drv) | 539 | static void acpi_driver_attach(struct acpi_driver *drv) |
552 | { | 540 | { |
553 | struct list_head *node, *next; | 541 | struct list_head *node, *next; |
554 | int count = 0; | ||
555 | 542 | ||
556 | ACPI_FUNCTION_TRACE("acpi_driver_attach"); | 543 | ACPI_FUNCTION_TRACE("acpi_driver_attach"); |
557 | 544 | ||
@@ -568,7 +555,6 @@ static int acpi_driver_attach(struct acpi_driver *drv) | |||
568 | if (!acpi_bus_driver_init(dev, drv)) { | 555 | if (!acpi_bus_driver_init(dev, drv)) { |
569 | acpi_start_single_object(dev); | 556 | acpi_start_single_object(dev); |
570 | atomic_inc(&drv->references); | 557 | atomic_inc(&drv->references); |
571 | count++; | ||
572 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 558 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
573 | "Found driver [%s] for device [%s]\n", | 559 | "Found driver [%s] for device [%s]\n", |
574 | drv->name, dev->pnp.bus_id)); | 560 | drv->name, dev->pnp.bus_id)); |
@@ -577,10 +563,9 @@ static int acpi_driver_attach(struct acpi_driver *drv) | |||
577 | spin_lock(&acpi_device_lock); | 563 | spin_lock(&acpi_device_lock); |
578 | } | 564 | } |
579 | spin_unlock(&acpi_device_lock); | 565 | spin_unlock(&acpi_device_lock); |
580 | return_VALUE(count); | ||
581 | } | 566 | } |
582 | 567 | ||
583 | static int acpi_driver_detach(struct acpi_driver *drv) | 568 | static void acpi_driver_detach(struct acpi_driver *drv) |
584 | { | 569 | { |
585 | struct list_head *node, *next; | 570 | struct list_head *node, *next; |
586 | 571 | ||
@@ -602,7 +587,6 @@ static int acpi_driver_detach(struct acpi_driver *drv) | |||
602 | } | 587 | } |
603 | } | 588 | } |
604 | spin_unlock(&acpi_device_lock); | 589 | spin_unlock(&acpi_device_lock); |
605 | return_VALUE(0); | ||
606 | } | 590 | } |
607 | 591 | ||
608 | /** | 592 | /** |
@@ -610,28 +594,22 @@ static int acpi_driver_detach(struct acpi_driver *drv) | |||
610 | * @driver: driver being registered | 594 | * @driver: driver being registered |
611 | * | 595 | * |
612 | * Registers a driver with the ACPI bus. Searches the namespace for all | 596 | * Registers a driver with the ACPI bus. Searches the namespace for all |
613 | * devices that match the driver's criteria and binds. Returns the | 597 | * devices that match the driver's criteria and binds. Returns zero for |
614 | * number of devices that were claimed by the driver, or a negative | 598 | * success or a negative error status for failure. |
615 | * error status for failure. | ||
616 | */ | 599 | */ |
617 | int acpi_bus_register_driver(struct acpi_driver *driver) | 600 | int acpi_bus_register_driver(struct acpi_driver *driver) |
618 | { | 601 | { |
619 | int count; | ||
620 | |||
621 | ACPI_FUNCTION_TRACE("acpi_bus_register_driver"); | 602 | ACPI_FUNCTION_TRACE("acpi_bus_register_driver"); |
622 | 603 | ||
623 | if (acpi_disabled) | 604 | if (acpi_disabled) |
624 | return_VALUE(-ENODEV); | 605 | return_VALUE(-ENODEV); |
625 | 606 | ||
626 | if (!driver) | ||
627 | return_VALUE(-EINVAL); | ||
628 | |||
629 | spin_lock(&acpi_device_lock); | 607 | spin_lock(&acpi_device_lock); |
630 | list_add_tail(&driver->node, &acpi_bus_drivers); | 608 | list_add_tail(&driver->node, &acpi_bus_drivers); |
631 | spin_unlock(&acpi_device_lock); | 609 | spin_unlock(&acpi_device_lock); |
632 | count = acpi_driver_attach(driver); | 610 | acpi_driver_attach(driver); |
633 | 611 | ||
634 | return_VALUE(count); | 612 | return_VALUE(0); |
635 | } | 613 | } |
636 | 614 | ||
637 | EXPORT_SYMBOL(acpi_bus_register_driver); | 615 | EXPORT_SYMBOL(acpi_bus_register_driver); |
@@ -643,23 +621,16 @@ EXPORT_SYMBOL(acpi_bus_register_driver); | |||
643 | * Unregisters a driver with the ACPI bus. Searches the namespace for all | 621 | * Unregisters a driver with the ACPI bus. Searches the namespace for all |
644 | * devices that match the driver's criteria and unbinds. | 622 | * devices that match the driver's criteria and unbinds. |
645 | */ | 623 | */ |
646 | int acpi_bus_unregister_driver(struct acpi_driver *driver) | 624 | void acpi_bus_unregister_driver(struct acpi_driver *driver) |
647 | { | 625 | { |
648 | int error = 0; | 626 | acpi_driver_detach(driver); |
649 | |||
650 | ACPI_FUNCTION_TRACE("acpi_bus_unregister_driver"); | ||
651 | |||
652 | if (driver) { | ||
653 | acpi_driver_detach(driver); | ||
654 | 627 | ||
655 | if (!atomic_read(&driver->references)) { | 628 | if (!atomic_read(&driver->references)) { |
656 | spin_lock(&acpi_device_lock); | 629 | spin_lock(&acpi_device_lock); |
657 | list_del_init(&driver->node); | 630 | list_del_init(&driver->node); |
658 | spin_unlock(&acpi_device_lock); | 631 | spin_unlock(&acpi_device_lock); |
659 | } | 632 | } |
660 | } else | 633 | return; |
661 | error = -EINVAL; | ||
662 | return_VALUE(error); | ||
663 | } | 634 | } |
664 | 635 | ||
665 | EXPORT_SYMBOL(acpi_bus_unregister_driver); | 636 | EXPORT_SYMBOL(acpi_bus_unregister_driver); |