aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-03-03 16:35:20 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2013-03-04 08:23:40 -0500
commit53540098b23c3884b4a0b4f220b9d977bc496af3 (patch)
treefe86061c4772efaa92fbe68920f803ae4280b2d0 /drivers
parent9b27516fcd7ab7dc416edf418446c24c61729938 (diff)
ACPI / glue: Add .match() callback to struct acpi_bus_type
USB uses the .find_bridge() callback from struct acpi_bus_type incorrectly, because as a result of the way it is used by USB every device in the system that doesn't have a bus type or parent is passed to usb_acpi_find_device() for inspection. What USB actually needs, though, is to call usb_acpi_find_device() for USB ports that don't have a bus type defined, but have usb_port_device_type as their device type, as well as for USB devices. To fix that replace the struct bus_type pointer in struct acpi_bus_type used for matching devices to specific subsystems with a .match() callback to be used for this purpose and update the users of struct acpi_bus_type, including USB, accordingly. Define the .match() callback routine for USB, usb_acpi_bus_match(), in such a way that it will cover both USB devices and USB ports and remove the now redundant .find_bridge() callback pointer from usb_acpi_bus. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Yinghai Lu <yinghai@kernel.org> Acked-by: Jeff Garzik <jgarzik@pobox.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/glue.c39
-rw-r--r--drivers/ata/libata-acpi.c1
-rw-r--r--drivers/pci/pci-acpi.c8
-rw-r--r--drivers/pnp/pnpacpi/core.c8
-rw-r--r--drivers/scsi/scsi_lib.c7
-rw-r--r--drivers/usb/core/usb-acpi.c9
6 files changed, 41 insertions, 31 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
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index 0ea1018280bd..c832a5ca09ad 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -1150,6 +1150,7 @@ static int ata_acpi_find_dummy(struct device *dev, acpi_handle *handle)
1150} 1150}
1151 1151
1152static struct acpi_bus_type ata_acpi_bus = { 1152static struct acpi_bus_type ata_acpi_bus = {
1153 .name = "ATA",
1153 .find_bridge = ata_acpi_find_dummy, 1154 .find_bridge = ata_acpi_find_dummy,
1154 .find_device = ata_acpi_find_device, 1155 .find_device = ata_acpi_find_device,
1155}; 1156};
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index 39c937f9b426..dee5dddaa292 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -331,8 +331,14 @@ static void pci_acpi_cleanup(struct device *dev)
331 } 331 }
332} 332}
333 333
334static bool pci_acpi_bus_match(struct device *dev)
335{
336 return dev->bus == &pci_bus_type;
337}
338
334static struct acpi_bus_type acpi_pci_bus = { 339static struct acpi_bus_type acpi_pci_bus = {
335 .bus = &pci_bus_type, 340 .name = "PCI",
341 .match = pci_acpi_bus_match,
336 .find_device = acpi_pci_find_device, 342 .find_device = acpi_pci_find_device,
337 .setup = pci_acpi_setup, 343 .setup = pci_acpi_setup,
338 .cleanup = pci_acpi_cleanup, 344 .cleanup = pci_acpi_cleanup,
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c
index 8813fc03aa09..55cd459a3908 100644
--- a/drivers/pnp/pnpacpi/core.c
+++ b/drivers/pnp/pnpacpi/core.c
@@ -353,8 +353,14 @@ static int __init acpi_pnp_find_device(struct device *dev, acpi_handle * handle)
353/* complete initialization of a PNPACPI device includes having 353/* complete initialization of a PNPACPI device includes having
354 * pnpdev->dev.archdata.acpi_handle point to its ACPI sibling. 354 * pnpdev->dev.archdata.acpi_handle point to its ACPI sibling.
355 */ 355 */
356static bool acpi_pnp_bus_match(struct device *dev)
357{
358 return dev->bus == &pnp_bus_type;
359}
360
356static struct acpi_bus_type __initdata acpi_pnp_bus = { 361static struct acpi_bus_type __initdata acpi_pnp_bus = {
357 .bus = &pnp_bus_type, 362 .name = "PNP",
363 .match = acpi_pnp_bus_match,
358 .find_device = acpi_pnp_find_device, 364 .find_device = acpi_pnp_find_device,
359}; 365};
360 366
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 765398c063c7..c31187d79343 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -71,9 +71,14 @@ struct kmem_cache *scsi_sdb_cache;
71#ifdef CONFIG_ACPI 71#ifdef CONFIG_ACPI
72#include <acpi/acpi_bus.h> 72#include <acpi/acpi_bus.h>
73 73
74static bool acpi_scsi_bus_match(struct device *dev)
75{
76 return dev->bus == &scsi_bus_type;
77}
78
74int scsi_register_acpi_bus_type(struct acpi_bus_type *bus) 79int scsi_register_acpi_bus_type(struct acpi_bus_type *bus)
75{ 80{
76 bus->bus = &scsi_bus_type; 81 bus->match = acpi_scsi_bus_match;
77 return register_acpi_bus_type(bus); 82 return register_acpi_bus_type(bus);
78} 83}
79EXPORT_SYMBOL_GPL(scsi_register_acpi_bus_type); 84EXPORT_SYMBOL_GPL(scsi_register_acpi_bus_type);
diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index cef4252bb31a..b6f4bad3f756 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -210,9 +210,14 @@ static int usb_acpi_find_device(struct device *dev, acpi_handle *handle)
210 return 0; 210 return 0;
211} 211}
212 212
213static bool usb_acpi_bus_match(struct device *dev)
214{
215 return is_usb_device(dev) || is_usb_port(dev);
216}
217
213static struct acpi_bus_type usb_acpi_bus = { 218static struct acpi_bus_type usb_acpi_bus = {
214 .bus = &usb_bus_type, 219 .name = "USB",
215 .find_bridge = usb_acpi_find_device, 220 .match = usb_acpi_bus_match,
216 .find_device = usb_acpi_find_device, 221 .find_device = usb_acpi_find_device,
217}; 222};
218 223