From patchwork Wed Jan 3 13:35:22 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: 123313 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp10182625qgn; Wed, 3 Jan 2018 05:38:56 -0800 (PST) X-Google-Smtp-Source: ACJfBouzSfuOHGzP55CFgUnZrrGlC39I9EmB83rQbhPh2W+6iY2RNTrEn0ktienq3i5zskFmaIBl X-Received: by 10.98.190.26 with SMTP id l26mr1458209pff.90.1514986736715; Wed, 03 Jan 2018 05:38:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514986736; cv=none; d=google.com; s=arc-20160816; b=kLNn+vVoXpTIVBh6+aF6qHM/J49cvPLjXjm5fFFIY5BHMqVMXICwYdRBxwRU9/e78W a7y2NeXTq+ZmoXOSKWvk8gqXcNe8N27eyLkTuwwz1hqfrbImoCMCLpm/HKSCi28SUViX QYjsfDOH8vPyXgKoWC+9Yq4CdMDoxk/wmm4RZijzX30odEP4tjkITSl0KCd1XSfRpJFt eo5r+tFM7yuVo6Y97tC1Rshoqtc+8lzjCRgUE+L1PLnweKH1THyPHgz4Ondh2EfYBTEU PB2Sc2ZHoHaEYpbQcFOoKMGObqELaKXA+exilsL3ixnmTITdBkogkEu25EU+rpI46XXP Nz/w== 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=Y90JTKEYrmKZpKl9Zu73t04aMDtO40zkOOaUnv1nh6E=; b=U0qmzTB72eHaZQQgLhY9bQWrmUz6IcWzELkygmjA/fdxRPIdMtGAuooQ9z8w8QMMmh TnQBkn4inLD8rhG7UYXU/jXEIH7/eYuFAH0TgBhKVAjSTP0w5rxbiYr/hYZBSpWUYp15 Pp2ZpkQfxzcYHBPYuxxGVSzdkAtbvf2AEuKl2jIR9pSq+oFaqOxx6Gk01zyKDVHwTyCN 3+9JnGdIrFb1oi67yF0CO17tpwiJbWo5nX+jVk29WIq28cblrblwptUU2+TteT40OJUl 5MIbYP2mNWYchI1N2uqJ6mmoCauCEpj628hZMN4d3hBBGisS9aT6SEwacjAa5Q/Brzo5 +cDg== 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 s192si15198pgs.472.2018.01.03.05.38.56; Wed, 03 Jan 2018 05:38:56 -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 S1753125AbeACNiw (ORCPT + 28 others); Wed, 3 Jan 2018 08:38:52 -0500 Received: from foss.arm.com ([217.140.101.70]:50152 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751716AbeACNiv (ORCPT ); Wed, 3 Jan 2018 08:38:51 -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 E55D71529; Wed, 3 Jan 2018 05:38:50 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6536A3F24A; Wed, 3 Jan 2018 05:38:49 -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 v2 15/27] staging: ccree: use Makefile to include PM code Date: Wed, 3 Jan 2018 13:35:22 +0000 Message-Id: <1514986544-5888-16-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514986544-5888-1-git-send-email-gilad@benyossef.com> References: <1514986544-5888-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 bb47144..c107e25 100644 --- a/drivers/staging/ccree/Makefile +++ b/drivers/staging/ccree/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 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 4031881..b0ace75 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 138de71..c28f3aa 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 e99c148..01f4756 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 } }