aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-05-25 08:41:02 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-05-25 08:41:02 -0400
commit3022f4de491c096650d55ae9d562a9c811830724 (patch)
tree928514c1b7c423ed130af2214bed69008d14d3ee
parented3a872e2ef62bde06e2f579d8d1458766ced078 (diff)
parent8ce62f85a81f57e86bc120ab690facc612223188 (diff)
Merge branch 'acpi-platform' into acpi-lpss
-rw-r--r--drivers/acpi/acpi_lpss.c17
-rw-r--r--drivers/acpi/acpi_platform.c29
-rw-r--r--drivers/acpi/internal.h3
3 files changed, 30 insertions, 19 deletions
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index d1c9b04e29a3..db362a96c38e 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -305,12 +305,14 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
305 struct lpss_private_data *pdata; 305 struct lpss_private_data *pdata;
306 struct resource_list_entry *rentry; 306 struct resource_list_entry *rentry;
307 struct list_head resource_list; 307 struct list_head resource_list;
308 struct platform_device *pdev;
308 int ret; 309 int ret;
309 310
310 dev_desc = (struct lpss_device_desc *)id->driver_data; 311 dev_desc = (struct lpss_device_desc *)id->driver_data;
311 if (!dev_desc) 312 if (!dev_desc) {
312 return acpi_create_platform_device(adev, id); 313 pdev = acpi_create_platform_device(adev);
313 314 return IS_ERR_OR_NULL(pdev) ? PTR_ERR(pdev) : 1;
315 }
314 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); 316 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
315 if (!pdata) 317 if (!pdata)
316 return -ENOMEM; 318 return -ENOMEM;
@@ -360,10 +362,13 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
360 dev_desc->setup(pdata); 362 dev_desc->setup(pdata);
361 363
362 adev->driver_data = pdata; 364 adev->driver_data = pdata;
363 ret = acpi_create_platform_device(adev, id); 365 pdev = acpi_create_platform_device(adev);
364 if (ret > 0) 366 if (!IS_ERR_OR_NULL(pdev)) {
365 return ret; 367 device_enable_async_suspend(&pdev->dev);
368 return 1;
369 }
366 370
371 ret = PTR_ERR(pdev);
367 adev->driver_data = NULL; 372 adev->driver_data = NULL;
368 373
369 err_out: 374 err_out:
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c
index dbfe49e5fd63..9f7bcfdf18ef 100644
--- a/drivers/acpi/acpi_platform.c
+++ b/drivers/acpi/acpi_platform.c
@@ -32,6 +32,10 @@ static const struct acpi_device_id acpi_platform_device_ids[] = {
32 { "ACPI0003" }, 32 { "ACPI0003" },
33 { "VPC2004" }, 33 { "VPC2004" },
34 { "BCM4752" }, 34 { "BCM4752" },
35 { "LNV4752" },
36 { "BCM2E1A" },
37 { "BCM2E39" },
38 { "BCM2E3D" },
35 39
36 /* Intel Smart Sound Technology */ 40 /* Intel Smart Sound Technology */
37 { "INT33C8" }, 41 { "INT33C8" },
@@ -43,7 +47,6 @@ static const struct acpi_device_id acpi_platform_device_ids[] = {
43/** 47/**
44 * acpi_create_platform_device - Create platform device for ACPI device node 48 * acpi_create_platform_device - Create platform device for ACPI device node
45 * @adev: ACPI device node to create a platform device for. 49 * @adev: ACPI device node to create a platform device for.
46 * @id: ACPI device ID used to match @adev.
47 * 50 *
48 * 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
49 * 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
@@ -51,8 +54,7 @@ static const struct acpi_device_id acpi_platform_device_ids[] = {
51 * 54 *
52 * 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.
53 */ 56 */
54int acpi_create_platform_device(struct acpi_device *adev, 57struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
55 const struct acpi_device_id *id)
56{ 58{
57 struct platform_device *pdev = NULL; 59 struct platform_device *pdev = NULL;
58 struct acpi_device *acpi_parent; 60 struct acpi_device *acpi_parent;
@@ -64,19 +66,19 @@ int acpi_create_platform_device(struct acpi_device *adev,
64 66
65 /* 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. */
66 if (adev->physical_node_count) 68 if (adev->physical_node_count)
67 return 0; 69 return NULL;
68 70
69 INIT_LIST_HEAD(&resource_list); 71 INIT_LIST_HEAD(&resource_list);
70 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); 72 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
71 if (count < 0) { 73 if (count < 0) {
72 return 0; 74 return NULL;
73 } else if (count > 0) { 75 } else if (count > 0) {
74 resources = kmalloc(count * sizeof(struct resource), 76 resources = kmalloc(count * sizeof(struct resource),
75 GFP_KERNEL); 77 GFP_KERNEL);
76 if (!resources) { 78 if (!resources) {
77 dev_err(&adev->dev, "No memory for resources\n"); 79 dev_err(&adev->dev, "No memory for resources\n");
78 acpi_dev_free_resource_list(&resource_list); 80 acpi_dev_free_resource_list(&resource_list);
79 return -ENOMEM; 81 return ERR_PTR(-ENOMEM);
80 } 82 }
81 count = 0; 83 count = 0;
82 list_for_each_entry(rentry, &resource_list, node) 84 list_for_each_entry(rentry, &resource_list, node)
@@ -113,22 +115,27 @@ int acpi_create_platform_device(struct acpi_device *adev,
113 pdevinfo.num_res = count; 115 pdevinfo.num_res = count;
114 pdevinfo.acpi_node.companion = adev; 116 pdevinfo.acpi_node.companion = adev;
115 pdev = platform_device_register_full(&pdevinfo); 117 pdev = platform_device_register_full(&pdevinfo);
116 if (IS_ERR(pdev)) { 118 if (IS_ERR(pdev))
117 dev_err(&adev->dev, "platform device creation failed: %ld\n", 119 dev_err(&adev->dev, "platform device creation failed: %ld\n",
118 PTR_ERR(pdev)); 120 PTR_ERR(pdev));
119 pdev = NULL; 121 else
120 } else {
121 dev_dbg(&adev->dev, "created platform device %s\n", 122 dev_dbg(&adev->dev, "created platform device %s\n",
122 dev_name(&pdev->dev)); 123 dev_name(&pdev->dev));
123 }
124 124
125 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);
126 return 1; 133 return 1;
127} 134}
128 135
129static struct acpi_scan_handler platform_handler = { 136static struct acpi_scan_handler platform_handler = {
130 .ids = acpi_platform_device_ids, 137 .ids = acpi_platform_device_ids,
131 .attach = acpi_create_platform_device, 138 .attach = acpi_platform_attach,
132}; 139};
133 140
134void __init acpi_platform_init(void) 141void __init acpi_platform_init(void)
diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h
index 957391306cbf..bb7de413d06d 100644
--- a/drivers/acpi/internal.h
+++ b/drivers/acpi/internal.h
@@ -180,8 +180,7 @@ static inline void suspend_nvs_restore(void) {}
180 -------------------------------------------------------------------------- */ 180 -------------------------------------------------------------------------- */
181struct platform_device; 181struct platform_device;
182 182
183int acpi_create_platform_device(struct acpi_device *adev, 183struct platform_device *acpi_create_platform_device(struct acpi_device *adev);
184 const struct acpi_device_id *id);
185 184
186/*-------------------------------------------------------------------------- 185/*--------------------------------------------------------------------------
187 Video 186 Video