]> Git Repo - linux.git/commitdiff
Merge branch 'pnp' into release
authorLen Brown <[email protected]>
Wed, 30 Apr 2008 17:59:05 +0000 (13:59 -0400)
committerLen Brown <[email protected]>
Wed, 30 Apr 2008 17:59:05 +0000 (13:59 -0400)
1  2 
drivers/pnp/pnpacpi/core.c

index 63e64ef39fb70cc8f6008d76b00f3b437871dcf0,0950b711f19e04264f7c0f1fe7d4877e493f5535..50902773beaf9092fd0a241d535835a8839c843b
@@@ -25,6 -25,7 +25,7 @@@
  #include <acpi/acpi_bus.h>
  #include <acpi/actypes.h>
  
+ #include "../base.h"
  #include "pnpacpi.h"
  
  static int num = 0;
@@@ -44,7 -45,7 +45,7 @@@ static struct acpi_device_id excluded_i
        {"", 0},
  };
  
 -static inline int is_exclusive_device(struct acpi_device *dev)
 +static inline int __init is_exclusive_device(struct acpi_device *dev)
  {
        return (!acpi_match_device_ids(dev, excluded_id_list));
  }
@@@ -72,40 -73,24 +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 +148,6 @@@ static int __init pnpacpi_add_device(st
  {
        acpi_handle temp = NULL;
        acpi_status status;
-       struct pnp_id *dev_id;
        struct pnp_dev *dev;
  
        status = acpi_get_handle(device->handle, "_CRS", &temp);
            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;
        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;
                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,
This page took 0.070355 seconds and 4 git commands to generate.