All of lore.kernel.org
 help / color / mirror / Atom feed
* [Kernel-janitors] [PATCH -mm 5/9] pci_find_device to pci_get_device
@ 2004-09-21  6:52 Scott Feldman
  2004-09-21 12:53 ` [Kernel-janitors] [PATCH -mm 5/9] pci_find_device to Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: Scott Feldman @ 2004-09-21  6:52 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1573 bytes --]

Use pci_get_device instead of pci_find_device as pci device returned
from pci_find_device can disappear at any momemt in time.

Signed-off-by: Scott Feldman <sfeldma@pobox.com>

diff -Naurp linux-2.6.9-rc2-mm1/drivers/net/sis900.c linux-2.6.9-rc2-mm1-dsf/drivers/net/sis900.c
--- linux-2.6.9-rc2-mm1/drivers/net/sis900.c	2004-09-20 22:35:32.000000000 -0700
+++ linux-2.6.9-rc2-mm1-dsf/drivers/net/sis900.c	2004-09-20 22:39:02.339946664 -0700
@@ -262,9 +262,9 @@ static int __devinit sis630e_get_mac_add
 	u8 reg;
 	int i;
 
-	isa_bridge = pci_find_device(PCI_VENDOR_ID_SI, 0x0008, isa_bridge);
+	isa_bridge = pci_get_device(PCI_VENDOR_ID_SI, 0x0008, isa_bridge);
 	if (!isa_bridge) {
-		isa_bridge = pci_find_device(PCI_VENDOR_ID_SI, 0x0018, isa_bridge);
+		isa_bridge = pci_get_device(PCI_VENDOR_ID_SI, 0x0018, isa_bridge);
 		if (!isa_bridge) {
 			printk("%s: Can not find ISA bridge\n", net_dev->name);
 			return 0;
@@ -279,6 +279,7 @@ static int __devinit sis630e_get_mac_add
 	}
 	pci_write_config_byte(isa_bridge, 0x48, reg & ~0x40);
 
+	pci_dev_put(isa_bridge);
 	return 1;
 }
 
@@ -485,9 +486,11 @@ static int __devinit sis900_probe (struc
 	}
 
 	/* save our host bridge revision */
-	dev = pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630, NULL);
-	if (dev)
+	dev = pci_get_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630, NULL);
+	if (dev) {
 		pci_read_config_byte(dev, PCI_CLASS_REVISION, &sis_priv->host_bridge_rev);
+		pci_dev_put(dev);
+	}
 
 	/* print some information about our NIC */
 	printk(KERN_INFO "%s: %s at %#lx, IRQ %d, ", net_dev->name,



[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

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

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

* Re: [Kernel-janitors] [PATCH -mm 5/9] pci_find_device to
  2004-09-21  6:52 [Kernel-janitors] [PATCH -mm 5/9] pci_find_device to pci_get_device Scott Feldman
@ 2004-09-21 12:53 ` Matthew Wilcox
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2004-09-21 12:53 UTC (permalink / raw)
  To: kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 2193 bytes --]

On Mon, Sep 20, 2004 at 11:52:54PM -0700, Scott Feldman wrote:
> diff -Naurp linux-2.6.9-rc2-mm1/drivers/net/sis900.c linux-2.6.9-rc2-mm1-dsf/drivers/net/sis900.c
> --- linux-2.6.9-rc2-mm1/drivers/net/sis900.c	2004-09-20 22:35:32.000000000 -0700
> +++ linux-2.6.9-rc2-mm1-dsf/drivers/net/sis900.c	2004-09-20 22:39:02.339946664 -0700
> @@ -262,9 +262,9 @@ static int __devinit sis630e_get_mac_add
>  	u8 reg;
>  	int i;
>  
> -	isa_bridge = pci_find_device(PCI_VENDOR_ID_SI, 0x0008, isa_bridge);
> +	isa_bridge = pci_get_device(PCI_VENDOR_ID_SI, 0x0008, isa_bridge);
>  	if (!isa_bridge) {
> -		isa_bridge = pci_find_device(PCI_VENDOR_ID_SI, 0x0018, isa_bridge);
> +		isa_bridge = pci_get_device(PCI_VENDOR_ID_SI, 0x0018, isa_bridge);

The original driver isn't coded terribly well.  I'd do it as:

	struct pci_dev *isa_bridge;

	isa_bridge = pci_get_device(PCI_VENDOR_ID_SI, 0x0008, NULL);
	if (!isa_bridge)
		isa_bridge = pci_get_device(PCI_VENDOR_ID_SI, 0x0018, NULL);
	if (!isa_bridge) {
		printk("%s: Can not find ISA bridge\n", net_dev->name);
		return 0;
	}

>  		if (!isa_bridge) {
>  			printk("%s: Can not find ISA bridge\n", net_dev->name);
>  			return 0;
> @@ -279,6 +279,7 @@ static int __devinit sis630e_get_mac_add
>  	}
>  	pci_write_config_byte(isa_bridge, 0x48, reg & ~0x40);
>  
> +	pci_dev_put(isa_bridge);
>  	return 1;
>  }
>  
> @@ -485,9 +486,11 @@ static int __devinit sis900_probe (struc
>  	}
>  
>  	/* save our host bridge revision */
> -	dev = pci_find_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630, NULL);
> -	if (dev)
> +	dev = pci_get_device(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_630, NULL);
> +	if (dev) {
>  		pci_read_config_byte(dev, PCI_CLASS_REVISION, &sis_priv->host_bridge_rev);
> +		pci_dev_put(dev);
> +	}

This one's fine.

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

[-- Attachment #2: Type: text/plain, Size: 167 bytes --]

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

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

end of thread, other threads:[~2004-09-21 12:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-21  6:52 [Kernel-janitors] [PATCH -mm 5/9] pci_find_device to pci_get_device Scott Feldman
2004-09-21 12:53 ` [Kernel-janitors] [PATCH -mm 5/9] pci_find_device to Matthew Wilcox

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.