Skip to content

Commit 8620578

Browse files
committed
PM: sleep: Call dpm_async_fn() directly in each suspend phase
Simplify the system-wide suspend of devices by invoking dpm_async_fn() directly from the main loop in each suspend phase instead of using an additional wrapper function for running it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Stanislaw Gruszka <[email protected]> Reviewed-by: Ulf Hansson <[email protected]>
1 parent 96db0f9 commit 8620578

File tree

1 file changed

+25
-36
lines changed

1 file changed

+25
-36
lines changed

drivers/base/power/main.c

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,15 +1192,15 @@ static void dpm_superior_set_must_resume(struct device *dev)
11921192
}
11931193

11941194
/**
1195-
* __device_suspend_noirq - Execute a "noirq suspend" callback for given device.
1195+
* device_suspend_noirq - Execute a "noirq suspend" callback for given device.
11961196
* @dev: Device to handle.
11971197
* @state: PM transition of the system being carried out.
11981198
* @async: If true, the device is being suspended asynchronously.
11991199
*
12001200
* The driver of @dev will not receive interrupts while this function is being
12011201
* executed.
12021202
*/
1203-
static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool async)
1203+
static int device_suspend_noirq(struct device *dev, pm_message_t state, bool async)
12041204
{
12051205
pm_callback_t callback = NULL;
12061206
const char *info = NULL;
@@ -1277,18 +1277,10 @@ static void async_suspend_noirq(void *data, async_cookie_t cookie)
12771277
{
12781278
struct device *dev = data;
12791279

1280-
__device_suspend_noirq(dev, pm_transition, true);
1280+
device_suspend_noirq(dev, pm_transition, true);
12811281
put_device(dev);
12821282
}
12831283

1284-
static int device_suspend_noirq(struct device *dev)
1285-
{
1286-
if (dpm_async_fn(dev, async_suspend_noirq))
1287-
return 0;
1288-
1289-
return __device_suspend_noirq(dev, pm_transition, false);
1290-
}
1291-
12921284
static int dpm_noirq_suspend_devices(pm_message_t state)
12931285
{
12941286
ktime_t starttime = ktime_get();
@@ -1305,10 +1297,15 @@ static int dpm_noirq_suspend_devices(pm_message_t state)
13051297
struct device *dev = to_device(dpm_late_early_list.prev);
13061298

13071299
list_move(&dev->power.entry, &dpm_noirq_list);
1300+
1301+
if (dpm_async_fn(dev, async_suspend_noirq))
1302+
continue;
1303+
13081304
get_device(dev);
1305+
13091306
mutex_unlock(&dpm_list_mtx);
13101307

1311-
error = device_suspend_noirq(dev);
1308+
error = device_suspend_noirq(dev, state, false);
13121309

13131310
put_device(dev);
13141311

@@ -1369,14 +1366,14 @@ static void dpm_propagate_wakeup_to_parent(struct device *dev)
13691366
}
13701367

13711368
/**
1372-
* __device_suspend_late - Execute a "late suspend" callback for given device.
1369+
* device_suspend_late - Execute a "late suspend" callback for given device.
13731370
* @dev: Device to handle.
13741371
* @state: PM transition of the system being carried out.
13751372
* @async: If true, the device is being suspended asynchronously.
13761373
*
13771374
* Runtime PM is disabled for @dev while this function is being executed.
13781375
*/
1379-
static int __device_suspend_late(struct device *dev, pm_message_t state, bool async)
1376+
static int device_suspend_late(struct device *dev, pm_message_t state, bool async)
13801377
{
13811378
pm_callback_t callback = NULL;
13821379
const char *info = NULL;
@@ -1447,18 +1444,10 @@ static void async_suspend_late(void *data, async_cookie_t cookie)
14471444
{
14481445
struct device *dev = data;
14491446

1450-
__device_suspend_late(dev, pm_transition, true);
1447+
device_suspend_late(dev, pm_transition, true);
14511448
put_device(dev);
14521449
}
14531450

1454-
static int device_suspend_late(struct device *dev)
1455-
{
1456-
if (dpm_async_fn(dev, async_suspend_late))
1457-
return 0;
1458-
1459-
return __device_suspend_late(dev, pm_transition, false);
1460-
}
1461-
14621451
/**
14631452
* dpm_suspend_late - Execute "late suspend" callbacks for all devices.
14641453
* @state: PM transition of the system being carried out.
@@ -1481,11 +1470,15 @@ int dpm_suspend_late(pm_message_t state)
14811470
struct device *dev = to_device(dpm_suspended_list.prev);
14821471

14831472
list_move(&dev->power.entry, &dpm_late_early_list);
1473+
1474+
if (dpm_async_fn(dev, async_suspend_late))
1475+
continue;
1476+
14841477
get_device(dev);
14851478

14861479
mutex_unlock(&dpm_list_mtx);
14871480

1488-
error = device_suspend_late(dev);
1481+
error = device_suspend_late(dev, state, false);
14891482

14901483
put_device(dev);
14911484

@@ -1582,12 +1575,12 @@ static void dpm_clear_superiors_direct_complete(struct device *dev)
15821575
}
15831576

15841577
/**
1585-
* __device_suspend - Execute "suspend" callbacks for given device.
1578+
* device_suspend - Execute "suspend" callbacks for given device.
15861579
* @dev: Device to handle.
15871580
* @state: PM transition of the system being carried out.
15881581
* @async: If true, the device is being suspended asynchronously.
15891582
*/
1590-
static int __device_suspend(struct device *dev, pm_message_t state, bool async)
1583+
static int device_suspend(struct device *dev, pm_message_t state, bool async)
15911584
{
15921585
pm_callback_t callback = NULL;
15931586
const char *info = NULL;
@@ -1716,18 +1709,10 @@ static void async_suspend(void *data, async_cookie_t cookie)
17161709
{
17171710
struct device *dev = data;
17181711

1719-
__device_suspend(dev, pm_transition, true);
1712+
device_suspend(dev, pm_transition, true);
17201713
put_device(dev);
17211714
}
17221715

1723-
static int device_suspend(struct device *dev)
1724-
{
1725-
if (dpm_async_fn(dev, async_suspend))
1726-
return 0;
1727-
1728-
return __device_suspend(dev, pm_transition, false);
1729-
}
1730-
17311716
/**
17321717
* dpm_suspend - Execute "suspend" callbacks for all non-sysdev devices.
17331718
* @state: PM transition of the system being carried out.
@@ -1752,11 +1737,15 @@ int dpm_suspend(pm_message_t state)
17521737
struct device *dev = to_device(dpm_prepared_list.prev);
17531738

17541739
list_move(&dev->power.entry, &dpm_suspended_list);
1740+
1741+
if (dpm_async_fn(dev, async_suspend))
1742+
continue;
1743+
17551744
get_device(dev);
17561745

17571746
mutex_unlock(&dpm_list_mtx);
17581747

1759-
error = device_suspend(dev);
1748+
error = device_suspend(dev, state, false);
17601749

17611750
put_device(dev);
17621751

0 commit comments

Comments
 (0)