Merge branch 'acpi-scan'
* acpi-scan: ACPI / scan: Do not bind ACPI drivers to objects with scan handlers ACPI / ia64 / sba_iommu: Use ACPI scan handler for device discovery ACPI / scan: Simplify ACPI driver probing
This commit is contained in:
commit
8e9914d5ef
3 changed files with 46 additions and 65 deletions
|
@ -2042,7 +2042,8 @@ sba_map_ioc_to_node(struct ioc *ioc, acpi_handle handle)
|
|||
#endif
|
||||
|
||||
static int __init
|
||||
acpi_sba_ioc_add(struct acpi_device *device)
|
||||
acpi_sba_ioc_add(struct acpi_device *device,
|
||||
const struct acpi_device_id *not_used)
|
||||
{
|
||||
struct ioc *ioc;
|
||||
acpi_status status;
|
||||
|
@ -2090,14 +2091,18 @@ static const struct acpi_device_id hp_ioc_iommu_device_ids[] = {
|
|||
{"HWP0004", 0},
|
||||
{"", 0},
|
||||
};
|
||||
static struct acpi_driver acpi_sba_ioc_driver = {
|
||||
.name = "IOC IOMMU Driver",
|
||||
.ids = hp_ioc_iommu_device_ids,
|
||||
.ops = {
|
||||
.add = acpi_sba_ioc_add,
|
||||
},
|
||||
static struct acpi_scan_handler acpi_sba_ioc_handler = {
|
||||
.ids = hp_ioc_iommu_device_ids,
|
||||
.attach = acpi_sba_ioc_add,
|
||||
};
|
||||
|
||||
static int __init acpi_sba_ioc_init_acpi(void)
|
||||
{
|
||||
return acpi_scan_add_handler(&acpi_sba_ioc_handler);
|
||||
}
|
||||
/* This has to run before acpi_scan_init(). */
|
||||
arch_initcall(acpi_sba_ioc_init_acpi);
|
||||
|
||||
extern struct dma_map_ops swiotlb_dma_ops;
|
||||
|
||||
static int __init
|
||||
|
@ -2122,7 +2127,10 @@ sba_init(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
acpi_bus_register_driver(&acpi_sba_ioc_driver);
|
||||
/*
|
||||
* ioc_list should be populated by the acpi_sba_ioc_handler's .attach()
|
||||
* routine, but that only happens if acpi_scan_init() has already run.
|
||||
*/
|
||||
if (!ioc_list) {
|
||||
#ifdef CONFIG_IA64_GENERIC
|
||||
/*
|
||||
|
|
|
@ -933,32 +933,43 @@ static void acpi_device_remove_notify_handler(struct acpi_device *device)
|
|||
acpi_device_notify);
|
||||
}
|
||||
|
||||
static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *);
|
||||
static int acpi_device_probe(struct device * dev)
|
||||
static int acpi_device_probe(struct device *dev)
|
||||
{
|
||||
struct acpi_device *acpi_dev = to_acpi_device(dev);
|
||||
struct acpi_driver *acpi_drv = to_acpi_driver(dev->driver);
|
||||
int ret;
|
||||
|
||||
ret = acpi_bus_driver_init(acpi_dev, acpi_drv);
|
||||
if (!ret) {
|
||||
if (acpi_drv->ops.notify) {
|
||||
ret = acpi_device_install_notify_handler(acpi_dev);
|
||||
if (ret) {
|
||||
if (acpi_drv->ops.remove)
|
||||
acpi_drv->ops.remove(acpi_dev);
|
||||
acpi_dev->driver = NULL;
|
||||
acpi_dev->driver_data = NULL;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if (acpi_dev->handler)
|
||||
return -EINVAL;
|
||||
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
||||
"Found driver [%s] for device [%s]\n",
|
||||
acpi_drv->name, acpi_dev->pnp.bus_id));
|
||||
get_device(dev);
|
||||
if (!acpi_drv->ops.add)
|
||||
return -ENOSYS;
|
||||
|
||||
ret = acpi_drv->ops.add(acpi_dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
acpi_dev->driver = acpi_drv;
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
||||
"Driver [%s] successfully bound to device [%s]\n",
|
||||
acpi_drv->name, acpi_dev->pnp.bus_id));
|
||||
|
||||
if (acpi_drv->ops.notify) {
|
||||
ret = acpi_device_install_notify_handler(acpi_dev);
|
||||
if (ret) {
|
||||
if (acpi_drv->ops.remove)
|
||||
acpi_drv->ops.remove(acpi_dev);
|
||||
|
||||
acpi_dev->driver = NULL;
|
||||
acpi_dev->driver_data = NULL;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found driver [%s] for device [%s]\n",
|
||||
acpi_drv->name, acpi_dev->pnp.bus_id));
|
||||
get_device(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int acpi_device_remove(struct device * dev)
|
||||
|
@ -1113,41 +1124,6 @@ static void acpi_device_unregister(struct acpi_device *device)
|
|||
/* --------------------------------------------------------------------------
|
||||
Driver Management
|
||||
-------------------------------------------------------------------------- */
|
||||
/**
|
||||
* acpi_bus_driver_init - add a device to a driver
|
||||
* @device: the device to add and initialize
|
||||
* @driver: driver for the device
|
||||
*
|
||||
* Used to initialize a device via its device driver. Called whenever a
|
||||
* driver is bound to a device. Invokes the driver's add() ops.
|
||||
*/
|
||||
static int
|
||||
acpi_bus_driver_init(struct acpi_device *device, struct acpi_driver *driver)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (!device || !driver)
|
||||
return -EINVAL;
|
||||
|
||||
if (!driver->ops.add)
|
||||
return -ENOSYS;
|
||||
|
||||
result = driver->ops.add(device);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
device->driver = driver;
|
||||
|
||||
/*
|
||||
* TBD - Configuration Management: Assign resources to device based
|
||||
* upon possible configuration and currently allocated resources.
|
||||
*/
|
||||
|
||||
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
||||
"Driver successfully bound to device\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* acpi_bus_register_driver - register a driver with the ACPI bus
|
||||
* @driver: driver being registered
|
||||
|
|
|
@ -1722,9 +1722,6 @@ static int acpi_video_bus_add(struct acpi_device *device)
|
|||
int error;
|
||||
acpi_status status;
|
||||
|
||||
if (device->handler)
|
||||
return -EINVAL;
|
||||
|
||||
status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
|
||||
device->parent->handle, 1,
|
||||
acpi_video_bus_match, NULL,
|
||||
|
|
Loading…
Reference in a new issue