public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PPC] Missing pci_dev_put in arch/ppc/platforms/chrp_pci.c ?
@ 2004-11-17 12:29 Rolf Eike Beer
  2004-11-17 22:04 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Rolf Eike Beer @ 2004-11-17 12:29 UTC (permalink / raw)
  To: Linux Kernel Mailing List

This is how it is:

chrp_pcibios_fixup(void)
{
        struct pci_dev *dev = NULL;
        struct device_node *np;

        /* PCI interrupts are controlled by the OpenPIC */
        for_each_pci_dev(dev) {
                np = pci_device_to_OF_node(dev);
                if ((np != 0) && (np->n_intrs > 0) && (np->intrs[0].line != 0))
                        dev->irq = np->intrs[0].line;
                pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
        }
}

for_each_pci_dev is defined to use pci_get_device in include/linux/pci.h,
which uses pci_dev_get. So every PCI devices use count will be incremented
if chrp_pcibios_fixup is called. Do I miss something or should we add a
pci_dev_put(dev) at the end of the loop?

Eike

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PPC] Missing pci_dev_put in arch/ppc/platforms/chrp_pci.c ?
  2004-11-17 12:29 [PPC] Missing pci_dev_put in arch/ppc/platforms/chrp_pci.c ? Rolf Eike Beer
@ 2004-11-17 22:04 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2004-11-17 22:04 UTC (permalink / raw)
  To: Rolf Eike Beer; +Cc: Linux Kernel Mailing List

On Wed, Nov 17, 2004 at 01:29:51PM +0100, Rolf Eike Beer wrote:
> This is how it is:
> 
> chrp_pcibios_fixup(void)
> {
>         struct pci_dev *dev = NULL;
>         struct device_node *np;
> 
>         /* PCI interrupts are controlled by the OpenPIC */
>         for_each_pci_dev(dev) {
>                 np = pci_device_to_OF_node(dev);
>                 if ((np != 0) && (np->n_intrs > 0) && (np->intrs[0].line != 0))
>                         dev->irq = np->intrs[0].line;
>                 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
>         }
> }
> 
> for_each_pci_dev is defined to use pci_get_device in include/linux/pci.h,
> which uses pci_dev_get. So every PCI devices use count will be incremented
> if chrp_pcibios_fixup is called. Do I miss something or should we add a
> pci_dev_put(dev) at the end of the loop?

You missed something :)

Read the docs for pci_get_device(), it will explain how the above code
is just fine.

BTW, this isn't the first time this very question has come up on lkml,
how come people never think to do a archive search...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-11-17 23:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-17 12:29 [PPC] Missing pci_dev_put in arch/ppc/platforms/chrp_pci.c ? Rolf Eike Beer
2004-11-17 22:04 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox