diff options
author | David Lin <dtwlin@google.com> | 2016-07-14 15:13:00 -0500 |
---|---|---|
committer | Alex Elder <elder@linaro.org> | 2016-07-14 16:53:55 -0500 |
commit | af5dc7f8c0f4b71fa53db2e8d6f18c26048a182f (patch) | |
tree | aa9d174798fc0d999338394536972b854cd1f467 /drivers/staging/greybus/gbphy.h | |
parent | greybus: camera: add runtime pm support (diff) | |
download | linux-dev-af5dc7f8c0f4b71fa53db2e8d6f18c26048a182f.tar.xz linux-dev-af5dc7f8c0f4b71fa53db2e8d6f18c26048a182f.zip |
greybus: gbphy: add gbphy runtime pm support
Since GBphy is a child of the Bundle device driver, for those runtime pm
settings that are common to all the protocol drivers need to go in to
the GBphy bus driver.
Testing Done:
- Check gbphy driver can be autosuspended
Signed-off-by: David Lin <dtwlin@google.com>
Signed-off-by: Axel Haslam <ahaslam@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Alex Elder <elder@linaro.org>
Diffstat (limited to 'drivers/staging/greybus/gbphy.h')
-rw-r--r-- | drivers/staging/greybus/gbphy.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/staging/greybus/gbphy.h b/drivers/staging/greybus/gbphy.h index 68ad51821a60..57c6f65aeb7f 100644 --- a/drivers/staging/greybus/gbphy.h +++ b/drivers/staging/greybus/gbphy.h @@ -66,5 +66,45 @@ void gb_gbphy_deregister_driver(struct gbphy_driver *driver); #define module_gbphy_driver(__gbphy_driver) \ module_driver(__gbphy_driver, gb_gbphy_register, gb_gbphy_deregister) +#ifdef CONFIG_PM_RUNTIME +static inline int gbphy_runtime_get_sync(struct gbphy_device *gbphy_dev) +{ + struct device *dev = &gbphy_dev->dev; + int ret; + + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + dev_err(dev, "pm_runtime_get_sync failed: %d\n", ret); + pm_runtime_put_noidle(dev); + return ret; + } + + return 0; +} + +static inline void gbphy_runtime_put_autosuspend(struct gbphy_device *gbphy_dev) +{ + struct device *dev = &gbphy_dev->dev; + + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); +} + +static inline void gbphy_runtime_get_noresume(struct gbphy_device *gbphy_dev) +{ + pm_runtime_get_noresume(&gbphy_dev->dev); +} + +static inline void gbphy_runtime_put_noidle(struct gbphy_device *gbphy_dev) +{ + pm_runtime_put_noidle(&gbphy_dev->dev); +} +#else +static inline int gbphy_runtime_get_sync(struct device *dev) { return 0; } +static inline void gbphy_runtime_put_autosuspend(struct device *dev) {} +static inline void gbphy_runtime_get_noresume(struct gbphy_device *gbphy_dev) {} +static inline void gbphy_runtime_put_noidle(struct gbphy_device *gbphy_dev) {} +#endif + #endif /* __GBPHY_H */ |