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.c51
1 files changed, 15 insertions, 36 deletions
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index 1d4950388fa1..2bf9082f7523 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -22,27 +22,16 @@
22 22
23ACPI_MODULE_NAME("platform"); 23ACPI_MODULE_NAME("platform");
24 24
25/* 25static const struct acpi_device_id forbidden_id_list[] = {
26 * The following ACPI IDs are known to be suitable for representing as 26 {"PNP0000", 0}, /* PIC */
27 * platform devices. 27 {"PNP0100", 0}, /* Timer */
28 */ 28 {"PNP0200", 0}, /* AT DMA Controller */
29static const struct acpi_device_id acpi_platform_device_ids[] = { 29 {"", 0},
30
31 { "PNP0D40" },
32 { "VPC2004" },
33 { "BCM4752" },
34
35 /* Intel Smart Sound Technology */
36 { "INT33C8" },
37 { "80860F28" },
38
39 { }
40}; 30};
41 31
42/** 32/**
43 * acpi_create_platform_device - Create platform device for ACPI device node 33 * acpi_create_platform_device - Create platform device for ACPI device node
44 * @adev: ACPI device node to create a platform device for. 34 * @adev: ACPI device node to create a platform device for.
45 * @id: ACPI device ID used to match @adev.
46 * 35 *
47 * Check if the given @adev can be represented as a platform device and, if 36 * 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 37 * that's the case, create and register a platform device, populate its common
@@ -50,8 +39,7 @@ static const struct acpi_device_id acpi_platform_device_ids[] = {
50 * 39 *
51 * Name of the platform device will be the same as @adev's. 40 * Name of the platform device will be the same as @adev's.
52 */ 41 */
53int acpi_create_platform_device(struct acpi_device *adev, 42struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
54 const struct acpi_device_id *id)
55{ 43{
56 struct platform_device *pdev = NULL; 44 struct platform_device *pdev = NULL;
57 struct acpi_device *acpi_parent; 45 struct acpi_device *acpi_parent;
@@ -63,19 +51,22 @@ int acpi_create_platform_device(struct acpi_device *adev,
63 51
64 /* If the ACPI node already has a physical device attached, skip it. */ 52 /* If the ACPI node already has a physical device attached, skip it. */
65 if (adev->physical_node_count) 53 if (adev->physical_node_count)
66 return 0; 54 return NULL;
55
56 if (!acpi_match_device_ids(adev, forbidden_id_list))
57 return ERR_PTR(-EINVAL);
67 58
68 INIT_LIST_HEAD(&resource_list); 59 INIT_LIST_HEAD(&resource_list);
69 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); 60 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
70 if (count < 0) { 61 if (count < 0) {
71 return 0; 62 return NULL;
72 } else if (count > 0) { 63 } else if (count > 0) {
73 resources = kmalloc(count * sizeof(struct resource), 64 resources = kmalloc(count * sizeof(struct resource),
74 GFP_KERNEL); 65 GFP_KERNEL);
75 if (!resources) { 66 if (!resources) {
76 dev_err(&adev->dev, "No memory for resources\n"); 67 dev_err(&adev->dev, "No memory for resources\n");
77 acpi_dev_free_resource_list(&resource_list); 68 acpi_dev_free_resource_list(&resource_list);
78 return -ENOMEM; 69 return ERR_PTR(-ENOMEM);
79 } 70 }
80 count = 0; 71 count = 0;
81 list_for_each_entry(rentry, &resource_list, node) 72 list_for_each_entry(rentry, &resource_list, node)
@@ -112,25 +103,13 @@ int acpi_create_platform_device(struct acpi_device *adev,
112 pdevinfo.num_res = count; 103 pdevinfo.num_res = count;
113 pdevinfo.acpi_node.companion = adev; 104 pdevinfo.acpi_node.companion = adev;
114 pdev = platform_device_register_full(&pdevinfo); 105 pdev = platform_device_register_full(&pdevinfo);
115 if (IS_ERR(pdev)) { 106 if (IS_ERR(pdev))
116 dev_err(&adev->dev, "platform device creation failed: %ld\n", 107 dev_err(&adev->dev, "platform device creation failed: %ld\n",
117 PTR_ERR(pdev)); 108 PTR_ERR(pdev));
118 pdev = NULL; 109 else
119 } else {
120 dev_dbg(&adev->dev, "created platform device %s\n", 110 dev_dbg(&adev->dev, "created platform device %s\n",
121 dev_name(&pdev->dev)); 111 dev_name(&pdev->dev));
122 }
123 112
124 kfree(resources); 113 kfree(resources);
125 return 1; 114 return pdev;
126}
127
128static struct acpi_scan_handler platform_handler = {
129 .ids = acpi_platform_device_ids,
130 .attach = acpi_create_platform_device,
131};
132
133void __init acpi_platform_init(void)
134{
135 acpi_scan_add_handler(&platform_handler);
136} 115}