aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpi_platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/acpi_platform.c')
-rw-r--r--drivers/acpi/acpi_platform.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index c0a39417ebe4..9f7bcfdf18ef 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -47,7 +47,6 @@ static const struct acpi_device_id acpi_platform_device_ids[] = {
47/** 47/**
48 * acpi_create_platform_device - Create platform device for ACPI device node 48 * acpi_create_platform_device - Create platform device for ACPI device node
49 * @adev: ACPI device node to create a platform device for. 49 * @adev: ACPI device node to create a platform device for.
50 * @id: ACPI device ID used to match @adev.
51 * 50 *
52 * Check if the given @adev can be represented as a platform device and, if 51 * Check if the given @adev can be represented as a platform device and, if
53 * that's the case, create and register a platform device, populate its common 52 * that's the case, create and register a platform device, populate its common
@@ -55,8 +54,7 @@ static const struct acpi_device_id acpi_platform_device_ids[] = {
55 * 54 *
56 * Name of the platform device will be the same as @adev's. 55 * Name of the platform device will be the same as @adev's.
57 */ 56 */
58int acpi_create_platform_device(struct acpi_device *adev, 57struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
59 const struct acpi_device_id *id)
60{ 58{
61 struct platform_device *pdev = NULL; 59 struct platform_device *pdev = NULL;
62 struct acpi_device *acpi_parent; 60 struct acpi_device *acpi_parent;
@@ -68,19 +66,19 @@ int acpi_create_platform_device(struct acpi_device *adev,
68 66
69 /* If the ACPI node already has a physical device attached, skip it. */ 67 /* If the ACPI node already has a physical device attached, skip it. */
70 if (adev->physical_node_count) 68 if (adev->physical_node_count)
71 return 0; 69 return NULL;
72 70
73 INIT_LIST_HEAD(&resource_list); 71 INIT_LIST_HEAD(&resource_list);
74 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); 72 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
75 if (count < 0) { 73 if (count < 0) {
76 return 0; 74 return NULL;
77 } else if (count > 0) { 75 } else if (count > 0) {
78 resources = kmalloc(count * sizeof(struct resource), 76 resources = kmalloc(count * sizeof(struct resource),
79 GFP_KERNEL); 77 GFP_KERNEL);
80 if (!resources) { 78 if (!resources) {
81 dev_err(&adev->dev, "No memory for resources\n"); 79 dev_err(&adev->dev, "No memory for resources\n");
82 acpi_dev_free_resource_list(&resource_list); 80 acpi_dev_free_resource_list(&resource_list);
83 return -ENOMEM; 81 return ERR_PTR(-ENOMEM);
84 } 82 }
85 count = 0; 83 count = 0;
86 list_for_each_entry(rentry, &resource_list, node) 84 list_for_each_entry(rentry, &resource_list, node)
@@ -117,22 +115,27 @@ int acpi_create_platform_device(struct acpi_device *adev,
117 pdevinfo.num_res = count; 115 pdevinfo.num_res = count;
118 pdevinfo.acpi_node.companion = adev; 116 pdevinfo.acpi_node.companion = adev;
119 pdev = platform_device_register_full(&pdevinfo); 117 pdev = platform_device_register_full(&pdevinfo);
120 if (IS_ERR(pdev)) { 118 if (IS_ERR(pdev))
121 dev_err(&adev->dev, "platform device creation failed: %ld\n", 119 dev_err(&adev->dev, "platform device creation failed: %ld\n",
122 PTR_ERR(pdev)); 120 PTR_ERR(pdev));
123 pdev = NULL; 121 else
124 } else {
125 dev_dbg(&adev->dev, "created platform device %s\n", 122 dev_dbg(&adev->dev, "created platform device %s\n",
126 dev_name(&pdev->dev)); 123 dev_name(&pdev->dev));
127 }
128 124
129 kfree(resources); 125 kfree(resources);
126 return pdev;
127}
128
129static int acpi_platform_attach(struct acpi_device *adev,
130 const struct acpi_device_id *id)
131{
132 acpi_create_platform_device(adev);
130 return 1; 133 return 1;
131} 134}
132 135
133static struct acpi_scan_handler platform_handler = { 136static struct acpi_scan_handler platform_handler = {
134 .ids = acpi_platform_device_ids, 137 .ids = acpi_platform_device_ids,
135 .attach = acpi_create_platform_device, 138 .attach = acpi_platform_attach,
136}; 139};
137 140
138void __init acpi_platform_init(void) 141void __init acpi_platform_init(void)