diff mbox

[v2,01/12] IB/ocrdma: Use kcalloc() in ocrdma_mbx_alloc_pd_range()

Message ID 21442d70-e77b-8338-30f7-9c41d048a665@users.sourceforge.net (mailing list archive)
State Deferred
Headers show

Commit Message

SF Markus Elfring April 22, 2017, 2:30 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 22 Apr 2017 11:33:25 +0200

* 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 <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Devesh Sharma April 24, 2017, 4:27 p.m. UTC | #1
Acked-By: Devesh Sharma <devesh.sharma@broadcom.com>

On Sat, Apr 22, 2017 at 8:00 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 22 Apr 2017 11:33:25 +0200
>
> * 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 <elfring@users.sourceforge.net>
> ---
>  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 aa6967197620..c868314222b9 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);
>
> --
> 2.12.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Doug Ledford April 25, 2017, 5:02 p.m. UTC | #2
On Mon, 2017-04-24 at 21:57 +0530, Devesh Sharma wrote:
> Acked-By: Devesh Sharma <devesh.sharma@broadcom.com>

Devesh, after you have reviewed any of Markus' patches that you care to
review, if you wish any of them to go into my tree, please submit them
to me yourself.  Thanks.
SF Markus Elfring Aug. 8, 2017, 5:26 p.m. UTC | #3
Hello,

How will the clarification be continued for the shown change possibilities?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Leon Romanovsky Aug. 9, 2017, 6:43 a.m. UTC | #4
On Tue, Aug 08, 2017 at 07:26:45PM +0200, SF Markus Elfring wrote:
> Hello,
>
> How will the clarification be continued for the shown change possibilities?

Every sub-maintainer will decide on his own what and how to proceed with
these patches.

Thanks

>
> Regards,
> Markus
diff mbox

Patch

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index aa6967197620..c868314222b9 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);