Skip to content

Commit a99f501

Browse files
committed
Merge branch 'remotes/lorenzo/pci/xilinx-nwl'
- Declare bitmap correctly and as part of struct nwl_msi managed resource (Christophe JAILLET) * remotes/lorenzo/pci/xilinx-nwl: PCI: xilinx-nwl: Simplify code and fix a memory leak
2 parents 18b026d + 61f0aa4 commit a99f501

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

drivers/pci/controller/pcie-xilinx-nwl.c

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146

147147
struct nwl_msi { /* MSI information */
148148
struct irq_domain *msi_domain;
149-
unsigned long *bitmap;
149+
DECLARE_BITMAP(bitmap, INT_PCI_MSI_NR);
150150
struct irq_domain *dev_domain;
151151
struct mutex lock; /* protect bitmap variable */
152152
int irq_msi0;
@@ -335,12 +335,10 @@ static void nwl_pcie_leg_handler(struct irq_desc *desc)
335335

336336
static void nwl_pcie_handle_msi_irq(struct nwl_pcie *pcie, u32 status_reg)
337337
{
338-
struct nwl_msi *msi;
338+
struct nwl_msi *msi = &pcie->msi;
339339
unsigned long status;
340340
u32 bit;
341341

342-
msi = &pcie->msi;
343-
344342
while ((status = nwl_bridge_readl(pcie, status_reg)) != 0) {
345343
for_each_set_bit(bit, &status, 32) {
346344
nwl_bridge_writel(pcie, 1 << bit, status_reg);
@@ -560,30 +558,21 @@ static int nwl_pcie_enable_msi(struct nwl_pcie *pcie)
560558
struct nwl_msi *msi = &pcie->msi;
561559
unsigned long base;
562560
int ret;
563-
int size = BITS_TO_LONGS(INT_PCI_MSI_NR) * sizeof(long);
564561

565562
mutex_init(&msi->lock);
566563

567-
msi->bitmap = kzalloc(size, GFP_KERNEL);
568-
if (!msi->bitmap)
569-
return -ENOMEM;
570-
571564
/* Get msi_1 IRQ number */
572565
msi->irq_msi1 = platform_get_irq_byname(pdev, "msi1");
573-
if (msi->irq_msi1 < 0) {
574-
ret = -EINVAL;
575-
goto err;
576-
}
566+
if (msi->irq_msi1 < 0)
567+
return -EINVAL;
577568

578569
irq_set_chained_handler_and_data(msi->irq_msi1,
579570
nwl_pcie_msi_handler_high, pcie);
580571

581572
/* Get msi_0 IRQ number */
582573
msi->irq_msi0 = platform_get_irq_byname(pdev, "msi0");
583-
if (msi->irq_msi0 < 0) {
584-
ret = -EINVAL;
585-
goto err;
586-
}
574+
if (msi->irq_msi0 < 0)
575+
return -EINVAL;
587576

588577
irq_set_chained_handler_and_data(msi->irq_msi0,
589578
nwl_pcie_msi_handler_low, pcie);
@@ -592,8 +581,7 @@ static int nwl_pcie_enable_msi(struct nwl_pcie *pcie)
592581
ret = nwl_bridge_readl(pcie, I_MSII_CAPABILITIES) & MSII_PRESENT;
593582
if (!ret) {
594583
dev_err(dev, "MSI not present\n");
595-
ret = -EIO;
596-
goto err;
584+
return -EIO;
597585
}
598586

599587
/* Enable MSII */
@@ -632,10 +620,6 @@ static int nwl_pcie_enable_msi(struct nwl_pcie *pcie)
632620
nwl_bridge_writel(pcie, MSGF_MSI_SR_LO_MASK, MSGF_MSI_MASK_LO);
633621

634622
return 0;
635-
err:
636-
kfree(msi->bitmap);
637-
msi->bitmap = NULL;
638-
return ret;
639623
}
640624

641625
static int nwl_pcie_bridge_init(struct nwl_pcie *pcie)

0 commit comments

Comments
 (0)