Commit 5bb400ce authored by Vinod Koul's avatar Vinod Koul Committed by Mark Brown

ASoC: Intel: wrap runtime_pm usage count under CONFIG_PM

The struct dev_pm_ops defines usage_count only when CONFIG_PM is defined. So
we should use this variable only in cases where this falg is true.
So we define a local variable and read the value under this flag. In non PM
cases, we set this to 1.
Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3f2dcbea
...@@ -139,17 +139,23 @@ static int sst_power_control(struct device *dev, bool state) ...@@ -139,17 +139,23 @@ static int sst_power_control(struct device *dev, bool state)
{ {
struct intel_sst_drv *ctx = dev_get_drvdata(dev); struct intel_sst_drv *ctx = dev_get_drvdata(dev);
int ret = 0; int ret = 0;
int usage_count = 0;
#ifdef CONFIG_PM
usage_count = atomic_read(&dev->power.usage_count);
#else
usage_count = 1;
#endif
if (state == true) { if (state == true) {
ret = pm_runtime_get_sync(dev); ret = pm_runtime_get_sync(dev);
dev_dbg(ctx->dev, "Enable: pm usage count: %d\n",
atomic_read(&dev->power.usage_count)); dev_dbg(ctx->dev, "Enable: pm usage count: %d\n", usage_count);
if (ret < 0) { if (ret < 0) {
dev_err(ctx->dev, "Runtime get failed with err: %d\n", ret); dev_err(ctx->dev, "Runtime get failed with err: %d\n", ret);
return ret; return ret;
} }
if ((ctx->sst_state == SST_RESET) && if ((ctx->sst_state == SST_RESET) && (usage_count == 1)) {
(atomic_read(&dev->power.usage_count) == 1)) {
ret = sst_load_fw(ctx); ret = sst_load_fw(ctx);
if (ret) { if (ret) {
dev_err(dev, "FW download fail %d\n", ret); dev_err(dev, "FW download fail %d\n", ret);
...@@ -158,8 +164,7 @@ static int sst_power_control(struct device *dev, bool state) ...@@ -158,8 +164,7 @@ static int sst_power_control(struct device *dev, bool state)
} }
} }
} else { } else {
dev_dbg(ctx->dev, "Disable: pm usage count: %d\n", dev_dbg(ctx->dev, "Disable: pm usage count: %d\n", usage_count);
atomic_read(&dev->power.usage_count));
return sst_pm_runtime_put(ctx); return sst_pm_runtime_put(ctx);
} }
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment