netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@gmail.com>
To: Michael Buesch <mb@bu3sch.de>
Cc: Greg KH <gregkh@suse.de>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-pci@atrey.karlin.mff.cuni.cz, jgarzik@pobox.com,
	netdev@vger.kernel.org, st3@riseup.net, linville@tuxdriver.com
Subject: Re: [PATCH 2/3] pci: bcm43xx avoid pci_find_device
Date: Mon, 05 Jun 2006 22:45:08 +0159	[thread overview]
Message-ID: <448497EB.4010109@gmail.com> (raw)
In-Reply-To: <200606052235.28687.mb@bu3sch.de>

Michael Buesch napsal(a):
> On Monday 05 June 2006 22:18, Jiri Slaby wrote:
>> bcm43xx avoid pci_find_device
>>
>> Change pci_find_device to safer pci_get_device with support for more
>> devices.
> 
> I am wondering about the reference count.
> From docbook:
> 
> 256  * pci_get_device - begin or continue searching for a PCI device by vendor/device id
> 257  * @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids
> 258  * @device: PCI device id to match, or %PCI_ANY_ID to match all device ids
> 259  * @from: Previous PCI device found in search, or %NULL for new search.
> 260  *
> 261  * Iterates through the list of known PCI devices.  If a PCI device is
> 262  * found with a matching @vendor and @device, the reference count to the
>                                                       ^^^^^^^^^^^^^^^^^^^^^^
> 263  * device is incremented and a pointer to its device structure is returned.
>        ^^^^^^^^^^^^^^^^^^^^^
> 264  * Otherwise, %NULL is returned.  A new search is initiated by passing %NULL
> 265  * to the @from argument.  Otherwise if @from is not %NULL, searches continue
> 266  * from next device on the global list.  The reference count for @from is
> 267  * always decremented if it is not %NULL.
> 
> Who is going to decrement it, once the device is not used anymore.
> "not used anymore" is ifconfig down in the case of bcm43xx.
> You will call pci_get_device on each ifconfig up.
> 
>> Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
>>
>> ---
>> commit 4b73c16f5411d97360d5f26f292ffddeb670ff75
>> tree 6e43c8bd02498eb1ceec6bdc64277fa8408da9e2
>> parent d59f9ea8489749f59cd0c7333a4784cab964daa8
>> author Jiri Slaby <ku@bellona.localdomain> Mon, 05 Jun 2006 22:01:03 +0159
>> committer Jiri Slaby <ku@bellona.localdomain> Mon, 05 Jun 2006 22:01:03 +0159
>>
>>  drivers/net/wireless/bcm43xx/bcm43xx_main.c |   21 ++++++++++++++++-----
>>  1 files changed, 16 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
>> index 22b8fa6..d1a9975 100644
>> --- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c
>> +++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c
>> @@ -2133,6 +2133,13 @@ out:
>>  	return err;
>>  }
>>  
>> +#ifdef CONFIG_BCM947XX
>> +static struct pci_device_id bcm43xx_47xx_ids[] = {
>> +	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4324) },
>> +	{ 0 }
>> +};
>> +#endif
>> +
>>  static int bcm43xx_initialize_irq(struct bcm43xx_private *bcm)
>>  {
>>  	int res;
>> @@ -2142,11 +2149,15 @@ static int bcm43xx_initialize_irq(struct
>>  	bcm->irq = bcm->pci_dev->irq;
>>  #ifdef CONFIG_BCM947XX
>>  	if (bcm->pci_dev->bus->number == 0) {
>> -		struct pci_dev *d = NULL;
>> -		/* FIXME: we will probably need more device IDs here... */
>> -		d = pci_find_device(PCI_VENDOR_ID_BROADCOM, 0x4324, NULL);
>> -		if (d != NULL) {
>> -			bcm->irq = d->irq;
>> +		struct pci_dev *d;
>> +		struct pci_device_id *id;
>> +		for (id = bcm43xx_47xx_ids; id->vendor; id++) {
>> +			d = pci_get_device(id->vendor, id->device, NULL);
>> +			if (d != NULL) {
>> +				bcm->irq = d->irq;
>> +				pci_dev_put(d);
here?
>> +				break;
>> +			}
>>  		}
>>  	}
>>  #endif
>>
> 

regards,
-- 
Jiri Slaby         www.fi.muni.cz/~xslaby
\_.-^-._   jirislaby@gmail.com   _.-^-._/
B67499670407CE62ACC8 22A032CC55C339D47A7E

  reply	other threads:[~2006-06-05 20:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20060605201818.1239938CE036@bu3sch.de>
2006-06-05 20:35 ` [PATCH 2/3] pci: bcm43xx avoid pci_find_device Michael Buesch
2006-06-05 20:46   ` Jiri Slaby [this message]
2006-06-05 20:16 [PATCH 0/3 #3] " Jiri Slaby
     [not found] ` <20060605202007.B464FC7B73@atrey.karlin.mff.cuni.cz>
2006-06-05 20:53   ` [PATCH 2/3] pci: bcm43xx " Greg KH
2006-06-05 21:09     ` Jiri Slaby
2006-06-06  1:18     ` Jeff Garzik
2006-06-06  6:50       ` Greg KH
2006-06-06 12:58     ` Michael Buesch
     [not found] <20060526001053.D2349C7C58@atrey.karlin.mff.cuni.cz>
2006-05-26  0:35 ` Jeff Garzik
2006-05-26 10:20   ` Jiri Slaby
2006-05-26 10:22     ` Jeff Garzik
2006-05-26 10:33       ` Jiri Slaby
2006-05-26 10:37         ` Jeff Garzik
2006-05-26 10:54           ` Jiri Slaby
2006-05-26 11:09             ` Jeff Garzik
2006-05-26 11:30               ` Jiri Slaby
2006-06-05 18:56                 ` John W. Linville
2006-06-05 19:10                   ` Jiri Slaby
2006-05-26 11:49         ` Michael Buesch
2006-05-26 11:52           ` Jiri Slaby

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=448497EB.4010109@gmail.com \
    --to=jirislaby@gmail.com \
    --cc=gregkh@suse.de \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@atrey.karlin.mff.cuni.cz \
    --cc=linville@tuxdriver.com \
    --cc=mb@bu3sch.de \
    --cc=netdev@vger.kernel.org \
    --cc=st3@riseup.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).