From patchwork Wed Mar 8 12:41:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9610997 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 610676046A for ; Wed, 8 Mar 2017 12:51:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3619A284F3 for ; Wed, 8 Mar 2017 12:51:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B28C28567; Wed, 8 Mar 2017 12:51:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5C49284F3 for ; Wed, 8 Mar 2017 12:51:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752990AbdCHMvo (ORCPT ); Wed, 8 Mar 2017 07:51:44 -0500 Received: from mout.web.de ([212.227.15.14]:63744 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752062AbdCHMvg (ORCPT ); Wed, 8 Mar 2017 07:51:36 -0500 Received: from [192.168.1.2] ([92.228.144.238]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MJ1Nh-1cj6re46fZ-002TTS; Wed, 08 Mar 2017 13:41:12 +0100 Subject: [PATCH 02/26] IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range() To: linux-rdma@vger.kernel.org, Devesh Sharma , Doug Ledford , Hal Rosenstock , Sean Hefty , Selvin Xavier References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <7abcae42-6bc2-0653-69ea-5112943ff72e@users.sourceforge.net> Date: Wed, 8 Mar 2017 13:41:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:Z+JUdolhHGrlWRAPokLkKYshPD5fA+eEygU1NXdU+Hhsfw5vJcn Pl6+kljQwoFtT4qPRutJVoBwVq+vg/cNaC7TSKynnj/7tdxNLLqrveEgV/hZyFtc+RJH5Bn JKEcbO3ApwbmgF1X3TxE8cy7orpy6Yv/jjOTlHNN4t/fosc+dxZPshA3suAzKcoRvcOzUH2 1cVeJTEOdLW2JfcQM5QOQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:6g0knUaijnc=:UGoJZJBttUn6OhpTj0gu/N 9oAlcFMIce0iL8Q+wZfvDrzPsM2wtEHupWP5jTaXflXWBqeuvICsy8DFnhX1mjJnl9SwtwYtd +95Jmvd6nJecqYUumJQnliVXJ2XVK825d9r6dNUEPeUwsNsWfnnJSXwUerhwBrATVDq1iCLEM hkN27UtdJZsntSByB7UADnSNv53xOgaDyO7QfsSpJe1yP+eTNvHwzZldxoKzwwO2HLgDQFzmR VBG6UcTQVQOsjpD/EpivIdPhRFDsvxWJ55uBtNhpq5KGP717qGNHkI8wYQf8vhMUrL6YS7UNv o4OU1A6iylvBgqj/bapBUuwNzxp6Vb8eTEDChVkPvLCFTimkfIKd3sqZsc+kFhDoq2IEupu3T MTZ7TYdf3T6qp9ym3htiQyu40H1+RxDrocqPeswPgXZfzFRZn/FbWEuhQpF63eDdNmyietKMb glMzwrR8ujD7GDLWmgYPmbnqxzOo6Skxhgwm7p82/nx+zkUzfeW0wuEEdTTyaT2bvJWjj5KsG EAwcUZkG40wNDX01BDucJHBK/2uXegecH4TeBIftpzEas7kHOFRhjhHmR158Noxr2PeX4ICUd 2TP5R/SZ5MnUnNU8O7w1TGOPGusrOt6WeE15hzaRKGnMvkzc7Ftosv0CIkxw/HrxkGIs8fhcp WEY48IiIo1x+WzfRAJs8W7xYxHqQQAuqv/BuHuy0CUL6uYzFF9afzjfYjrsmAA1RmorEqRzOG oDr20qsFI1bKQvaB65qjXl205frj9XiaLNjwcD/4DoHlHXW7gX6Tj3emggt1RvjgkPNbI9zj+ RxmpE61 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Tue, 7 Mar 2017 18:23:54 +0100 * Multiplications for the size determination of memory allocations indicated that array data structures should be processed. Thus reuse the corresponding function "kcalloc". This issue was detected by using the Coccinelle software. * Delete the local variable "pd_bitmap_size" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index cbac41b15d94..d5a3127b6df8 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c @@ -1505,7 +1505,6 @@ int ocrdma_mbx_dealloc_pd(struct ocrdma_dev *dev, struct ocrdma_pd *pd) static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) { int status = -ENOMEM; - size_t pd_bitmap_size; struct ocrdma_alloc_pd_range *cmd; struct ocrdma_alloc_pd_range_rsp *rsp; @@ -1527,10 +1526,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) dev->pd_mgr->pd_dpp_start = rsp->dpp_page_pdid & OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK; dev->pd_mgr->max_dpp_pd = rsp->pd_count; - pd_bitmap_size = - BITS_TO_LONGS(rsp->pd_count) * sizeof(long); - dev->pd_mgr->pd_dpp_bitmap = kzalloc(pd_bitmap_size, - GFP_KERNEL); + dev->pd_mgr->pd_dpp_bitmap + = kcalloc(BITS_TO_LONGS(rsp->pd_count), + sizeof(long), + GFP_KERNEL); } kfree(cmd); } @@ -1546,9 +1545,10 @@ static int ocrdma_mbx_alloc_pd_range(struct ocrdma_dev *dev) dev->pd_mgr->pd_norm_start = rsp->dpp_page_pdid & OCRDMA_ALLOC_PD_RNG_RSP_START_PDID_MASK; dev->pd_mgr->max_normal_pd = rsp->pd_count; - pd_bitmap_size = BITS_TO_LONGS(rsp->pd_count) * sizeof(long); - dev->pd_mgr->pd_norm_bitmap = kzalloc(pd_bitmap_size, - GFP_KERNEL); + dev->pd_mgr->pd_norm_bitmap + = kcalloc(BITS_TO_LONGS(rsp->pd_count), + sizeof(long), + GFP_KERNEL); } kfree(cmd);