Skip to content

Commit 3020537

Browse files
committed
PM: sleep: core: Fold functions into their callers
Fold four functions in the PM core that each have only one caller now into their callers. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Alan Stern <[email protected]>
1 parent 107d47b commit 3020537

File tree

1 file changed

+60
-138
lines changed

1 file changed

+60
-138
lines changed

drivers/base/power/main.c

Lines changed: 60 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -573,43 +573,6 @@ bool dev_pm_may_skip_resume(struct device *dev)
573573
return !dev->power.must_resume && pm_transition.event != PM_EVENT_RESTORE;
574574
}
575575

576-
static pm_callback_t dpm_subsys_resume_noirq_cb(struct device *dev,
577-
pm_message_t state,
578-
const char **info_p)
579-
{
580-
pm_callback_t callback;
581-
const char *info;
582-
583-
if (dev->pm_domain) {
584-
info = "noirq power domain ";
585-
callback = pm_noirq_op(&dev->pm_domain->ops, state);
586-
} else if (dev->type && dev->type->pm) {
587-
info = "noirq type ";
588-
callback = pm_noirq_op(dev->type->pm, state);
589-
} else if (dev->class && dev->class->pm) {
590-
info = "noirq class ";
591-
callback = pm_noirq_op(dev->class->pm, state);
592-
} else if (dev->bus && dev->bus->pm) {
593-
info = "noirq bus ";
594-
callback = pm_noirq_op(dev->bus->pm, state);
595-
} else {
596-
return NULL;
597-
}
598-
599-
if (info_p)
600-
*info_p = info;
601-
602-
return callback;
603-
}
604-
605-
static pm_callback_t dpm_subsys_suspend_noirq_cb(struct device *dev,
606-
pm_message_t state,
607-
const char **info_p);
608-
609-
static pm_callback_t dpm_subsys_suspend_late_cb(struct device *dev,
610-
pm_message_t state,
611-
const char **info_p);
612-
613576
/**
614577
* device_resume_noirq - Execute a "noirq resume" callback for given device.
615578
* @dev: Device to handle.
@@ -621,8 +584,8 @@ static pm_callback_t dpm_subsys_suspend_late_cb(struct device *dev,
621584
*/
622585
static int device_resume_noirq(struct device *dev, pm_message_t state, bool async)
623586
{
624-
pm_callback_t callback;
625-
const char *info;
587+
pm_callback_t callback = NULL;
588+
const char *info = NULL;
626589
bool skip_resume;
627590
int error = 0;
628591

@@ -638,7 +601,19 @@ static int device_resume_noirq(struct device *dev, pm_message_t state, bool asyn
638601
if (!dpm_wait_for_superior(dev, async))
639602
goto Out;
640603

641-
callback = dpm_subsys_resume_noirq_cb(dev, state, &info);
604+
if (dev->pm_domain) {
605+
info = "noirq power domain ";
606+
callback = pm_noirq_op(&dev->pm_domain->ops, state);
607+
} else if (dev->type && dev->type->pm) {
608+
info = "noirq type ";
609+
callback = pm_noirq_op(dev->type->pm, state);
610+
} else if (dev->class && dev->class->pm) {
611+
info = "noirq class ";
612+
callback = pm_noirq_op(dev->class->pm, state);
613+
} else if (dev->bus && dev->bus->pm) {
614+
info = "noirq bus ";
615+
callback = pm_noirq_op(dev->bus->pm, state);
616+
}
642617
if (callback) {
643618
skip_resume = false;
644619
goto Run;
@@ -791,35 +766,6 @@ void dpm_resume_noirq(pm_message_t state)
791766
cpuidle_resume();
792767
}
793768

794-
static pm_callback_t dpm_subsys_resume_early_cb(struct device *dev,
795-
pm_message_t state,
796-
const char **info_p)
797-
{
798-
pm_callback_t callback;
799-
const char *info;
800-
801-
if (dev->pm_domain) {
802-
info = "early power domain ";
803-
callback = pm_late_early_op(&dev->pm_domain->ops, state);
804-
} else if (dev->type && dev->type->pm) {
805-
info = "early type ";
806-
callback = pm_late_early_op(dev->type->pm, state);
807-
} else if (dev->class && dev->class->pm) {
808-
info = "early class ";
809-
callback = pm_late_early_op(dev->class->pm, state);
810-
} else if (dev->bus && dev->bus->pm) {
811-
info = "early bus ";
812-
callback = pm_late_early_op(dev->bus->pm, state);
813-
} else {
814-
return NULL;
815-
}
816-
817-
if (info_p)
818-
*info_p = info;
819-
820-
return callback;
821-
}
822-
823769
/**
824770
* device_resume_early - Execute an "early resume" callback for given device.
825771
* @dev: Device to handle.
@@ -830,8 +776,8 @@ static pm_callback_t dpm_subsys_resume_early_cb(struct device *dev,
830776
*/
831777
static int device_resume_early(struct device *dev, pm_message_t state, bool async)
832778
{
833-
pm_callback_t callback;
834-
const char *info;
779+
pm_callback_t callback = NULL;
780+
const char *info = NULL;
835781
int error = 0;
836782

837783
TRACE_DEVICE(dev);
@@ -846,9 +792,19 @@ static int device_resume_early(struct device *dev, pm_message_t state, bool asyn
846792
if (!dpm_wait_for_superior(dev, async))
847793
goto Out;
848794

849-
callback = dpm_subsys_resume_early_cb(dev, state, &info);
850-
851-
if (!callback && dev->driver && dev->driver->pm) {
795+
if (dev->pm_domain) {
796+
info = "early power domain ";
797+
callback = pm_late_early_op(&dev->pm_domain->ops, state);
798+
} else if (dev->type && dev->type->pm) {
799+
info = "early type ";
800+
callback = pm_late_early_op(dev->type->pm, state);
801+
} else if (dev->class && dev->class->pm) {
802+
info = "early class ";
803+
callback = pm_late_early_op(dev->class->pm, state);
804+
} else if (dev->bus && dev->bus->pm) {
805+
info = "early bus ";
806+
callback = pm_late_early_op(dev->bus->pm, state);
807+
} else if (dev->driver && dev->driver->pm) {
852808
info = "early driver ";
853809
callback = pm_late_early_op(dev->driver->pm, state);
854810
}
@@ -1226,35 +1182,6 @@ static void dpm_superior_set_must_resume(struct device *dev)
12261182
device_links_read_unlock(idx);
12271183
}
12281184

1229-
static pm_callback_t dpm_subsys_suspend_noirq_cb(struct device *dev,
1230-
pm_message_t state,
1231-
const char **info_p)
1232-
{
1233-
pm_callback_t callback;
1234-
const char *info;
1235-
1236-
if (dev->pm_domain) {
1237-
info = "noirq power domain ";
1238-
callback = pm_noirq_op(&dev->pm_domain->ops, state);
1239-
} else if (dev->type && dev->type->pm) {
1240-
info = "noirq type ";
1241-
callback = pm_noirq_op(dev->type->pm, state);
1242-
} else if (dev->class && dev->class->pm) {
1243-
info = "noirq class ";
1244-
callback = pm_noirq_op(dev->class->pm, state);
1245-
} else if (dev->bus && dev->bus->pm) {
1246-
info = "noirq bus ";
1247-
callback = pm_noirq_op(dev->bus->pm, state);
1248-
} else {
1249-
return NULL;
1250-
}
1251-
1252-
if (info_p)
1253-
*info_p = info;
1254-
1255-
return callback;
1256-
}
1257-
12581185
/**
12591186
* __device_suspend_noirq - Execute a "noirq suspend" callback for given device.
12601187
* @dev: Device to handle.
@@ -1266,8 +1193,8 @@ static pm_callback_t dpm_subsys_suspend_noirq_cb(struct device *dev,
12661193
*/
12671194
static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool async)
12681195
{
1269-
pm_callback_t callback;
1270-
const char *info;
1196+
pm_callback_t callback = NULL;
1197+
const char *info = NULL;
12711198
int error = 0;
12721199

12731200
TRACE_DEVICE(dev);
@@ -1281,7 +1208,19 @@ static int __device_suspend_noirq(struct device *dev, pm_message_t state, bool a
12811208
if (dev->power.syscore || dev->power.direct_complete)
12821209
goto Complete;
12831210

1284-
callback = dpm_subsys_suspend_noirq_cb(dev, state, &info);
1211+
if (dev->pm_domain) {
1212+
info = "noirq power domain ";
1213+
callback = pm_noirq_op(&dev->pm_domain->ops, state);
1214+
} else if (dev->type && dev->type->pm) {
1215+
info = "noirq type ";
1216+
callback = pm_noirq_op(dev->type->pm, state);
1217+
} else if (dev->class && dev->class->pm) {
1218+
info = "noirq class ";
1219+
callback = pm_noirq_op(dev->class->pm, state);
1220+
} else if (dev->bus && dev->bus->pm) {
1221+
info = "noirq bus ";
1222+
callback = pm_noirq_op(dev->bus->pm, state);
1223+
}
12851224
if (callback)
12861225
goto Run;
12871226

@@ -1429,35 +1368,6 @@ static void dpm_propagate_wakeup_to_parent(struct device *dev)
14291368
spin_unlock_irq(&parent->power.lock);
14301369
}
14311370

1432-
static pm_callback_t dpm_subsys_suspend_late_cb(struct device *dev,
1433-
pm_message_t state,
1434-
const char **info_p)
1435-
{
1436-
pm_callback_t callback;
1437-
const char *info;
1438-
1439-
if (dev->pm_domain) {
1440-
info = "late power domain ";
1441-
callback = pm_late_early_op(&dev->pm_domain->ops, state);
1442-
} else if (dev->type && dev->type->pm) {
1443-
info = "late type ";
1444-
callback = pm_late_early_op(dev->type->pm, state);
1445-
} else if (dev->class && dev->class->pm) {
1446-
info = "late class ";
1447-
callback = pm_late_early_op(dev->class->pm, state);
1448-
} else if (dev->bus && dev->bus->pm) {
1449-
info = "late bus ";
1450-
callback = pm_late_early_op(dev->bus->pm, state);
1451-
} else {
1452-
return NULL;
1453-
}
1454-
1455-
if (info_p)
1456-
*info_p = info;
1457-
1458-
return callback;
1459-
}
1460-
14611371
/**
14621372
* __device_suspend_late - Execute a "late suspend" callback for given device.
14631373
* @dev: Device to handle.
@@ -1468,8 +1378,8 @@ static pm_callback_t dpm_subsys_suspend_late_cb(struct device *dev,
14681378
*/
14691379
static int __device_suspend_late(struct device *dev, pm_message_t state, bool async)
14701380
{
1471-
pm_callback_t callback;
1472-
const char *info;
1381+
pm_callback_t callback = NULL;
1382+
const char *info = NULL;
14731383
int error = 0;
14741384

14751385
TRACE_DEVICE(dev);
@@ -1490,7 +1400,19 @@ static int __device_suspend_late(struct device *dev, pm_message_t state, bool as
14901400
if (dev->power.syscore || dev->power.direct_complete)
14911401
goto Complete;
14921402

1493-
callback = dpm_subsys_suspend_late_cb(dev, state, &info);
1403+
if (dev->pm_domain) {
1404+
info = "late power domain ";
1405+
callback = pm_late_early_op(&dev->pm_domain->ops, state);
1406+
} else if (dev->type && dev->type->pm) {
1407+
info = "late type ";
1408+
callback = pm_late_early_op(dev->type->pm, state);
1409+
} else if (dev->class && dev->class->pm) {
1410+
info = "late class ";
1411+
callback = pm_late_early_op(dev->class->pm, state);
1412+
} else if (dev->bus && dev->bus->pm) {
1413+
info = "late bus ";
1414+
callback = pm_late_early_op(dev->bus->pm, state);
1415+
}
14941416
if (callback)
14951417
goto Run;
14961418

0 commit comments

Comments
 (0)