Re: [PATCH] PM: add dpm_use_runtime_{suspend, resume} helper functions

Alan Stern
2010-03-01T18:40:03Z

On Sat, 27 Feb 2010, Rafael J. Wysocki wrote:

> What about the patch below, then (untested)?
>
> Use GENERIC_SUBSYS_PM_OPS for the subsystem and then
> UNIVERSAL_DEV_PM_OPS for drivers, possibly passing NULL as idle_fn.

> +#ifdef CONFIG_PM_SLEEP
> +#define GENERIC_SYSTEM_SLEEP_PM_OPS \
> + .suspend = pm_generic_suspend, \
> + .resume = pm_generic_resume,
> +#else
> +#define GENERIC_SYSTEM_SLEEP_PM_OPS

Wouldn't you want to have this work for hibernation as well as suspend?
So the .freeze, .thaw, etc. members should be defined too.

> +/*
> + * Use this for subsystems (bus types, device types, device classes) that only
> + * need to invoke PM callbacks provided by device drivers supporting both the
> + * system sleep PM and runtime PM.
> + */
> +#define GENERIC_SUBSYS_PM_OPS(name) \
> +const struct dev_pm_ops name = { \
> +GENERIC_SYSTEM_SLEEP_PM_OPS \
> +GENERIC_RUNTIME_PM_OPS \
> }

There's no reason for this to have "name" as a parameter, since all
instances of the structure will be identical. Instead you can put

extern const struct dev_pm_ops generic_subsys_pm_ops;
EXPORT_SYMBOL_GPL(generic_subsys_pm_ops);

in the header file and define the structure in generic_ops.c.

Alan Stern