2022-07-04 13:25:30

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH] PCI: iproc: Use the bitmap API to allocate bitmaps

Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.

It is less verbose and it improves the semantic.

Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/pci/controller/pcie-iproc-msi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/pcie-iproc-msi.c b/drivers/pci/controller/pcie-iproc-msi.c
index 757b7fbcdc59..fee036b07cd4 100644
--- a/drivers/pci/controller/pcie-iproc-msi.c
+++ b/drivers/pci/controller/pcie-iproc-msi.c
@@ -589,8 +589,8 @@ int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node)
msi->has_inten_reg = true;

msi->nr_msi_vecs = msi->nr_irqs * EQ_LEN;
- msi->bitmap = devm_kcalloc(pcie->dev, BITS_TO_LONGS(msi->nr_msi_vecs),
- sizeof(*msi->bitmap), GFP_KERNEL);
+ msi->bitmap = devm_bitmap_zalloc(pcie->dev, msi->nr_msi_vecs,
+ GFP_KERNEL);
if (!msi->bitmap)
return -ENOMEM;

--
2.34.1


2022-07-04 17:29:08

by Ray Jui

[permalink] [raw]
Subject: Re: [PATCH] PCI: iproc: Use the bitmap API to allocate bitmaps



On 7/4/2022 6:15 AM, Christophe JAILLET wrote:
> Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.
>
> It is less verbose and it improves the semantic.
>
> Signed-off-by: Christophe JAILLET <[email protected]>
> ---
> drivers/pci/controller/pcie-iproc-msi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-iproc-msi.c b/drivers/pci/controller/pcie-iproc-msi.c
> index 757b7fbcdc59..fee036b07cd4 100644
> --- a/drivers/pci/controller/pcie-iproc-msi.c
> +++ b/drivers/pci/controller/pcie-iproc-msi.c
> @@ -589,8 +589,8 @@ int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node)
> msi->has_inten_reg = true;
>
> msi->nr_msi_vecs = msi->nr_irqs * EQ_LEN;
> - msi->bitmap = devm_kcalloc(pcie->dev, BITS_TO_LONGS(msi->nr_msi_vecs),
> - sizeof(*msi->bitmap), GFP_KERNEL);
> + msi->bitmap = devm_bitmap_zalloc(pcie->dev, msi->nr_msi_vecs,
> + GFP_KERNEL);
> if (!msi->bitmap)
> return -ENOMEM;
>

Improvement looks fine to me. Thanks.

Acked-by: Ray Jui <[email protected]>


Attachments:
smime.p7s (4.10 kB)
S/MIME Cryptographic Signature

2022-07-05 20:49:05

by Bjorn Helgaas

[permalink] [raw]
Subject: Re: [PATCH] PCI: iproc: Use the bitmap API to allocate bitmaps

On Mon, Jul 04, 2022 at 03:15:03PM +0200, Christophe JAILLET wrote:
> Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.
>
> It is less verbose and it improves the semantic.
>
> Signed-off-by: Christophe JAILLET <[email protected]>

Applied with Ray's ack to pci/ctrl/iproc for v5.20, thanks!

> ---
> drivers/pci/controller/pcie-iproc-msi.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-iproc-msi.c b/drivers/pci/controller/pcie-iproc-msi.c
> index 757b7fbcdc59..fee036b07cd4 100644
> --- a/drivers/pci/controller/pcie-iproc-msi.c
> +++ b/drivers/pci/controller/pcie-iproc-msi.c
> @@ -589,8 +589,8 @@ int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node)
> msi->has_inten_reg = true;
>
> msi->nr_msi_vecs = msi->nr_irqs * EQ_LEN;
> - msi->bitmap = devm_kcalloc(pcie->dev, BITS_TO_LONGS(msi->nr_msi_vecs),
> - sizeof(*msi->bitmap), GFP_KERNEL);
> + msi->bitmap = devm_bitmap_zalloc(pcie->dev, msi->nr_msi_vecs,
> + GFP_KERNEL);
> if (!msi->bitmap)
> return -ENOMEM;
>
> --
> 2.34.1
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel