[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070401170043.27a581cb@the-village.bc.nu>
Date: Sun, 1 Apr 2007 17:00:43 +0100
From: Alan Cox <alan@...rguk.ukuu.org.uk>
To: "Pedram M" <pmessri@...il.com>
Cc: kernel-janitors@...ts.osdl.org, linux-kernel@...r.kernel.org
Subject: Re: my first janitorial
On Sat, 31 Mar 2007 22:24:12 -0700
"Pedram M" <pmessri@...il.com> wrote:
> How about this one? Am I doing it right now?
> If not, please try to explain more to me what I am
> doing wrong.
You need to hold a reference to the PCI device for the entire duration it
is used. I think you actually also need something like this to get the whole
thing using pci references and pci_get_* properly
Alan
--- drivers/char/cyclades.c~ 2007-04-01 15:52:16.000000000 +0100
+++ drivers/char/cyclades.c 2007-04-01 15:52:16.000000000 +0100
@@ -4803,7 +4782,7 @@
cy_card[j].bus_index = 1;
cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = cy_pci_nchan/4;
- cy_card[j].pdev = pdev;
+ cy_card[j].pdev = pci_dev_get(pdev);
/* enable interrupts in the PCI interface */
plx_ver = cy_readb(cy_pci_addr2 + CyPLX_VER) & 0x0f;
@@ -4901,7 +4880,7 @@
Ze_addr0[ZeIndex] = cy_pci_addr0;
Ze_addr2[ZeIndex] = cy_pci_addr2;
Ze_irq[ZeIndex] = cy_pci_irq;
- Ze_pdev[ZeIndex] = pdev;
+ Ze_pdev[ZeIndex] = pci_dev_get(pdev);
ZeIndex++;
}
i--;
@@ -4986,7 +4965,7 @@
cy_card[j].bus_index = 1;
cy_card[j].first_line = cy_next_channel;
cy_card[j].num_chips = -1;
- cy_card[j].pdev = pdev;
+ cy_card[j].pdev = pci_dev_get(pdev);
/* print message */
#ifdef CONFIG_CYZ_INTR
@@ -5007,6 +4986,10 @@
cy_next_channel += cy_pci_nchan;
}
}
+
+ if (pdev)
+ pci_dev_put(pdev);
+
for (; ZeIndex != 0 && i < NR_CARDS; i++) {
cy_pci_phys0 = Ze_phys0[0];
@@ -5485,11 +5468,12 @@
)
free_irq(cy_card[i].irq, &cy_card[i]);
#ifdef CONFIG_PCI
- if (cy_card[i].pdev)
+ if (cy_card[i].pdev) {
pci_release_regions(cy_card[i].pdev);
+ pci_dev_put(pdev);
+ }
#endif
}
}
} /* cy_cleanup_module */
module_init(cy_init);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists