From patchwork Tue Feb 24 06:09:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinod Koul X-Patchwork-Id: 5870201 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 658E79F373 for ; Tue, 24 Feb 2015 06:13:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 925802069F for ; Tue, 24 Feb 2015 06:13:58 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 6AB6B20696 for ; Tue, 24 Feb 2015 06:13:57 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9063B260704; Tue, 24 Feb 2015 07:13:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id A20342604EA; Tue, 24 Feb 2015 07:13:01 +0100 (CET) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D33AC2604F0; Tue, 24 Feb 2015 07:12:58 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by alsa0.perex.cz (Postfix) with ESMTP id C21C32604E4 for ; Tue, 24 Feb 2015 07:12:49 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP; 23 Feb 2015 22:08:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,637,1418112000"; d="scan'208";a="531891174" Received: from vkoul-udesk3.iind.intel.com ([10.223.84.65]) by orsmga003.jf.intel.com with ESMTP; 23 Feb 2015 22:03:42 -0800 From: Vinod Koul To: alsa-devel@alsa-project.org Date: Tue, 24 Feb 2015 11:39:45 +0530 Message-Id: <1424758188-15569-3-git-send-email-vinod.koul@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1424758188-15569-1-git-send-email-vinod.koul@intel.com> References: <1424758188-15569-1-git-send-email-vinod.koul@intel.com> Cc: Vinod Koul , broonie@kernel.org, "Subhransu S. Prusty" , lgirdwood@gmail.com Subject: [alsa-devel] [PATCH v2 2/4] ASoC: Intel: Move the fw download to power_control X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Thus removing the runtime_resume handler. Signed-off-by: Subhransu S. Prusty Signed-off-by: Vinod Koul --- sound/soc/intel/sst/sst.c | 18 +----------------- sound/soc/intel/sst/sst_drv_interface.c | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/sound/soc/intel/sst/sst.c b/sound/soc/intel/sst/sst.c index 8f938112a01f..4d8f73ac5dd9 100644 --- a/sound/soc/intel/sst/sst.c +++ b/sound/soc/intel/sst/sst.c @@ -492,21 +492,6 @@ iram: return ret; } -static int intel_sst_runtime_resume(struct device *dev) -{ - int ret = 0; - struct intel_sst_drv *ctx = dev_get_drvdata(dev); - - if (ctx->sst_state == SST_RESET) { - ret = sst_load_fw(ctx); - if (ret) { - dev_err(dev, "FW download fail %d\n", ret); - sst_set_fw_state_locked(ctx, SST_RESET); - } - } - return ret; -} - static int intel_sst_resume(struct device *dev) { struct intel_sst_drv *ctx = dev_get_drvdata(dev); @@ -515,7 +500,7 @@ static int intel_sst_resume(struct device *dev) struct sst_block *block; if (!fw_save) - return intel_sst_runtime_resume(dev); + return 0; sst_set_fw_state_locked(ctx, SST_FW_LOADING); @@ -560,6 +545,5 @@ const struct dev_pm_ops intel_sst_pm = { .suspend = intel_sst_suspend, .resume = intel_sst_resume, .runtime_suspend = intel_sst_runtime_suspend, - .runtime_resume = intel_sst_runtime_resume, }; EXPORT_SYMBOL_GPL(intel_sst_pm); diff --git a/sound/soc/intel/sst/sst_drv_interface.c b/sound/soc/intel/sst/sst_drv_interface.c index 5d56fcdd58d8..549af7d7f6d0 100644 --- a/sound/soc/intel/sst/sst_drv_interface.c +++ b/sound/soc/intel/sst/sst_drv_interface.c @@ -138,12 +138,31 @@ int sst_get_stream(struct intel_sst_drv *ctx, static int sst_power_control(struct device *dev, bool state) { struct intel_sst_drv *ctx = dev_get_drvdata(dev); + int ret = 0; - dev_dbg(ctx->dev, "state:%d", state); - if (state == true) - return pm_runtime_get_sync(dev); - else + if (state == true) { + ret = pm_runtime_get_sync(dev); + dev_dbg(ctx->dev, "Enable: pm usage count: %d\n", + atomic_read(&dev->power.usage_count)); + if (ret < 0) { + dev_err(ctx->dev, "Runtime get failed with err: %d\n", ret); + return ret; + } + if ((ctx->sst_state == SST_RESET) && + (atomic_read(&dev->power.usage_count) == 1)) { + ret = sst_load_fw(ctx); + if (ret) { + dev_err(dev, "FW download fail %d\n", ret); + sst_set_fw_state_locked(ctx, SST_RESET); + ret = sst_pm_runtime_put(ctx); + } + } + } else { + dev_dbg(ctx->dev, "Disable: pm usage count: %d\n", + atomic_read(&dev->power.usage_count)); return sst_pm_runtime_put(ctx); + } + return ret; } /*