Skip to contentSkip to conversation

gdth: update deprecated pci_find_device

SCSI Jeff Garzik 3 participants 3 messages Feb 14, 2008 1 message not in the archive SCSI

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 46 lines · Linux Kernel Mailing List
Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=99109301d103fbf0de43fc5a580a406c12a501e0
Commit:     99109301d103fbf0de43fc5a580a406c12a501e0
Parent:     61c92814dc324b541391757062ff02fbf3b08086
Author:     Sergio Luis <[email protected]>
AuthorDate: Tue Feb 12 20:48:03 2008 -0300
Committer:  James Bottomley <[email protected]>
CommitDate: Wed Feb 13 09:33:10 2008 -0600

[SCSI] gdth: update deprecated pci_find_device

Fix compilation warning in gdth.c, which was using the deprecated pci_find_device.

drivers/scsi/gdth.c:645: warning: 'pci_find_device' is deprecated (declared at include/linux/pci.h:495)

Changing it to use pci_get_device, instead.

---
 drivers/scsi/Kconfig |    2 +-
 drivers/scsi/gdth.c  |    7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/scsi/Kconfig +1 -1
index a5f0aaa..a7a0813 100644
@@ -722,7 +722,7 @@ config SCSI_FD_MCS
 
 config SCSI_GDTH
 	tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support"
-	depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API && PCI_LEGACY
+	depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
 	---help---
 	  Formerly called GDT SCSI Disk Array Controller Support.
 
drivers/scsi/gdth.c +0 -1
index 7079fef..6d67f5c 100644
@@ -642,12 +642,15 @@ static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt,
           *cnt, vendor, device));
 
     pdev = NULL;
-    while ((pdev = pci_find_device(vendor, device, pdev)) 

drivers/scsi/gdth.c static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt, · line 653

Quoted 10 lines
drivers/scsi/gdth.c +5 -1
+    while ((pdev = pci_get_device(vendor, device, pdev))
            != NULL) {
         if (pci_enable_device(pdev))
             continue;
-        if (*cnt >= MAXHA)
+        if (*cnt >= MAXHA) {
+            pci_dev_put(pdev);
             return;
+        }
+

Why no pci_dev_put() in the module cleanup path?

Jeff

maintainer
#2 lore raw
Quoted 45 lines · Jeff Garzik
Quoted 44 lines · Linux Kernel Mailing List
Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=99109301d103fbf0de43fc5a580a406c12a501e0
Commit:     99109301d103fbf0de43fc5a580a406c12a501e0
Parent:     61c92814dc324b541391757062ff02fbf3b08086
Author:     Sergio Luis <[email protected]>
AuthorDate: Tue Feb 12 20:48:03 2008 -0300
Committer:  James Bottomley <[email protected]>
CommitDate: Wed Feb 13 09:33:10 2008 -0600

[SCSI] gdth: update deprecated pci_find_device

Fix compilation warning in gdth.c, which was using the deprecated pci_find_device.

drivers/scsi/gdth.c:645: warning: 'pci_find_device' is deprecated (declared at include/linux/pci.h:495)

Changing it to use pci_get_device, instead.

---
 drivers/scsi/Kconfig |    2 +-
 drivers/scsi/gdth.c  |    7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/scsi/Kconfig +1 -1
index a5f0aaa..a7a0813 100644
@@ -722,7 +722,7 @@ config SCSI_FD_MCS
 
 config SCSI_GDTH
 	tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support"
-	depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API && PCI_LEGACY
+	depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
 	---help---
 	  Formerly called GDT SCSI Disk Array Controller Support.
 
drivers/scsi/gdth.c +0 -0
index 7079fef..6d67f5c 100644
@@ -642,12 +642,15 @@ static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt,
           *cnt, vendor, device));
 
Quoted 14 lines

drivers/scsi/gdth.c static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt, · line 653

Quoted 12 lines
drivers/scsi/gdth.c +5 -2
     pdev = NULL;
-    while ((pdev = pci_find_device(vendor, device, pdev)) 
+    while ((pdev = pci_get_device(vendor, device, pdev))
            != NULL) {
         if (pci_enable_device(pdev))
             continue;
-        if (*cnt >= MAXHA)
+        if (*cnt >= MAXHA) {
+            pci_dev_put(pdev);
             return;
+        }
+

Why no pci_dev_put() in the module cleanup path?

Because the pci dev is never got ... nasty I know, but it's the way this driver works.

the while (pci_get_device()) runs until the device returned is NULL. At that point, every PCI device it ever returned has been put. The only problem is premature exit from the while loop, which is why I made the original author do a put along that path.

James

#3 lore raw
Quoted 60 lines · James Bottomley
Quoted 45 lines · Jeff Garzik
Quoted 44 lines · Linux Kernel Mailing List
Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=99109301d103fbf0de43fc5a580a406c12a501e0
Commit:     99109301d103fbf0de43fc5a580a406c12a501e0
Parent:     61c92814dc324b541391757062ff02fbf3b08086
Author:     Sergio Luis <[email protected]>
AuthorDate: Tue Feb 12 20:48:03 2008 -0300
Committer:  James Bottomley <[email protected]>
CommitDate: Wed Feb 13 09:33:10 2008 -0600

[SCSI] gdth: update deprecated pci_find_device

Fix compilation warning in gdth.c, which was using the deprecated pci_find_device.

drivers/scsi/gdth.c:645: warning: 'pci_find_device' is deprecated (declared at include/linux/pci.h:495)

Changing it to use pci_get_device, instead.

---
 drivers/scsi/Kconfig |    2 +-
 drivers/scsi/gdth.c  |    7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/scsi/Kconfig +1 -1
index a5f0aaa..a7a0813 100644
@@ -722,7 +722,7 @@ config SCSI_FD_MCS
 
 config SCSI_GDTH
 	tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support"
-	depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API && PCI_LEGACY
+	depends on (ISA || EISA || PCI) && SCSI && ISA_DMA_API
 	---help---
 	  Formerly called GDT SCSI Disk Array Controller Support.
 
drivers/scsi/gdth.c +0 -0
index 7079fef..6d67f5c 100644
@@ -642,12 +642,15 @@ static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt,
           *cnt, vendor, device));
 
Quoted 13 lines

drivers/scsi/gdth.c static void __init gdth_search_dev(gdth_pci_str *pcistr, ushort *cnt, · line 653

Quoted 12 lines
drivers/scsi/gdth.c +5 -2
     pdev = NULL;
-    while ((pdev = pci_find_device(vendor, device, pdev)) 
+    while ((pdev = pci_get_device(vendor, device, pdev))
            != NULL) {
         if (pci_enable_device(pdev))
             continue;
-        if (*cnt >= MAXHA)
+        if (*cnt >= MAXHA) {
+            pci_dev_put(pdev);
             return;
+        }
+

Why no pci_dev_put() in the module cleanup path?

Quoted 2 lines

Because the pci dev is never got ... nasty I know, but it's the way this driver works.

Then the change fixes nothing from my point of view. The core might drop the device from the system at any time after pci_get_device()'s next call.