From patchwork Mon Nov 13 14:45:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 118798 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1131969edl; Mon, 13 Nov 2017 06:47:52 -0800 (PST) X-Google-Smtp-Source: AGs4zMaDC0idYZ5EQecO80KS58DeNjLUn0E3MBvi421dKZYkCYQ95BMbUGsfNnhXG6U8xHJsIe8h X-Received: by 10.101.91.78 with SMTP id y14mr8950468pgr.380.1510584471979; Mon, 13 Nov 2017 06:47:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510584471; cv=none; d=google.com; s=arc-20160816; b=iHWnwGREaAMrfsj25Vr+kqnXB1bGA1vr4wFBflOlXozQZL8yUEcbZ79VOAXj4UaGXp 4Abp0aAoKtffD8MTBRA+tD6g4Aas0fSogRixJX25Lp1uLXp85RfzLMSdFNr3ETazP1Tm AQ7ONZ7ejPPmyczYb0pzAgWlkmxwVNk7DfmU/KMk8aSSnR/e0AHTqVCJ/2ChkzQeCd18 THWEmJ8IK8ycoon8MPD24X0eTMAlc8UFXfwChX/zW3SWot+D3e71KWYIWRp0/5C65noO 7wIUgq7RCSOYxipAGYPnuBa35dkgQIGdYlGupCjQjAdZHgBEjQumUwpg5lXY46AQrEf5 tk5g== 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=BCGC9QxnCdDlS3tnAlT184DUnnbZcwblEJSI0yQf8lI=; b=SaTkF9ioezbf2f1dqF9E7Wm5YHbZPXo2ye+T6s0JQ4Ochd2qk5kE6B6NCNiJUw0O2t ykqKd1cLFpYubKB6o6xxZCuatoohsujsZv3C/C8gPbjaf0fDzQHFkzAK9SMYPafkqJwd JfVPyY9DRKbQt3QgUas9iqgIB3EvJgrjM0sYOTscPcGE5THiG7o9qeZ450QpaX/3T8j/ OIiFS32umkYB+G/wgrnXnh0diL5Ze5X4fG53mHMABRaxAI98TkWvGfd0tpWZUiGfSoxi fuFrcTicS4PVUDubg6CBwnIlX1gEhhPBZhOhCKPA/4UOfcCGk7lTOQOX7L+pKbdx6aRA lbEg== 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 z10si14180869pgu.113.2017.11.13.06.47.49; Mon, 13 Nov 2017 06:47:51 -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 S1753416AbdKMOrr (ORCPT + 27 others); Mon, 13 Nov 2017 09:47:47 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47392 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752735AbdKMOrm (ORCPT ); Mon, 13 Nov 2017 09:47:42 -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 69F461435; Mon, 13 Nov 2017 06:47:42 -0800 (PST) Received: from sugar.kfn.arm.com (unknown [10.45.48.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C56413F318; Mon, 13 Nov 2017 06:47:40 -0800 (PST) From: Gilad Ben-Yossef To: Greg Kroah-Hartman Cc: Ofir Drang , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/24] staging: ccree: replace macro with inline func Date: Mon, 13 Nov 2017 14:45:42 +0000 Message-Id: <1510584358-29473-15-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510584358-29473-1-git-send-email-gilad@benyossef.com> References: <1510584358-29473-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 GET_DMA_BUFFER_TYPE with an inline function variant with type checking. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_buffer_mgr.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) -- 2.7.4 diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 684c934..5e01477 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -33,11 +33,6 @@ #include "ssi_hash.h" #include "ssi_aead.h" -#define GET_DMA_BUFFER_TYPE(buff_type) ( \ - ((buff_type) == SSI_DMA_BUF_NULL) ? "BUF_NULL" : \ - ((buff_type) == SSI_DMA_BUF_DLLI) ? "BUF_DLLI" : \ - ((buff_type) == SSI_DMA_BUF_MLLI) ? "BUF_MLLI" : "BUF_INVALID") - enum dma_buffer_type { DMA_NULL_TYPE = -1, DMA_SGL_TYPE = 1, @@ -64,6 +59,20 @@ struct buffer_array { u32 *mlli_nents[MAX_NUM_OF_BUFFERS_IN_MLLI]; }; +static inline char *cc_dma_buf_type(enum ssi_req_dma_buf_type type) +{ + switch (type) { + case SSI_DMA_BUF_NULL: + return "BUF_NULL"; + case SSI_DMA_BUF_DLLI: + return "BUF_DLLI"; + case SSI_DMA_BUF_MLLI: + return "BUF_MLLI"; + default: + return "BUF_INVALID"; + } +} + /** * cc_copy_mac() - Copy MAC to temporary location * @@ -594,7 +603,7 @@ int cc_map_blkcipher_request( } dev_dbg(dev, "areq_ctx->dma_buf_type = %s\n", - GET_DMA_BUFFER_TYPE(req_ctx->dma_buf_type)); + cc_dma_buf_type(req_ctx->dma_buf_type)); return 0; @@ -819,7 +828,7 @@ static inline int cc_aead_chain_assoc( areq_ctx->assoc.nents = 0; areq_ctx->assoc.mlli_nents = 0; dev_dbg(dev, "Chain assoc of length 0: buff_type=%s nents=%u\n", - GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type), + cc_dma_buf_type(areq_ctx->assoc_buff_type), areq_ctx->assoc.nents); goto chain_assoc_exit; } @@ -871,7 +880,7 @@ static inline int cc_aead_chain_assoc( if (unlikely((do_chain) || areq_ctx->assoc_buff_type == SSI_DMA_BUF_MLLI)) { dev_dbg(dev, "Chain assoc: buff_type=%s nents=%u\n", - GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type), + cc_dma_buf_type(areq_ctx->assoc_buff_type), areq_ctx->assoc.nents); cc_add_sg_entry(dev, sg_data, areq_ctx->assoc.nents, req->src, req->assoclen, 0, is_last, @@ -1496,7 +1505,7 @@ int cc_map_hash_request_final(struct ssi_drvdata *drvdata, void *ctx, /* change the buffer index for the unmap function */ areq_ctx->buff_index = (areq_ctx->buff_index ^ 1); dev_dbg(dev, "areq_ctx->data_dma_buf_type = %s\n", - GET_DMA_BUFFER_TYPE(areq_ctx->data_dma_buf_type)); + cc_dma_buf_type(areq_ctx->data_dma_buf_type)); return 0; fail_unmap_din: