aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpi_platform.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-05-30 09:55:19 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-05-30 09:55:19 -0400
commit52d1d0b12beaf98b6d144d7d1b24eb96cfea60f6 (patch)
tree4dde4eeb3f6ce7a4d3b68f4ab9adfc60da519a6e /drivers/acpi/acpi_platform.c
parentc7208164e66f63e3ec1759b98087849286410741 (diff)
parent3022f4de491c096650d55ae9d562a9c811830724 (diff)
Merge branch 'acpi-lpss' into acpi-enumeration
Diffstat (limited to 'drivers/acpi/acpi_platform.c')
-rw-r--r--drivers/acpi/acpi_platform.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 1d4950388fa1..3bb89def2292 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -31,6 +31,10 @@ static const struct acpi_device_id acpi_platform_device_ids[] = {
31 { "PNP0D40" }, 31 { "PNP0D40" },
32 { "VPC2004" }, 32 { "VPC2004" },
33 { "BCM4752" }, 33 { "BCM4752" },
34 { "LNV4752" },
35 { "BCM2E1A" },
36 { "BCM2E39" },
37 { "BCM2E3D" },
34 38
35 /* Intel Smart Sound Technology */ 39 /* Intel Smart Sound Technology */
36 { "INT33C8" }, 40 { "INT33C8" },
@@ -42,7 +46,6 @@ static const struct acpi_device_id acpi_platform_device_ids[] = {
42/** 46/**
43 * acpi_create_platform_device - Create platform device for ACPI device node 47 * acpi_create_platform_device - Create platform device for ACPI device node
44 * @adev: ACPI device node to create a platform device for. 48 * @adev: ACPI device node to create a platform device for.
45 * @id: ACPI device ID used to match @adev.
46 * 49 *
47 * Check if the given @adev can be represented as a platform device and, if 50 * Check if the given @adev can be represented as a platform device and, if
48 * that's the case, create and register a platform device, populate its common 51 * that's the case, create and register a platform device, populate its common
@@ -50,8 +53,7 @@ static const struct acpi_device_id acpi_platform_device_ids[] = {
50 * 53 *
51 * Name of the platform device will be the same as @adev's. 54 * Name of the platform device will be the same as @adev's.
52 */ 55 */
53int acpi_create_platform_device(struct acpi_device *adev, 56struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
54 const struct acpi_device_id *id)
55{ 57{
56 struct platform_device *pdev = NULL; 58 struct platform_device *pdev = NULL;
57 struct acpi_device *acpi_parent; 59 struct acpi_device *acpi_parent;
@@ -63,19 +65,19 @@ int acpi_create_platform_device(struct acpi_device *adev,
63 65
64 /* If the ACPI node already has a physical device attached, skip it. */ 66 /* If the ACPI node already has a physical device attached, skip it. */
65 if (adev->physical_node_count) 67 if (adev->physical_node_count)
66 return 0; 68 return NULL;
67 69
68 INIT_LIST_HEAD(&resource_list); 70 INIT_LIST_HEAD(&resource_list);
69 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); 71 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
70 if (count < 0) { 72 if (count < 0) {
71 return 0; 73 return NULL;
72 } else if (count > 0) { 74 } else if (count > 0) {
73 resources = kmalloc(count * sizeof(struct resource), 75 resources = kmalloc(count * sizeof(struct resource),
74 GFP_KERNEL); 76 GFP_KERNEL);
75 if (!resources) { 77 if (!resources) {
76 dev_err(&adev->dev, "No memory for resources\n"); 78 dev_err(&adev->dev, "No memory for resources\n");
77 acpi_dev_free_resource_list(&resource_list); 79 acpi_dev_free_resource_list(&resource_list);
78 return -ENOMEM; 80 return ERR_PTR(-ENOMEM);
79 } 81 }
80 count = 0; 82 count = 0;
81 list_for_each_entry(rentry, &resource_list, node) 83 list_for_each_entry(rentry, &resource_list, node)
@@ -112,22 +114,27 @@ int acpi_create_platform_device(struct acpi_device *adev,
112 pdevinfo.num_res = count; 114 pdevinfo.num_res = count;
113 pdevinfo.acpi_node.companion = adev; 115 pdevinfo.acpi_node.companion = adev;
114 pdev = platform_device_register_full(&pdevinfo); 116 pdev = platform_device_register_full(&pdevinfo);
115 if (IS_ERR(pdev)) { 117 if (IS_ERR(pdev))
116 dev_err(&adev->dev, "platform device creation failed: %ld\n", 118 dev_err(&adev->dev, "platform device creation failed: %ld\n",
117 PTR_ERR(pdev)); 119 PTR_ERR(pdev));
118 pdev = NULL; 120 else
119 } else {
120 dev_dbg(&adev->dev, "created platform device %s\n", 121 dev_dbg(&adev->dev, "created platform device %s\n",
121 dev_name(&pdev->dev)); 122 dev_name(&pdev->dev));
122 }
123 123
124 kfree(resources); 124 kfree(resources);
125 return pdev;
126}
127
128static int acpi_platform_attach(struct acpi_device *adev,
129 const struct acpi_device_id *id)
130{
131 acpi_create_platform_device(adev);
125 return 1; 132 return 1;
126} 133}
127 134
128static struct acpi_scan_handler platform_handler = { 135static struct acpi_scan_handler platform_handler = {
129 .ids = acpi_platform_device_ids, 136 .ids = acpi_platform_device_ids,
130 .attach = acpi_create_platform_device, 137 .attach = acpi_platform_attach,
131}; 138};
132 139
133void __init acpi_platform_init(void) 140void __init acpi_platform_init(void)