Skip to content

Commit 0307f4e

Browse files
committed
PM: runtime: Relocate rpm_callback() right after __rpm_callback()
Because rpm_callback() is a wrapper around __rpm_callback(), and the only caller of it after the change eliminating an invocation of it from rpm_idle(), move the former next to the latter to make the code a bit easier to follow. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
1 parent bc80c2e commit 0307f4e

1 file changed

Lines changed: 32 additions & 32 deletions

File tree

drivers/base/power/runtime.c

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,38 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev)
421421
return retval;
422422
}
423423

424+
/**
425+
* rpm_callback - Run a given runtime PM callback for a given device.
426+
* @cb: Runtime PM callback to run.
427+
* @dev: Device to run the callback for.
428+
*/
429+
static int rpm_callback(int (*cb)(struct device *), struct device *dev)
430+
{
431+
int retval;
432+
433+
if (dev->power.memalloc_noio) {
434+
unsigned int noio_flag;
435+
436+
/*
437+
* Deadlock might be caused if memory allocation with
438+
* GFP_KERNEL happens inside runtime_suspend and
439+
* runtime_resume callbacks of one block device's
440+
* ancestor or the block device itself. Network
441+
* device might be thought as part of iSCSI block
442+
* device, so network device and its ancestor should
443+
* be marked as memalloc_noio too.
444+
*/
445+
noio_flag = memalloc_noio_save();
446+
retval = __rpm_callback(cb, dev);
447+
memalloc_noio_restore(noio_flag);
448+
} else {
449+
retval = __rpm_callback(cb, dev);
450+
}
451+
452+
dev->power.runtime_error = retval;
453+
return retval != -EACCES ? retval : -EIO;
454+
}
455+
424456
/**
425457
* rpm_idle - Notify device bus type if the device can be suspended.
426458
* @dev: Device to notify the bus type about.
@@ -504,38 +536,6 @@ static int rpm_idle(struct device *dev, int rpmflags)
504536
return retval ? retval : rpm_suspend(dev, rpmflags | RPM_AUTO);
505537
}
506538

507-
/**
508-
* rpm_callback - Run a given runtime PM callback for a given device.
509-
* @cb: Runtime PM callback to run.
510-
* @dev: Device to run the callback for.
511-
*/
512-
static int rpm_callback(int (*cb)(struct device *), struct device *dev)
513-
{
514-
int retval;
515-
516-
if (dev->power.memalloc_noio) {
517-
unsigned int noio_flag;
518-
519-
/*
520-
* Deadlock might be caused if memory allocation with
521-
* GFP_KERNEL happens inside runtime_suspend and
522-
* runtime_resume callbacks of one block device's
523-
* ancestor or the block device itself. Network
524-
* device might be thought as part of iSCSI block
525-
* device, so network device and its ancestor should
526-
* be marked as memalloc_noio too.
527-
*/
528-
noio_flag = memalloc_noio_save();
529-
retval = __rpm_callback(cb, dev);
530-
memalloc_noio_restore(noio_flag);
531-
} else {
532-
retval = __rpm_callback(cb, dev);
533-
}
534-
535-
dev->power.runtime_error = retval;
536-
return retval != -EACCES ? retval : -EIO;
537-
}
538-
539539
/**
540540
* rpm_suspend - Carry out runtime suspend of given device.
541541
* @dev: Device to suspend.

0 commit comments

Comments
 (0)