All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Hollomon <markhollomon@comcast.net>
To: kernel-janitors@vger.kernel.org
Subject: Re: [KJ] question about pci_dev_put
Date: Thu, 18 May 2006 01:43:26 +0000	[thread overview]
Message-ID: <446BD13E.4050704@comcast.net> (raw)
In-Reply-To: <446BAEC6.9080907@yahoo.fr>

Nishanth Aravamudan wrote:
> On 18.05.2006 [01:16:22 +0200], trem wrote:
>> Hi
>>
>> I'm looking for information about pci_get_device and pci_dev_put. If my
>> research are good,
>> I've understood that pci_get_device increment the counter of the device
>> returned, and it also
>> decremented the counter of the device given as "from".
>>
>> I've searched example in the source. I've found this one in
>> arch/ppc/platforms/85xx/mpc85xx_cds_common.c(git kernel) :
>>
>>     if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
>>                                         PCI_DEVICE_ID_VIA_82C586_2,
>> NULL))) {
>>                 dev->irq = 10;
>>                 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 10);
>>         pci_dev_put(dev);
>>         }
>>
>>     if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
>>                                         PCI_DEVICE_ID_VIA_82C586_2, dev))) {
>>                 dev->irq = 11;
>>                 pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 11);
>>         pci_dev_put(dev);
>>         }
>>
>> So, if I don't mistake, this code is buggy, the counter is decremented
>> twice in the second if.
>> One in the pci_get_device and one in pci_dev_put. I'm on the right way ?
> 
> /me knows nothing about the PCI space, but looking at the comments for
> pci_get_device() and tracing what pci_dev_put() does, it seems like you
> are right.
> 
> It seems like the correct method is to remove the pci_dev_put(dev); from
> the first if above and change the second one to
> 
> 	if ((dev = pci_get_device(PCI_VENDOR_ID_VIA,
> 					PCI_DEVICE_ID_VIA_82C586_2, dev))) {
> 		dev->irq = 11;
> 		pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 11);
> 		pci_dev_put(dev);
> 	} else
> 		pci_dev_put(dev);

That can't be right. you will only reach the else leg if pci_get_device() returns
NULL. which means that you will be calling pci_dev_put(NULL).

-- 
Mark Hollomon
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

  parent reply	other threads:[~2006-05-18  1:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-17 23:16 [KJ] question about pci_dev_put trem
2006-05-18  1:20 ` Nishanth Aravamudan
2006-05-18  1:43 ` Mark Hollomon [this message]
2006-05-18  2:00 ` Nishanth Aravamudan
2006-05-18  2:47 ` Matthew Wilcox
2006-05-18  3:39 ` Nishanth Aravamudan
2006-05-18 11:59 ` Matthew Wilcox
2006-05-18 12:57 ` Mark Hollomon
2006-05-18 17:36 ` Greg KH
2006-05-18 17:37 ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=446BD13E.4050704@comcast.net \
    --to=markhollomon@comcast.net \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.