Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b589741 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

PM / Domains: Use subsystem runtime suspend/resume callbacks by default



Currently, the default "save state" and "restore state" routines
for generic PM domains, pm_genpd_default_save_state() and
pm_genpd_default_restore_state(), respectively, only use runtime PM
callbacks provided by device drivers, but in general those callbacks
need not provide the entire necessary functionality.  Namely, in
general it may be necessary to execute subsystem (i.e. device type,
device class or bus type) callbacks that will carry out all of the
necessary operations.

For this reason, modify pm_genpd_default_save_state() and
pm_genpd_default_restore_state() to execute subsystem callbacks,
if they are provided, and fall back to driver callbacks otherwise.

Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
parent 6887a413
Loading
Loading
Loading
Loading
+24 −8
Original line number Original line Diff line number Diff line
@@ -1615,16 +1615,24 @@ EXPORT_SYMBOL_GPL(__pm_genpd_remove_callbacks);
static int pm_genpd_default_save_state(struct device *dev)
static int pm_genpd_default_save_state(struct device *dev)
{
{
	int (*cb)(struct device *__dev);
	int (*cb)(struct device *__dev);
	struct device_driver *drv = dev->driver;


	cb = dev_gpd_data(dev)->ops.save_state;
	cb = dev_gpd_data(dev)->ops.save_state;
	if (cb)
	if (cb)
		return cb(dev);
		return cb(dev);


	if (drv && drv->pm && drv->pm->runtime_suspend)
	if (dev->type && dev->type->pm)
		return drv->pm->runtime_suspend(dev);
		cb = dev->type->pm->runtime_suspend;
	else if (dev->class && dev->class->pm)
		cb = dev->class->pm->runtime_suspend;
	else if (dev->bus && dev->bus->pm)
		cb = dev->bus->pm->runtime_suspend;
	else
		cb = NULL;


	return 0;
	if (!cb && dev->driver && dev->driver->pm)
		cb = dev->driver->pm->runtime_suspend;

	return cb ? cb(dev) : 0;
}
}


/**
/**
@@ -1634,16 +1642,24 @@ static int pm_genpd_default_save_state(struct device *dev)
static int pm_genpd_default_restore_state(struct device *dev)
static int pm_genpd_default_restore_state(struct device *dev)
{
{
	int (*cb)(struct device *__dev);
	int (*cb)(struct device *__dev);
	struct device_driver *drv = dev->driver;


	cb = dev_gpd_data(dev)->ops.restore_state;
	cb = dev_gpd_data(dev)->ops.restore_state;
	if (cb)
	if (cb)
		return cb(dev);
		return cb(dev);


	if (drv && drv->pm && drv->pm->runtime_resume)
	if (dev->type && dev->type->pm)
		return drv->pm->runtime_resume(dev);
		cb = dev->type->pm->runtime_resume;
	else if (dev->class && dev->class->pm)
		cb = dev->class->pm->runtime_resume;
	else if (dev->bus && dev->bus->pm)
		cb = dev->bus->pm->runtime_resume;
	else
		cb = NULL;


	return 0;
	if (!cb && dev->driver && dev->driver->pm)
		cb = dev->driver->pm->runtime_resume;

	return cb ? cb(dev) : 0;
}
}


#ifdef CONFIG_PM_SLEEP
#ifdef CONFIG_PM_SLEEP