diff options
author | Len Brown <len.brown@intel.com> | 2008-04-30 21:59:05 +0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-04-30 21:59:05 +0400 |
commit | 008238b54ac2350babf195084ecedbcf7851a202 (patch) | |
tree | a7cc18ea0403f4478883a3e36a6f0d2bf67eef3e /drivers/pnp/pnpacpi/core.c | |
parent | 96916090f488986a4ebb8e9ffa6a3b50881d5ccd (diff) | |
parent | dfd2e1b4e6eb46ff59c7e1c1111c967b8b5981c1 (diff) | |
download | linux-008238b54ac2350babf195084ecedbcf7851a202.tar.xz |
Merge branch 'pnp' into release
Diffstat (limited to 'drivers/pnp/pnpacpi/core.c')
-rw-r--r-- | drivers/pnp/pnpacpi/core.c | 90 |
1 files changed, 18 insertions, 72 deletions
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index 63e64ef39fb7..50902773beaf 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c @@ -25,6 +25,7 @@ #include <acpi/acpi_bus.h> #include <acpi/actypes.h> +#include "../base.h" #include "pnpacpi.h" static int num = 0; @@ -72,40 +73,24 @@ static int __init ispnpidacpi(char *id) return 1; } -static void __init pnpidacpi_to_pnpid(char *id, char *str) +static int pnpacpi_get_resources(struct pnp_dev *dev) { - str[0] = id[0]; - str[1] = id[1]; - str[2] = id[2]; - str[3] = tolower(id[3]); - str[4] = tolower(id[4]); - str[5] = tolower(id[5]); - str[6] = tolower(id[6]); - str[7] = '\0'; + dev_dbg(&dev->dev, "get resources\n"); + return pnpacpi_parse_allocated_resource(dev); } -static int pnpacpi_get_resources(struct pnp_dev *dev, - struct pnp_resource_table *res) -{ - acpi_status status; - - status = pnpacpi_parse_allocated_resource((acpi_handle) dev->data, - &dev->res); - return ACPI_FAILURE(status) ? -ENODEV : 0; -} - -static int pnpacpi_set_resources(struct pnp_dev *dev, - struct pnp_resource_table *res) +static int pnpacpi_set_resources(struct pnp_dev *dev) { acpi_handle handle = dev->data; struct acpi_buffer buffer; - int ret = 0; + int ret; acpi_status status; - ret = pnpacpi_build_resource_template(handle, &buffer); + dev_dbg(&dev->dev, "set resources\n"); + ret = pnpacpi_build_resource_template(dev, &buffer); if (ret) return ret; - ret = pnpacpi_encode_resources(res, &buffer); + ret = pnpacpi_encode_resources(dev, &buffer); if (ret) { kfree(buffer.pointer); return ret; @@ -163,7 +148,6 @@ static int __init pnpacpi_add_device(struct acpi_device *device) { acpi_handle temp = NULL; acpi_status status; - struct pnp_id *dev_id; struct pnp_dev *dev; status = acpi_get_handle(device->handle, "_CRS", &temp); @@ -171,11 +155,10 @@ static int __init pnpacpi_add_device(struct acpi_device *device) is_exclusive_device(device)) return 0; - dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); - if (!dev) { - pnp_err("Out of memory"); + dev = pnp_alloc_dev(&pnpacpi_protocol, num, acpi_device_hid(device)); + if (!dev) return -ENOMEM; - } + dev->data = device->handle; /* .enabled means the device can decode the resources */ dev->active = device->status.enabled; @@ -191,44 +174,17 @@ static int __init pnpacpi_add_device(struct acpi_device *device) if (ACPI_SUCCESS(status)) dev->capabilities |= PNP_DISABLE; - dev->protocol = &pnpacpi_protocol; - if (strlen(acpi_device_name(device))) strncpy(dev->name, acpi_device_name(device), sizeof(dev->name)); else strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name)); - dev->number = num; - - /* set the initial values for the PnP device */ - dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); - if (!dev_id) - goto err; - pnpidacpi_to_pnpid(acpi_device_hid(device), dev_id->id); - pnp_add_id(dev_id, dev); - - if (dev->active) { - /* parse allocated resource */ - status = pnpacpi_parse_allocated_resource(device->handle, - &dev->res); - if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { - pnp_err("PnPACPI: METHOD_NAME__CRS failure for %s", - dev_id->id); - goto err1; - } - } + if (dev->active) + pnpacpi_parse_allocated_resource(dev); - if (dev->capabilities & PNP_CONFIGURABLE) { - status = pnpacpi_parse_resource_option_data(device->handle, - dev); - if (ACPI_FAILURE(status) && (status != AE_NOT_FOUND)) { - pnp_err("PnPACPI: METHOD_NAME__PRS failure for %s", - dev_id->id); - goto err1; - } - } + if (dev->capabilities & PNP_CONFIGURABLE) + pnpacpi_parse_resource_option_data(dev); - /* parse compatible ids */ if (device->flags.compatible_ids) { struct acpi_compatible_id_list *cid_list = device->pnp.cid_list; int i; @@ -236,27 +192,17 @@ static int __init pnpacpi_add_device(struct acpi_device *device) for (i = 0; i < cid_list->count; i++) { if (!ispnpidacpi(cid_list->id[i].value)) continue; - dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL); - if (!dev_id) - continue; - - pnpidacpi_to_pnpid(cid_list->id[i].value, dev_id->id); - pnp_add_id(dev_id, dev); + pnp_add_id(dev, cid_list->id[i].value); } } /* clear out the damaged flags */ if (!dev->active) - pnp_init_resource_table(&dev->res); + pnp_init_resources(dev); pnp_add_device(dev); num++; return AE_OK; -err1: - kfree(dev_id); -err: - kfree(dev); - return -EINVAL; } static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, |