diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2020-02-11 19:19:08 +0100 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2020-02-22 02:25:44 +0100 |
commit | 8c7849a30255cfd9a9ba412b1517e20a8572448b (patch) | |
tree | 26dc1058b4bb604002ca761bcbfd6d208f3402a2 /drivers/crypto/ccree/cc_pm.c | |
parent | crypto: ccree - use u32 for SRAM addresses (diff) | |
download | linux-8c7849a30255cfd9a9ba412b1517e20a8572448b.tar.xz linux-8c7849a30255cfd9a9ba412b1517e20a8572448b.zip |
crypto: ccree - simplify Runtime PM handling
Currently, a large part of the probe function runs before Runtime PM is
enabled. As the driver manages the device's clock manually, this may
work fine on some systems, but may break on platforms with a more
complex power hierarchy.
Fix this by moving the initialization of Runtime PM before the first
register access (in cc_wait_for_reset_completion()), and putting the
device to sleep only after the last access (in cc_set_ree_fips_status()).
This allows to remove the pm_on flag, which was used to track manually
if Runtime PM had been enabled or not.
Remove the cc_pm_{init,go,fini}() wrappers, as they are called only
once, and obscure operation.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/ccree/cc_pm.c')
-rw-r--r-- | drivers/crypto/ccree/cc_pm.c | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/drivers/crypto/ccree/cc_pm.c b/drivers/crypto/ccree/cc_pm.c index 81376173c3ec..f7729fc1ee59 100644 --- a/drivers/crypto/ccree/cc_pm.c +++ b/drivers/crypto/ccree/cc_pm.c @@ -64,23 +64,15 @@ int cc_pm_resume(struct device *dev) int cc_pm_get(struct device *dev) { - int rc = 0; - struct cc_drvdata *drvdata = dev_get_drvdata(dev); - - if (drvdata->pm_on) - rc = pm_runtime_get_sync(dev); + int rc = pm_runtime_get_sync(dev); return (rc == 1 ? 0 : rc); } void cc_pm_put_suspend(struct device *dev) { - struct cc_drvdata *drvdata = dev_get_drvdata(dev); - - if (drvdata->pm_on) { - pm_runtime_mark_last_busy(dev); - pm_runtime_put_autosuspend(dev); - } + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); } bool cc_pm_is_dev_suspended(struct device *dev) @@ -88,27 +80,3 @@ bool cc_pm_is_dev_suspended(struct device *dev) /* check device state using runtime api */ return pm_runtime_suspended(dev); } - -int cc_pm_init(struct cc_drvdata *drvdata) -{ - struct device *dev = drvdata_to_dev(drvdata); - - /* must be before the enabling to avoid redundant suspending */ - pm_runtime_set_autosuspend_delay(dev, CC_SUSPEND_TIMEOUT); - pm_runtime_use_autosuspend(dev); - /* set us as active - note we won't do PM ops until cc_pm_go()! */ - return pm_runtime_set_active(dev); -} - -/* enable the PM module*/ -void cc_pm_go(struct cc_drvdata *drvdata) -{ - pm_runtime_enable(drvdata_to_dev(drvdata)); - drvdata->pm_on = true; -} - -void cc_pm_fini(struct cc_drvdata *drvdata) -{ - pm_runtime_disable(drvdata_to_dev(drvdata)); - drvdata->pm_on = false; -} |