diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-08-14 23:22:45 +0200 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-08-14 23:22:45 +0200 |
commit | f3ce717e60572421f56d89c9a85ac42e634d16e7 (patch) | |
tree | 46b85329773c7908378f90e4e8e86205ebfd229f /drivers/acpi/acpi_platform.c | |
parent | d4e4ab86bcba5a72779c43dc1459f71fea3d89c8 (diff) | |
parent | e73d3136355f511d3e1c2ef21acf02b19bd2b650 (diff) |
Merge back earlier 'acpi-assorted' material
Diffstat (limited to 'drivers/acpi/acpi_platform.c')
-rw-r--r-- | drivers/acpi/acpi_platform.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index fafec5ddf17..1bde12708f9 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c @@ -52,7 +52,7 @@ int acpi_create_platform_device(struct acpi_device *adev, struct platform_device_info pdevinfo; struct resource_list_entry *rentry; struct list_head resource_list; - struct resource *resources; + struct resource *resources = NULL; int count; /* If the ACPI node already has a physical device attached, skip it. */ @@ -61,20 +61,22 @@ int acpi_create_platform_device(struct acpi_device *adev, INIT_LIST_HEAD(&resource_list); count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); - if (count <= 0) + if (count < 0) { return 0; + } else if (count > 0) { + resources = kmalloc(count * sizeof(struct resource), + GFP_KERNEL); + if (!resources) { + dev_err(&adev->dev, "No memory for resources\n"); + acpi_dev_free_resource_list(&resource_list); + return -ENOMEM; + } + count = 0; + list_for_each_entry(rentry, &resource_list, node) + resources[count++] = rentry->res; - resources = kmalloc(count * sizeof(struct resource), GFP_KERNEL); - if (!resources) { - dev_err(&adev->dev, "No memory for resources\n"); acpi_dev_free_resource_list(&resource_list); - return -ENOMEM; } - count = 0; - list_for_each_entry(rentry, &resource_list, node) - resources[count++] = rentry->res; - - acpi_dev_free_resource_list(&resource_list); memset(&pdevinfo, 0, sizeof(pdevinfo)); /* |