Skip to content

Commit 8ce62f8

Browse files
committed
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>
1 parent a3cffce commit 8ce62f8

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

drivers/acpi/acpi_lpss.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,14 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
267267
struct lpss_private_data *pdata;
268268
struct resource_list_entry *rentry;
269269
struct list_head resource_list;
270+
struct platform_device *pdev;
270271
int ret;
271272

272273
dev_desc = (struct lpss_device_desc *)id->driver_data;
273-
if (!dev_desc)
274-
return acpi_create_platform_device(adev, id);
275-
274+
if (!dev_desc) {
275+
pdev = acpi_create_platform_device(adev);
276+
return IS_ERR_OR_NULL(pdev) ? PTR_ERR(pdev) : 1;
277+
}
276278
pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
277279
if (!pdata)
278280
return -ENOMEM;
@@ -322,10 +324,13 @@ static int acpi_lpss_create_device(struct acpi_device *adev,
322324
dev_desc->setup(pdata);
323325

324326
adev->driver_data = pdata;
325-
ret = acpi_create_platform_device(adev, id);
326-
if (ret > 0)
327-
return ret;
327+
pdev = acpi_create_platform_device(adev);
328+
if (!IS_ERR_OR_NULL(pdev)) {
329+
device_enable_async_suspend(&pdev->dev);
330+
return 1;
331+
}
328332

333+
ret = PTR_ERR(pdev);
329334
adev->driver_data = NULL;
330335

331336
err_out:

drivers/acpi/acpi_platform.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,14 @@ static const struct acpi_device_id acpi_platform_device_ids[] = {
4747
/**
4848
* acpi_create_platform_device - Create platform device for ACPI device node
4949
* @adev: ACPI device node to create a platform device for.
50-
* @id: ACPI device ID used to match @adev.
5150
*
5251
* Check if the given @adev can be represented as a platform device and, if
5352
* that's the case, create and register a platform device, populate its common
5453
* resources and returns a pointer to it. Otherwise, return %NULL.
5554
*
5655
* Name of the platform device will be the same as @adev's.
5756
*/
58-
int acpi_create_platform_device(struct acpi_device *adev,
59-
const struct acpi_device_id *id)
57+
struct platform_device *acpi_create_platform_device(struct acpi_device *adev)
6058
{
6159
struct platform_device *pdev = NULL;
6260
struct acpi_device *acpi_parent;
@@ -68,19 +66,19 @@ int acpi_create_platform_device(struct acpi_device *adev,
6866

6967
/* If the ACPI node already has a physical device attached, skip it. */
7068
if (adev->physical_node_count)
71-
return 0;
69+
return NULL;
7270

7371
INIT_LIST_HEAD(&resource_list);
7472
count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL);
7573
if (count < 0) {
76-
return 0;
74+
return NULL;
7775
} else if (count > 0) {
7876
resources = kmalloc(count * sizeof(struct resource),
7977
GFP_KERNEL);
8078
if (!resources) {
8179
dev_err(&adev->dev, "No memory for resources\n");
8280
acpi_dev_free_resource_list(&resource_list);
83-
return -ENOMEM;
81+
return ERR_PTR(-ENOMEM);
8482
}
8583
count = 0;
8684
list_for_each_entry(rentry, &resource_list, node)
@@ -117,22 +115,27 @@ int acpi_create_platform_device(struct acpi_device *adev,
117115
pdevinfo.num_res = count;
118116
pdevinfo.acpi_node.companion = adev;
119117
pdev = platform_device_register_full(&pdevinfo);
120-
if (IS_ERR(pdev)) {
118+
if (IS_ERR(pdev))
121119
dev_err(&adev->dev, "platform device creation failed: %ld\n",
122120
PTR_ERR(pdev));
123-
pdev = NULL;
124-
} else {
121+
else
125122
dev_dbg(&adev->dev, "created platform device %s\n",
126123
dev_name(&pdev->dev));
127-
}
128124

129125
kfree(resources);
126+
return pdev;
127+
}
128+
129+
static int acpi_platform_attach(struct acpi_device *adev,
130+
const struct acpi_device_id *id)
131+
{
132+
acpi_create_platform_device(adev);
130133
return 1;
131134
}
132135

133136
static struct acpi_scan_handler platform_handler = {
134137
.ids = acpi_platform_device_ids,
135-
.attach = acpi_create_platform_device,
138+
.attach = acpi_platform_attach,
136139
};
137140

138141
void __init acpi_platform_init(void)

drivers/acpi/internal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,7 @@ static inline void suspend_nvs_restore(void) {}
180180
-------------------------------------------------------------------------- */
181181
struct platform_device;
182182

183-
int acpi_create_platform_device(struct acpi_device *adev,
184-
const struct acpi_device_id *id);
183+
struct platform_device *acpi_create_platform_device(struct acpi_device *adev);
185184

186185
/*--------------------------------------------------------------------------
187186
Video

0 commit comments

Comments
 (0)