From patchwork Sat Dec 30 15:47:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 10137815 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 A642360375 for ; Sat, 30 Dec 2017 15:48:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 995DA287B3 for ; Sat, 30 Dec 2017 15:48:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DECE287B5; Sat, 30 Dec 2017 15:48:34 +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=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS 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 3F04B287B3 for ; Sat, 30 Dec 2017 15:48:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751002AbdL3PsU (ORCPT ); Sat, 30 Dec 2017 10:48:20 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:39131 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750931AbdL3PsT (ORCPT ); Sat, 30 Dec 2017 10:48:19 -0500 Received: by mail-pl0-f68.google.com with SMTP id bi12so24606390plb.6; Sat, 30 Dec 2017 07:48:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=YztIcW6ZPJ2wHznK/gc5Eh8fxu4D7UOHUqOkpoLzPsM=; b=MX3Gtj/T5MP/jlcmGBDpEFPLcwDY/NlgsBSgHeTOpD8727qNI8NsepIfPfcUe6WKW0 7MGumeQXX8FS5K3e9qJM0ii8DqMcstDvPENUYBwTWPAhvUFcFezpTkYr623wUl0HiG1o ToeyeT3+qzqqjT68H+nPQt+aZ9X9+ocibIgWYduoIh6qZ/gAalL/1oEh7gI/F6pnenur VzlTAFpW9ymaLZQn9qHCDIGPl9V4WB0TCBNVv+IEv9G59BU4afYrUpue9vQO3HoW9iqw XVy6hbMylEZxgwZLUk/IjldnizTKBVUDFkvt9VWvwJJtpuGld1hNbA9s9lmw2IjobpiQ ULZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YztIcW6ZPJ2wHznK/gc5Eh8fxu4D7UOHUqOkpoLzPsM=; b=diQ7KBGwpfyzk5KkvxuIWg677NSvlrQCNoefvJw7cwgs9MvLj9WWnuqGTT4OVA2OV5 rliKJGydDpE8SLroq3xarotqEdjj94hkUgkPDkHGUye886/+ZXUnjmqxWUfX31pcOxCw tU4IGTiH/38t0eyRWOzFNcZRncHsG3uRHv/FHC1nAaOiDCpN0L/Ekla2O4eRgS2LISiq b5su2xUdGDHHVQJfhjaVd2jtD/i+cW0N+ppQbIm2DkF+PaJ5gjURXRH6q1IqKOlUCiIM 0iIsJYkH072s9vHx0PKt+Khpqzh3JTzZZVzN47hCX0vTcgU9xwFfkFicEtjqdCS/v5zz dDKA== X-Gm-Message-State: AKGB3mJ+Q3STopsBngROZPK8+fm5DOwoyYsZY3xVDmEAxJvJ5jlhFAUP DOtTCOcls93fYf0njO/q8/g= X-Google-Smtp-Source: ACJfBouJdlNr4zYzvhZxyl79aTFHZSjkzSAL1xTMZuUUJJlP/6BBWU77vMXIIuV4DDh9UJVGwGwDFw== X-Received: by 10.84.241.67 with SMTP id u3mr39299341plm.275.1514648899029; Sat, 30 Dec 2017 07:48:19 -0800 (PST) Received: from localhost.localdomain ([103.46.193.14]) by smtp.gmail.com with ESMTPSA id 82sm85793802pfm.136.2017.12.30.07.48.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Dec 2017 07:48:18 -0800 (PST) From: Himanshu Jha To: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com Cc: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, shivasharan.srikanteshwara@broadcom.com, megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, mcgrof@kernel.org, Himanshu Jha Subject: [PATCH] scsi: megaraid: Use zeroing memory allocator than allocator/memset Date: Sat, 30 Dec 2017 21:17:57 +0530 Message-Id: <1514648877-7234-1-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use pci_zalloc_consistent for allocating zeroed memory and remove unnecessary memset function. Done using Coccinelle. Generated-by: scripts/coccinelle/api/alloc/kzalloc-simple.cocci 0-day tested with no failures. Suggested-by: Luis R. Rodriguez Signed-off-by: Himanshu Jha --- drivers/scsi/megaraid/megaraid_sas_base.c | 19 ++++++------------- drivers/scsi/megaraid/megaraid_sas_fusion.c | 5 ++--- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 2c8cfa2..62959d0 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -2222,10 +2222,9 @@ static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance, memset(instance->vf_affiliation_111, 0, sizeof(struct MR_LD_VF_AFFILIATION_111)); else { - new_affiliation_111 = - pci_alloc_consistent(instance->pdev, - sizeof(struct MR_LD_VF_AFFILIATION_111), - &new_affiliation_111_h); + new_affiliation_111 = + pci_zalloc_consistent(instance->pdev, + sizeof(struct MR_LD_VF_AFFILIATION_111), + &new_affiliation_111_h); if (!new_affiliation_111) { dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate " "memory for new affiliation for scsi%d\n", @@ -2233,8 +2232,6 @@ static int megasas_get_ld_vf_affiliation_111(struct megasas_instance *instance, megasas_return_cmd(instance, cmd); return -ENOMEM; } - memset(new_affiliation_111, 0, - sizeof(struct MR_LD_VF_AFFILIATION_111)); } memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); @@ -2331,11 +2328,9 @@ static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance, memset(instance->vf_affiliation, 0, (MAX_LOGICAL_DRIVES + 1) * sizeof(struct MR_LD_VF_AFFILIATION)); else { - new_affiliation = - pci_alloc_consistent(instance->pdev, - (MAX_LOGICAL_DRIVES + 1) * - sizeof(struct MR_LD_VF_AFFILIATION), - &new_affiliation_h); + new_affiliation = + pci_zalloc_consistent(instance->pdev, + (MAX_LOGICAL_DRIVES + 1) * + sizeof(struct MR_LD_VF_AFFILIATION), + &new_affiliation_h); if (!new_affiliation) { dev_printk(KERN_DEBUG, &instance->pdev->dev, "SR-IOV: Couldn't allocate " "memory for new affiliation for scsi%d\n", @@ -2343,8 +2338,6 @@ static int megasas_get_ld_vf_affiliation_12(struct megasas_instance *instance, megasas_return_cmd(instance, cmd); return -ENOMEM; } - memset(new_affiliation, 0, (MAX_LOGICAL_DRIVES + 1) * - sizeof(struct MR_LD_VF_AFFILIATION)); } memset(dcmd->mbox.b, 0, MFI_MBOX_SIZE); diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 65dc4fe..5f61b93 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c @@ -690,15 +690,14 @@ megasas_alloc_rdpq_fusion(struct megasas_instance *instance) array_size = sizeof(struct MPI2_IOC_INIT_RDPQ_ARRAY_ENTRY) * MAX_MSIX_QUEUES_FUSION; - fusion->rdpq_virt = pci_alloc_consistent(instance->pdev, array_size, - &fusion->rdpq_phys); + fusion->rdpq_virt = pci_zalloc_consistent(instance->pdev, array_size, + &fusion->rdpq_phys); if (!fusion->rdpq_virt) { dev_err(&instance->pdev->dev, "Failed from %s %d\n", __func__, __LINE__); return -ENOMEM; } - memset(fusion->rdpq_virt, 0, array_size); msix_count = instance->msix_vectors > 0 ? instance->msix_vectors : 1; fusion->reply_frames_desc_pool = dma_pool_create("mr_rdpq",