From patchwork Mon Jan 1 12:06:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 123046 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7797102qgn; Mon, 1 Jan 2018 04:10:02 -0800 (PST) X-Google-Smtp-Source: ACJfBovMCUJO84++RTm0meMdYTjaUhWVbYSd4GlWMigjPqEePIiMD6kx6hYiE/xZeOgN/U8qvGOV X-Received: by 10.84.129.193 with SMTP id b59mr42371681plb.361.1514808602670; Mon, 01 Jan 2018 04:10:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514808602; cv=none; d=google.com; s=arc-20160816; b=B4otyS44TCUPGJwzF+rO3BKAGfGZiGej0dcj+hUVQNrKp+igIkCRjkqL77EZXYvriI kBLV9PsBoDHLsU2jRhDvafTwmtw5IR1H44qYq/2vKY3QcpdzSeLyy6pNFropHdc53eIN 0wshFj4lPBaLctrmKVE9d8iHQzq3mw7kqt/JHyX4ZCXwwj2njYoHbn3YRhV1r+T6oPbv IZnyrggQND+ggGJyg86JrpINopw5IP1stKkYntWBBHiAB3xyXDqFJKwADlm3RJvzz8tk bfvTSnBBqJKmr1MnUm2KH1aulunTfi+D44J/SM88yhuEfyouB6LRMro5ZAF+Cb/JvGLn KDDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=pevjiKsGo3arSVlGGEWPg8EbjKsBPv8E1BdQMwgY0To=; b=q5op2gPCkLGvzVwWgLrQAguy8g/LDowHvbp2O20SBQRjy4nZi2imRV8elUe+BFS6qx Ju5yaTINcfOElqWML0rAjsLjK1D8HbWXd/h8/bn3FpaMsUPyZuVBPCskNvxWlumV8/SP Y760qKCWx9/C+Gfl7RRpbHuJRUyje1+jRNWkHusAXqzeRtFLPtKF34opHs64fTAVDM2q OmTsf8+0OeXEZQP8b1XQ4m5znh7RCcaPlby5DuGRQ5k4gzJlwOp3RLjReqfZn2POII8O ZXKmQj3a2PhAgOngEPmLZqz0tis34KLspGBhUZjSWfJ9lY5wWxb0vRpo7z3GgJ25UVLH RYPg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si31995315pls.247.2018.01.01.04.10.02; Mon, 01 Jan 2018 04:10:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751664AbeAAMJ7 (ORCPT + 28 others); Mon, 1 Jan 2018 07:09:59 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59178 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751403AbeAAMJ6 (ORCPT ); Mon, 1 Jan 2018 07:09:58 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2F4D315A2; Mon, 1 Jan 2018 04:09:58 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.158]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A07A83F41F; Mon, 1 Jan 2018 04:09:54 -0800 (PST) From: Gilad Ben-Yossef To: Greg Kroah-Hartman Cc: Ofir Drang , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org Subject: [PATCH 15/26] staging: ccree: use Makefile to include PM code Date: Mon, 1 Jan 2018 12:06:42 +0000 Message-Id: <1514808421-21993-16-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514808421-21993-1-git-send-email-gilad@benyossef.com> References: <1514808421-21993-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace ugly ifdefs with some inline macros and Makefile magic for optionally including power management related code for better readability. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/Makefile | 3 ++- drivers/staging/ccree/ssi_pm.c | 9 +------- drivers/staging/ccree/ssi_pm.h | 39 +++++++++++++++++++++++++++------ drivers/staging/ccree/ssi_request_mgr.c | 18 ++------------- 4 files changed, 37 insertions(+), 32 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/Makefile b/drivers/staging/ccree/Makefile index ab9f073..bb9c9e0 100644 --- a/drivers/staging/ccree/Makefile +++ b/drivers/staging/ccree/Makefile @@ -1,4 +1,5 @@ obj-$(CONFIG_CRYPTO_DEV_CCREE) := ccree.o -ccree-y := ssi_driver.o ssi_buffer_mgr.o ssi_request_mgr.o ssi_cipher.o ssi_hash.o ssi_aead.o ssi_ivgen.o ssi_sram_mgr.o ssi_pm.o +ccree-y := ssi_driver.o ssi_buffer_mgr.o ssi_request_mgr.o ssi_cipher.o ssi_hash.o ssi_aead.o ssi_ivgen.o ssi_sram_mgr.o ccree-$(CONFIG_CRYPTO_FIPS) += ssi_fips.o ccree-$(CONFIG_DEBUG_FS) += cc_debugfs.o +ccree-$(CONFIG_PM) += ssi_pm.o diff --git a/drivers/staging/ccree/ssi_pm.c b/drivers/staging/ccree/ssi_pm.c index 670f2d3..b7a8ff6 100644 --- a/drivers/staging/ccree/ssi_pm.c +++ b/drivers/staging/ccree/ssi_pm.c @@ -14,8 +14,6 @@ #include "ssi_hash.h" #include "ssi_pm.h" -#if defined(CONFIG_PM) - #define POWER_DOWN_ENABLE 0x01 #define POWER_DOWN_DISABLE 0x00 @@ -103,12 +101,9 @@ int cc_pm_put_suspend(struct device *dev) return rc; } -#endif - int cc_pm_init(struct cc_drvdata *drvdata) { int rc = 0; -#if defined(CONFIG_PM) struct device *dev = drvdata_to_dev(drvdata); /* must be before the enabling to avoid resdundent suspending */ @@ -120,13 +115,11 @@ int cc_pm_init(struct cc_drvdata *drvdata) return rc; /* enable the PM module*/ pm_runtime_enable(dev); -#endif + return rc; } void cc_pm_fini(struct cc_drvdata *drvdata) { -#if defined(CONFIG_PM) pm_runtime_disable(drvdata_to_dev(drvdata)); -#endif } diff --git a/drivers/staging/ccree/ssi_pm.h b/drivers/staging/ccree/ssi_pm.h index 0e33214..c45247a 100644 --- a/drivers/staging/ccree/ssi_pm.h +++ b/drivers/staging/ccree/ssi_pm.h @@ -11,21 +11,46 @@ #define CC_SUSPEND_TIMEOUT 3000 -int cc_pm_init(struct cc_drvdata *drvdata); - -void cc_pm_fini(struct cc_drvdata *drvdata); - #if defined(CONFIG_PM) extern const struct dev_pm_ops ccree_pm; +int cc_pm_init(struct cc_drvdata *drvdata); +void cc_pm_fini(struct cc_drvdata *drvdata); int cc_pm_suspend(struct device *dev); - int cc_pm_resume(struct device *dev); - int cc_pm_get(struct device *dev); - int cc_pm_put_suspend(struct device *dev); + +#else + +static inline int cc_pm_init(struct cc_drvdata *drvdata) +{ + return 0; +} + +static inline void cc_pm_fini(struct cc_drvdata *drvdata) {} + +static inline int cc_pm_suspend(struct device *dev) +{ + return 0; +} + +static inline int cc_pm_resume(struct device *dev) +{ + return 0; +} + +static inline int cc_pm_get(struct device *dev) +{ + return 0; +} + +static inline int cc_pm_put_suspend(struct device *dev) +{ + return 0; +} + #endif #endif /*__POWER_MGR_H__*/ diff --git a/drivers/staging/ccree/ssi_request_mgr.c b/drivers/staging/ccree/ssi_request_mgr.c index e0b1d95..b71200a 100644 --- a/drivers/staging/ccree/ssi_request_mgr.c +++ b/drivers/staging/ccree/ssi_request_mgr.c @@ -46,9 +46,7 @@ struct cc_req_mgr_handle { #else struct tasklet_struct comptask; #endif -#if defined(CONFIG_PM) bool is_runtime_suspended; -#endif }; struct cc_bl_item { @@ -404,9 +402,7 @@ static void cc_proc_backlog(struct cc_drvdata *drvdata) spin_unlock(&mgr->hw_lock); if (rc != -EINPROGRESS) { -#if defined(CONFIG_PM) cc_pm_put_suspend(dev); -#endif creq->user_cb(dev, req, rc); } @@ -432,13 +428,12 @@ int cc_send_request(struct cc_drvdata *drvdata, struct cc_crypto_req *cc_req, gfp_t flags = cc_gfp_flags(req); struct cc_bl_item *bli; -#if defined(CONFIG_PM) rc = cc_pm_get(dev); if (rc) { dev_err(dev, "ssi_power_mgr_runtime_get returned %x\n", rc); return rc; } -#endif + spin_lock_bh(&mgr->hw_lock); rc = cc_queues_status(drvdata, mgr, total_len); @@ -452,9 +447,7 @@ int cc_send_request(struct cc_drvdata *drvdata, struct cc_crypto_req *cc_req, bli = kmalloc(sizeof(*bli), flags); if (!bli) { -#if defined(CONFIG_PM) cc_pm_put_suspend(dev); -#endif return -ENOMEM; } @@ -486,13 +479,12 @@ int cc_send_sync_request(struct cc_drvdata *drvdata, cc_req->user_cb = request_mgr_complete; cc_req->user_arg = &cc_req->seq_compl; -#if defined(CONFIG_PM) rc = cc_pm_get(dev); if (rc) { dev_err(dev, "ssi_power_mgr_runtime_get returned %x\n", rc); return rc; } -#endif + while (true) { spin_lock_bh(&mgr->hw_lock); rc = cc_queues_status(drvdata, mgr, len + 1); @@ -502,9 +494,7 @@ int cc_send_sync_request(struct cc_drvdata *drvdata, spin_unlock_bh(&mgr->hw_lock); if (rc != -EAGAIN) { -#if defined(CONFIG_PM) cc_pm_put_suspend(dev); -#endif return rc; } wait_for_completion_interruptible(&drvdata->hw_queue_avail); @@ -515,9 +505,7 @@ int cc_send_sync_request(struct cc_drvdata *drvdata, spin_unlock_bh(&mgr->hw_lock); if (rc != -EINPROGRESS) { -#if defined(CONFIG_PM) cc_pm_put_suspend(dev); -#endif return rc; } @@ -621,9 +609,7 @@ static void proc_completions(struct cc_drvdata *drvdata) dev_dbg(dev, "Dequeue request tail=%u\n", *tail); dev_dbg(dev, "Request completed. axi_completed=%d\n", request_mgr_handle->axi_completed); -#if defined(CONFIG_PM) cc_pm_put_suspend(dev); -#endif } }