From patchwork Tue Aug 15 06:26:38 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: 110098 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp5115150obb; Mon, 14 Aug 2017 23:28:00 -0700 (PDT) X-Received: by 10.84.218.66 with SMTP id f2mr30076964plm.206.1502778479993; Mon, 14 Aug 2017 23:27:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502778479; cv=none; d=google.com; s=arc-20160816; b=iv0cKBwOfFqQ+sDxCmLhkl4I/80y1z1J8ZdntL1BhefKSNyhIb55TWdatS+cRfjFT5 T2Olo3TzP3a7NNCDh7Wxb6gG42T7ca3kALsMoWJsPzijMiqoEtjP00OAV1akLvX+Mc7c QbonXJPMEYl68dLRTclsx36GNl2nTz4At8izVCWzxB/n1fviWg2tPnlo7Th5EBq4B1Y7 xoYLh9nffKI3O52WOnc+0Da+8JqIAsjmZiHd0int5RdSm6GkzLBLCdzxqf899ngJBsHf zBEdvEALDDlJ1h7N2IZv74XIifmSBAyaeV1gLOGwSxscpoM1NuA5E8Rd4snMJkjKK+J4 wvLA== 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=TBIRiI8+zwYNtkFmMxjeJaK/PDmLE37jRUUB+f/lfSM=; b=Z+dO37xIeHWZJ6SN7+oX7fdicBczCElaEOAOnKCoOfJJ7jc0CjZ8n3ejk0J++Ijj6N h4Qx4NObQyRJh+db6P4IZ7MeU74RcITC5lcvLogdUNg54w1zgMIB1FG5H3ngeF3ixwz9 MASJeeZ7hOYFMwZMZhsgteCfUweeqM5g99g+wBrFbVnUuAn/0ej0Knkh3ZAZP6c/fVTW 03lmoJR2WTwbzqfjvh/Qd4VxfXST4QYwrG4eBaSciXaZcT84UvmCCzXVKphPXpASlAUD DcoJ1trGJDAa30BIKHXtV6p+XmCN4fv29hTJ/W+aiKZdwdGDwXsdTOlZKiURPwP3IKeB 6yFg== 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 b34si5656677plc.965.2017.08.14.23.27.59; Mon, 14 Aug 2017 23:27:59 -0700 (PDT) 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 S1753483AbdHOG14 (ORCPT + 25 others); Tue, 15 Aug 2017 02:27:56 -0400 Received: from foss.arm.com ([217.140.101.70]:48120 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752484AbdHOG1v (ORCPT ); Tue, 15 Aug 2017 02:27:51 -0400 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 7F7682B; Mon, 14 Aug 2017 23:27:51 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.148]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DBEDA3F3E1; Mon, 14 Aug 2017 23:27:49 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 10/22] staging: ccree: rewrite GET_DMA_BUFFER_TYPE as func Date: Tue, 15 Aug 2017 09:26:38 +0300 Message-Id: <1502778412-16255-11-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1502778412-16255-1-git-send-email-gilad@benyossef.com> References: <1502778412-16255-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 The GET_DMA_BUFFER_TYPE macro was triggering a macro argument reuse warning from checkpatch. Rewrite the macro as inline function instead to avoid risk of unintended side effects. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_buffer_mgr.c | 26 +++++++++++++++++--------- drivers/staging/ccree/ssi_buffer_mgr.h | 6 ++++-- 2 files changed, 21 insertions(+), 11 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_buffer_mgr.c b/drivers/staging/ccree/ssi_buffer_mgr.c index 0b81fd5..4be7b51 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.c +++ b/drivers/staging/ccree/ssi_buffer_mgr.c @@ -34,11 +34,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, @@ -65,6 +60,19 @@ struct buffer_array { u32 *mlli_nents[MAX_NUM_OF_BUFFERS_IN_MLLI]; }; +static const char *dma_buf_types[SSI_DMA_BUF_TYPE_MAX] = { + "BUF_NULL", + "BUF_DLLI", + "BUF_MLLI" + "BUF_INVALID" +}; + +static inline const char *dma_buf_type_str(enum ssi_req_dma_buf_type type) +{ + type = (type < SSI_DMA_BUF_INVL) ? type : SSI_DMA_BUF_INVL; + return dma_buf_types[type]; +} + /** * ssi_buffer_mgr_get_sgl_nents() - Get scatterlist number of entries. * @@ -597,7 +605,7 @@ int ssi_buffer_mgr_map_blkcipher_request( } SSI_LOG_DEBUG("areq_ctx->dma_buf_type = %s\n", - GET_DMA_BUFFER_TYPE(req_ctx->dma_buf_type)); + dma_buf_type_str(req_ctx->dma_buf_type)); return 0; @@ -827,7 +835,7 @@ static inline int ssi_buffer_mgr_aead_chain_assoc( areq_ctx->assoc.nents = 0; areq_ctx->assoc.mlli_nents = 0; SSI_LOG_DEBUG("Chain assoc of length 0: buff_type=%s nents=%u\n", - GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type), + dma_buf_type_str(areq_ctx->assoc_buff_type), areq_ctx->assoc.nents); goto chain_assoc_exit; } @@ -879,7 +887,7 @@ static inline int ssi_buffer_mgr_aead_chain_assoc( if (unlikely((do_chain) || (areq_ctx->assoc_buff_type == SSI_DMA_BUF_MLLI))) { SSI_LOG_DEBUG("Chain assoc: buff_type=%s nents=%u\n", - GET_DMA_BUFFER_TYPE(areq_ctx->assoc_buff_type), + dma_buf_type_str(areq_ctx->assoc_buff_type), areq_ctx->assoc.nents); ssi_buffer_mgr_add_scatterlist_entry( sg_data, areq_ctx->assoc.nents, @@ -1555,7 +1563,7 @@ int ssi_buffer_mgr_map_hash_request_final( /* change the buffer index for the unmap function */ areq_ctx->buff_index = (areq_ctx->buff_index ^ 1); SSI_LOG_DEBUG("areq_ctx->data_dma_buf_type = %s\n", - GET_DMA_BUFFER_TYPE(areq_ctx->data_dma_buf_type)); + dma_buf_type_str(areq_ctx->data_dma_buf_type)); return 0; fail_unmap_din: diff --git a/drivers/staging/ccree/ssi_buffer_mgr.h b/drivers/staging/ccree/ssi_buffer_mgr.h index 41f5223..93972fd 100644 --- a/drivers/staging/ccree/ssi_buffer_mgr.h +++ b/drivers/staging/ccree/ssi_buffer_mgr.h @@ -28,8 +28,10 @@ enum ssi_req_dma_buf_type { SSI_DMA_BUF_NULL = 0, - SSI_DMA_BUF_DLLI, - SSI_DMA_BUF_MLLI + SSI_DMA_BUF_DLLI = 1, + SSI_DMA_BUF_MLLI = 2, + SSI_DMA_BUF_INVL = 3, + SSI_DMA_BUF_TYPE_MAX = 4 }; enum ssi_sg_cpy_direct {