* Re: [PATCH 3/3] pci: gt96100eth avoid pci_find_device
[not found] <20060526001155.4828DC7C5E@atrey.karlin.mff.cuni.cz>
@ 2006-05-26 0:37 ` Jeff Garzik
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2006-05-26 0:37 UTC (permalink / raw)
To: Jiri Slaby
Cc: Greg KH, Linux Kernel Mailing List, linux-pci, netdev, stevel,
source
Jiri Slaby wrote:
> gt96100eth avoid pci_find_device
>
> Change pci_find_device to safer pci_get_device.
>
> Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
>
> ---
> commit f656671e9da9d33bd7a2fb3f5c0d0f7009925698
> tree b92c808b6a9eecce58b0f7b0ffe1237631dbd65a
> parent 1d3b6caf027fe53351c645523587aeac40bc3e47
> author Jiri Slaby <ku@bellona.localdomain> Fri, 26 May 2006 01:55:23 +0159
> committer Jiri Slaby <ku@bellona.localdomain> Fri, 26 May 2006 01:55:23 +0159
>
> drivers/net/gt96100eth.c | 10 +++++++---
> 1 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/gt96100eth.c b/drivers/net/gt96100eth.c
> index 2d24354..beac56d 100644
> --- a/drivers/net/gt96100eth.c
> +++ b/drivers/net/gt96100eth.c
> @@ -613,9 +613,9 @@ static int gt96100_init_module(void)
> /*
> * Stupid probe because this really isn't a PCI device
> */
> - if (!(pci = pci_find_device(PCI_VENDOR_ID_MARVELL,
> + if (!(pci = pci_get_device(PCI_VENDOR_ID_MARVELL,
> PCI_DEVICE_ID_MARVELL_GT96100, NULL)) &&
> - !(pci = pci_find_device(PCI_VENDOR_ID_MARVELL,
> + !(pci = pci_get_device(PCI_VENDOR_ID_MARVELL,
> PCI_DEVICE_ID_MARVELL_GT96100A, NULL))) {
> printk(KERN_ERR __FILE__ ": GT96100 not found!\n");
> return -ENODEV;
Seems OK to me, though you may wish to use a pci_device_id list with
pci_match_[one_]device() here too.
Jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 3/3] pci: gt96100eth avoid pci_find_device
[not found] <448491ab.7fb59b32.690f.01c1SMTPIN_ADDED@mx.gmail.com>
@ 2006-06-05 20:57 ` Jiri Slaby
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Slaby @ 2006-06-05 20:57 UTC (permalink / raw)
To: Jiri Slaby
Cc: Greg KH, Linux Kernel Mailing List, linux-pci, jgarzik, netdev,
stevel, source
Jiri Slaby napsal(a):
> gt96100eth avoid pci_find_device
>
> Change pci_find_device to safer pci_get_device with support for more
> bridges.
>
> Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
>
> ---
> commit fd863b81ac491faf783ff7f2dcf6032177c5ab7f
> tree d7eb59f897505230023754f19ad7227eec39e676
> parent 4b73c16f5411d97360d5f26f292ffddeb670ff75
> author Jiri Slaby <ku@bellona.localdomain> Mon, 05 Jun 2006 22:01:20 +0159
> committer Jiri Slaby <ku@bellona.localdomain> Mon, 05 Jun 2006 22:01:20 +0159
>
> drivers/net/gt96100eth.c | 23 ++++++++++++++++++-----
> 1 files changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/gt96100eth.c b/drivers/net/gt96100eth.c
> index 2d24354..3066c86 100644
> --- a/drivers/net/gt96100eth.c
> +++ b/drivers/net/gt96100eth.c
> @@ -600,6 +600,11 @@ disable_ether_irq(struct net_device *dev
> GT96100ETH_WRITE(gp, GT96100_ETH_INT_MASK, 0);
> }
>
> +static struct pci_device_id gt96100_ids[] = {
> + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT96100) },
> + { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, PCI_DEVICE_ID_MARVELL_GT96100A) },
> + { 0 }
> +};
>
> /*
> * Init GT96100 ethernet controller driver
> @@ -607,16 +612,20 @@ disable_ether_irq(struct net_device *dev
> static int gt96100_init_module(void)
> {
> struct pci_dev *pci;
> + struct pci_device_id *id;
> int i, retval=0;
> u32 cpuConfig;
>
> /*
> * Stupid probe because this really isn't a PCI device
> */
> - if (!(pci = pci_find_device(PCI_VENDOR_ID_MARVELL,
> - PCI_DEVICE_ID_MARVELL_GT96100, NULL)) &&
> - !(pci = pci_find_device(PCI_VENDOR_ID_MARVELL,
> - PCI_DEVICE_ID_MARVELL_GT96100A, NULL))) {
> + for (id = gt96100_ids; id->vendor; id++) {
> + pci = pci_get_device(id->vendor, id->device, NULL);
> + if (pci != NULL)
> + break;
> + }
I wonder if this is even better:
while ((pci = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, pci)) != NULL)
if (pci_match_id(gt96100_ids, pci) != NULL)
break;
What do you think?
> +
> + if (!id->vendor) {
> printk(KERN_ERR __FILE__ ": GT96100 not found!\n");
> return -ENODEV;
> }
> @@ -625,12 +634,16 @@ static int gt96100_init_module(void)
> if (cpuConfig & (1<<12)) {
> printk(KERN_ERR __FILE__
> ": must be in Big Endian mode!\n");
> - return -ENODEV;
> + retval = -ENODEV;
> + goto err_pput;
> }
>
> for (i=0; i < NUM_INTERFACES; i++)
> retval |= gt96100_probe1(pci, i);
>
> +err_pput:
> + pci_dev_put(pci);
> +
> return retval;
> }
>
>
--
Jiri Slaby www.fi.muni.cz/~xslaby
\_.-^-._ jirislaby@gmail.com _.-^-._/
B67499670407CE62ACC8 22A032CC55C339D47A7E
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-06-05 20:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20060526001155.4828DC7C5E@atrey.karlin.mff.cuni.cz>
2006-05-26 0:37 ` [PATCH 3/3] pci: gt96100eth avoid pci_find_device Jeff Garzik
[not found] <448491ab.7fb59b32.690f.01c1SMTPIN_ADDED@mx.gmail.com>
2006-06-05 20:57 ` Jiri Slaby
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).