aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-05-25 08:38:52 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-05-25 08:38:52 -0400
commit8ce62f85a81f57e86bc120ab690facc612223188 (patch)
tree1754f856a05e238e0b5cf30aa89e4f82b2f803b3 /drivers/acpi
parenta3cffce4fbafac072660648e028cc9e629b5b3c8 (diff)
ACPI / platform / LPSS: Enable async suspend/resume of LPSS devices
To seed up suspend and resume of devices included into Intel SoCs handled by the ACPI LPSS driver during system suspend, make acpi_lpss_create_device() call device_enable_async_suspend() for every device created by it. This requires acpi_create_platform_device() to be modified to return a pointer to struct platform_device instead of an int. As a result, acpi_create_platform_device() cannot be pointed to by the .attach pointer in platform_handler directly any more, so a simple wrapper around it is necessary for this purpose. That, in turn, allows the second unused argument of acpi_create_platform_device() to be dropped, which is an improvement. Tested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpi_lpss.c17
-rw-r--r--drivers/acpi/acpi_platform.c25
-rw-r--r--drivers/acpi/internal.h3
3 files changed, 26 insertions, 19 deletions
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 69e29f409d4c..0e9c0d38b85c 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -267,12 +267,14 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
267 struct lpss_private_data *pdata; 267 struct lpss_private_data *pdata;
268 struct resource_list_entry *rentry; 268 struct resource_list_entry *rentry;
269 struct list_head resource_list; 269 struct list_head resource_list;
270 struct platform_device *pdev;
270 int ret; 271 int ret;
271 272
272 dev_desc = (struct lpss_device_desc *)id->driver_data; 273 dev_desc = (struct lpss_device_desc *)id->driver_data;
273 if (!dev_desc) 274 if (!dev_desc) {
274 return acpi_create_platform_device(adev, id); 275 pdev = acpi_create_platform_device(adev);
275 276 return IS_ERR_OR_NULL(pdev) ? PTR_ERR(pdev) : 1;
277 }
276 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); 278 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
277 if (!pdata) 279 if (!pdata)
278 return -ENOMEM; 280 return -ENOMEM;
@@ -322,10 +324,13 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
322 dev_desc->setup(pdata); 324 dev_desc->setup(pdata);
323 325
324 adev->driver_data = pdata; 326 adev->driver_data = pdata;
325 ret = acpi_create_platform_device(adev, id); 327 pdev = acpi_create_platform_device(adev);
326 if (ret > 0) 328 if (!IS_ERR_OR_NULL(pdev)) {
327 return ret; 329 device_enable_async_suspend(&pdev->dev);
330 return 1;
331 }
328 332
333 ret = PTR_ERR(pdev);
329 adev->driver_data = NULL; 334 adev->driver_data = NULL;
330 335
331 err_out: 336 err_out:
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)
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