public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [-mm PATCH] remove use of pci_find_device in watchdog driver for Intel 6300ESB chipset
@ 2005-08-15 21:30 Naveen Gupta
  2005-08-15 23:14 ` David Härdeman
  0 siblings, 1 reply; 3+ messages in thread
From: Naveen Gupta @ 2005-08-15 21:30 UTC (permalink / raw)
  To: wim, david, akpm; +Cc: linux-kernel


This patch replaces obsolete 'pci_find_device' with 'pci_get_device' to
prevent the device from being stolen under us in Watchdog timer driver
for intel 6300ESB chipset.

Signed-off-by: Naveen Gupta <ngupta@google.com>

Index: linux-2.6.12/drivers/char/watchdog/i6300esb.c
===================================================================
--- linux-2.6.12.orig/drivers/char/watchdog/i6300esb.c	2005-08-15 11:28:07.000000000 -0700
+++ linux-2.6.12/drivers/char/watchdog/i6300esb.c	2005-08-15 11:36:54.000000000 -0700
@@ -362,23 +362,24 @@
 {
 	u8 val1;
 	unsigned short val2;
-
+	struct pci_device_id *ids = esb_pci_tbl;
         struct pci_dev *dev = NULL;
         /*
          *      Find the PCI device
          */
 
-        while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
-                if (pci_match_id(esb_pci_tbl, dev)) {
-                        esb_pci = dev;
-                        break;
-                }
-        }
+	while (ids->vendor && ids->device) {
+		if ((dev = pci_get_device(ids->vendor, ids->device, dev)) != NULL) {
+			esb_pci = dev;
+			break;
+		}
+		ids++;
+	}
 
         if (esb_pci) {
         	if (pci_enable_device(esb_pci)) {
 			printk (KERN_ERR PFX "failed to enable device\n");
-			goto out;
+			goto err_devput;
 		}
 
 		if (pci_request_region(esb_pci, 0, ESB_MODULE_NAME)) {
@@ -430,8 +431,9 @@
 		pci_release_region(esb_pci, 0);
 err_disable:
 		pci_disable_device(esb_pci);
+err_devput:
+		pci_dev_put(esb_pci);
 	}
-out:
 	return 0;
 }
 
@@ -481,7 +483,8 @@
 	pci_release_region(esb_pci, 0);
 /* err_disable: */
 	pci_disable_device(esb_pci);
-/* out: */
+/* err_devput: */
+	pci_dev_put(esb_pci);
         return ret;
 }
 
@@ -497,6 +500,7 @@
 	iounmap(BASEADDR);
 	pci_release_region(esb_pci, 0);
 	pci_disable_device(esb_pci);
+	pci_dev_put(esb_pci);
 }
 
 module_init(watchdog_init);

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

* Re: [-mm PATCH] remove use of pci_find_device in watchdog driver for Intel 6300ESB chipset
  2005-08-15 21:30 [-mm PATCH] remove use of pci_find_device in watchdog driver for Intel 6300ESB chipset Naveen Gupta
@ 2005-08-15 23:14 ` David Härdeman
  2005-08-16  0:19   ` Jiri Slaby
  0 siblings, 1 reply; 3+ messages in thread
From: David Härdeman @ 2005-08-15 23:14 UTC (permalink / raw)
  To: Naveen Gupta; +Cc: linux-kernel

On Mon, Aug 15, 2005 at 02:30:15PM -0700, Naveen Gupta wrote:
[...}
>-        while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
>-                if (pci_match_id(esb_pci_tbl, dev)) {
>-                        esb_pci = dev;
>-                        break;
>-                }
>-        }
>+	while (ids->vendor && ids->device) {
>+		if ((dev = pci_get_device(ids->vendor, ids->device, dev)) != NULL) {
>+			esb_pci = dev;
>+			break;
>+		}
>+		ids++;
>+	}

I'm certainly not sure about this, but the proposed while loop looks a 
bit unconventional, wouldn't something like:

for_each_pci_dev(dev)
	if (pci_match_id(esb_pci_tbl, dev)) {
		esb_pci = dev;
		break;
	}
}

be better?

//David

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

* Re: [-mm PATCH] remove use of pci_find_device in watchdog driver for Intel 6300ESB chipset
  2005-08-15 23:14 ` David Härdeman
@ 2005-08-16  0:19   ` Jiri Slaby
  0 siblings, 0 replies; 3+ messages in thread
From: Jiri Slaby @ 2005-08-16  0:19 UTC (permalink / raw)
  To: David Härdeman; +Cc: Naveen Gupta, linux-kernel

David Härdeman napsal(a):

> On Mon, Aug 15, 2005 at 02:30:15PM -0700, Naveen Gupta wrote:
> [...}
>
>> -        while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) 
>> != NULL) {
>> -                if (pci_match_id(esb_pci_tbl, dev)) {
>> -                        esb_pci = dev;
>> -                        break;
>> -                }
>> -        }
>> +    while (ids->vendor && ids->device) {
>> +        if ((dev = pci_get_device(ids->vendor, ids->device, dev)) != 
>> NULL) {
>> +            esb_pci = dev;
>> +            break;
>> +        }
>> +        ids++;
>> +    }
>
>
> I'm certainly not sure about this, but the proposed while loop looks a 
> bit unconventional, wouldn't something like:
>
> for_each_pci_dev(dev)
>     if (pci_match_id(esb_pci_tbl, dev)) {
>         esb_pci = dev;
>         break;
>     }
> }
>
> be better?

I did it here http://lkml.org/lkml/2005/8/9/305, but it wasn't acked 
yet. I should repost.

-- 
Jiri Slaby         www.fi.muni.cz/~xslaby
~\-/~      jirislaby@gmail.com      ~\-/~
241B347EC88228DE51EE A49C4A73A25004CB2A10


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

end of thread, other threads:[~2005-08-16  0:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-15 21:30 [-mm PATCH] remove use of pci_find_device in watchdog driver for Intel 6300ESB chipset Naveen Gupta
2005-08-15 23:14 ` David Härdeman
2005-08-16  0:19   ` Jiri Slaby

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