aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/glue.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/glue.c')
-rw-r--r--drivers/acpi/glue.c39
1 files changed, 13 insertions, 26 deletions
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index ef6f155469b5..b94d14721af3 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -36,12 +36,11 @@ int register_acpi_bus_type(struct acpi_bus_type *type)
36{ 36{
37 if (acpi_disabled) 37 if (acpi_disabled)
38 return -ENODEV; 38 return -ENODEV;
39 if (type && type->bus && type->find_device) { 39 if (type && type->match && type->find_device) {
40 down_write(&bus_type_sem); 40 down_write(&bus_type_sem);
41 list_add_tail(&type->list, &bus_type_list); 41 list_add_tail(&type->list, &bus_type_list);
42 up_write(&bus_type_sem); 42 up_write(&bus_type_sem);
43 printk(KERN_INFO PREFIX "bus type %s registered\n", 43 printk(KERN_INFO PREFIX "bus type %s registered\n", type->name);
44 type->bus->name);
45 return 0; 44 return 0;
46 } 45 }
47 return -ENODEV; 46 return -ENODEV;
@@ -56,24 +55,21 @@ int unregister_acpi_bus_type(struct acpi_bus_type *type)
56 down_write(&bus_type_sem); 55 down_write(&bus_type_sem);
57 list_del_init(&type->list); 56 list_del_init(&type->list);
58 up_write(&bus_type_sem); 57 up_write(&bus_type_sem);
59 printk(KERN_INFO PREFIX "ACPI bus type %s unregistered\n", 58 printk(KERN_INFO PREFIX "bus type %s unregistered\n",
60 type->bus->name); 59 type->name);
61 return 0; 60 return 0;
62 } 61 }
63 return -ENODEV; 62 return -ENODEV;
64} 63}
65EXPORT_SYMBOL_GPL(unregister_acpi_bus_type); 64EXPORT_SYMBOL_GPL(unregister_acpi_bus_type);
66 65
67static struct acpi_bus_type *acpi_get_bus_type(struct bus_type *type) 66static struct acpi_bus_type *acpi_get_bus_type(struct device *dev)
68{ 67{
69 struct acpi_bus_type *tmp, *ret = NULL; 68 struct acpi_bus_type *tmp, *ret = NULL;
70 69
71 if (!type)
72 return NULL;
73
74 down_read(&bus_type_sem); 70 down_read(&bus_type_sem);
75 list_for_each_entry(tmp, &bus_type_list, list) { 71 list_for_each_entry(tmp, &bus_type_list, list) {
76 if (tmp->bus == type) { 72 if (tmp->match(dev)) {
77 ret = tmp; 73 ret = tmp;
78 break; 74 break;
79 } 75 }
@@ -261,26 +257,17 @@ err:
261 257
262static int acpi_platform_notify(struct device *dev) 258static int acpi_platform_notify(struct device *dev)
263{ 259{
264 struct acpi_bus_type *type; 260 struct acpi_bus_type *type = acpi_get_bus_type(dev);
265 acpi_handle handle; 261 acpi_handle handle;
266 int ret; 262 int ret;
267 263
268 ret = acpi_bind_one(dev, NULL); 264 ret = acpi_bind_one(dev, NULL);
269 if (ret && (!dev->bus || !dev->parent)) {
270 /* bridge devices genernally haven't bus or parent */
271 ret = acpi_find_bridge_device(dev, &handle);
272 if (!ret) {
273 ret = acpi_bind_one(dev, handle);
274 if (ret)
275 goto out;
276 }
277 }
278
279 type = acpi_get_bus_type(dev->bus);
280 if (ret) { 265 if (ret) {
281 if (!type || !type->find_device) { 266 if (!type) {
282 DBG("No ACPI bus support for %s\n", dev_name(dev)); 267 ret = acpi_find_bridge_device(dev, &handle);
283 ret = -EINVAL; 268 if (!ret)
269 ret = acpi_bind_one(dev, handle);
270
284 goto out; 271 goto out;
285 } 272 }
286 273
@@ -316,7 +303,7 @@ static int acpi_platform_notify_remove(struct device *dev)
316{ 303{
317 struct acpi_bus_type *type; 304 struct acpi_bus_type *type;
318 305
319 type = acpi_get_bus_type(dev->bus); 306 type = acpi_get_bus_type(dev);
320 if (type && type->cleanup) 307 if (type && type->cleanup)
321 type->cleanup(dev); 308 type->cleanup(dev);
322 309