Skip to contentSkip to conversation

change pci_find_device to pci_get_device,

PATCH In review Denis Cheng 3 participants 7 messages Jul 16, 2007 – Jul 17, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 change pci_find_device to pci_get_device,

this eliminates compiler warning:

drivers/scsi/advansys.c: In function ‘advansys_detect’:
drivers/scsi/advansys.c:4456: warning: ‘pci_find_device’ is deprecated (declared at include/linux/pci.h:478)

---
 drivers/scsi/advansys.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/advansys.c +1 -1
index 2b66897..8e5abd1 100644
@@ -4453,7 +4453,7 @@ advansys_detect(struct scsi_host_template *tpnt)
 
                     /* Find all PCI cards. */
                     while (pci_device_id_cnt < ASC_PCI_DEVICE_ID_CNT) {
-                        if ((pci_devp = pci_find_device(PCI_VENDOR_ID_ASP,
+                        if ((pci_devp = pci_get_device(PCI_VENDOR_ID_ASP,
                             pci_device_id[pci_device_id_cnt], pci_devp)) ==
                             NULL) {
                             pci_device_id_cnt++;
Signature · 1 line
1.5.2.2
author
#1 lore raw
Quoted 4 lines · Denis Cheng

this eliminates compiler warning:

drivers/scsi/advansys.c: In function 'advansys_detect':
drivers/scsi/advansys.c:4456: warning: 'pci_find_device' is deprecated (declared at include/linux/pci.h:478)

But there is still one warning left:
drivers/scsi/advansys.c:794:2: warning: #warning this driver is still not properly converted to the DMA API

Quoted 23 lines
---
 drivers/scsi/advansys.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/advansys.c +1 -2
index 2b66897..8e5abd1 100644
@@ -4453,7 +4453,7 @@ advansys_detect(struct scsi_host_template *tpnt)
 
                     /* Find all PCI cards. */
                     while (pci_device_id_cnt < ASC_PCI_DEVICE_ID_CNT) {
-                        if ((pci_devp = pci_find_device(PCI_VENDOR_ID_ASP,
+                        if ((pci_devp = pci_get_device(PCI_VENDOR_ID_ASP,
                             pci_device_id[pci_device_id_cnt], pci_devp)) =
                             NULL) {
                             pci_device_id_cnt++;
--

1.5.2.2

Signature · 5 lines
Denis Cheng
Linux Application Developer

"One of my most productive days was throwing away 1000 lines of code."
 - Ken Thompson.
#2 lore raw
In reply to Denis Cheng

drivers/scsi/advansys.c advansys_detect(struct scsi_host_template *tpnt) · line 4459

Quoted 10 lines · Denis Cheng
drivers/scsi/advansys.c +1 -1
@@ -4453,7 +4453,7 @@ advansys_detect(struct scsi_host_template *tpnt)
 
                     /* Find all PCI cards. */
                     while (pci_device_id_cnt < ASC_PCI_DEVICE_ID_CNT) {
-                        if ((pci_devp = pci_find_device(PCI_VENDOR_ID_ASP,
+                        if ((pci_devp = pci_get_device(PCI_VENDOR_ID_ASP,
                             pci_device_id[pci_device_id_cnt], pci_devp)) =
                             NULL) {
                             pci_device_id_cnt++;

Where do you drop the reference to the PCI device again?

Signature · 3 lines
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
author
#3 lore raw
In reply to Denis Cheng
Quoted 13 lines · Matthew Wilcox

drivers/scsi/advansys.c advansys_detect(struct scsi_host_template *tpnt)

Quoted 10 lines · Denis Cheng
drivers/scsi/advansys.c +1 -2
@@ -4453,7 +4453,7 @@ advansys_detect(struct scsi_host_template *tpnt)
 
                     /* Find all PCI cards. */
                     while (pci_device_id_cnt < ASC_PCI_DEVICE_ID_CNT) {
-                        if ((pci_devp = pci_find_device(PCI_VENDOR_ID_ASP,
+                        if ((pci_devp = pci_get_device(PCI_VENDOR_ID_ASP,
                             pci_device_id[pci_device_id_cnt], pci_devp)) =
                             NULL) {
                             pci_device_id_cnt++;
--

Where do you drop the reference to the PCI device again?

I don't know how to solve this problem, I just want to do some kernel janitors project to contribute to the linux kernel, I'm just a kernel newbie;
Because the pci_find_device is deprecated, the comments in this function said, please use pci_get_device instead; but pci_get_device called here return a (struct pci_dev *) to a local variable, someone could tell me when to call pci_put_device?

Thanks.

Quoted 6 lines

--
"Bill, look, we understand that you're interested in selling us this operating system, but compare it to ours. We can't possibly take such a retrograde step."

Signature · 5 lines
Denis Cheng
Linux Application Developer

"One of my most productive days was throwing away 1000 lines of code."
 - Ken Thompson.
#4 lore raw
In reply to Denis Cheng
Quoted 3 lines · rae l

I don't know how to solve this problem, I just want to do some kernel janitors project to contribute to the linux kernel, I'm just a kernel newbie;

Pick an easier project; this one is too intricate.

Quoted 4 lines

Because the pci_find_device is deprecated, the comments in this function said, please use pci_get_device instead; but pci_get_device called here return a (struct pci_dev *) to a local variable, someone could tell me when to call pci_put_device?

The correct way to do this is to convert the driver to use the pci_register_driver API. I'm taking a stab at it now -- and let me assure you that it's not easy.

Signature · 3 lines
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
#5 lore raw
In reply to Denis Cheng
Quoted 16 lines · rae l
Quoted 15 lines · Matthew Wilcox

drivers/scsi/advansys.c advansys_detect(struct scsi_host_template *tpnt) · line 4456

Quoted 5 lines · Denis Cheng
drivers/scsi/advansys.c +0 -1
@@ -4453,7 +4453,7 @@ advansys_detect(struct scsi_host_template *tpnt)
 
                     /* Find all PCI cards. */
                     while (pci_device_id_cnt < ASC_PCI_DEVICE_ID_CNT) {
-                        if ((pci_devp = 

pci_find_device(PCI_VENDOR_ID_ASP,

Review advansys_detect(struct scsi_host_template *tpnt) · line 4456

Quoted 1 line
(quoted diff) +1 -0
+                        if ((pci_devp = 

pci_get_device(PCI_VENDOR_ID_ASP,

Review advansys_detect(struct scsi_host_template *tpnt) · line 4457

Quoted 1 line
(quoted diff) +0 -0
                             pci_device_id[pci_device_id_cnt], pci_devp)) 

=

Quoted 3 lines
drivers/scsi/advansys.c +0 -1
                             NULL) {
                             pci_device_id_cnt++;
--
Quoted 8 lines
Quoted 1 line

Where do you drop the reference to the PCI device again?

I don't know how to solve this problem, I just want to do some kernel janitors project to contribute to the linux kernel, I'm just a kernel newbie;
Because the pci_find_device is deprecated, the comments in this function said, please use pci_get_device instead; but pci_get_device called here return a (struct pci_dev *) to a local variable, someone could tell me when to call pci_put_device?

Please read the comments for the pci_get_device() function to fully understand why people have not just gone through and done a simple search-and-replace action for the whole kernel tree. It is much more complex than that.

good luck,

greg k-h

#6 lore raw
In reply to Denis Cheng
Quoted 4 lines · Greg KH

Please read the comments for the pci_get_device() function to fully understand why people have not just gone through and done a simple search-and-replace action for the whole kernel tree. It is much more complex than that.

Yes, it is. Here's my solution:

http://marc.info/?l=linux-scsi&m8462846525015&w=2
http://marc.info/?l=linux-scsi&m8462738926857&w=2
http://marc.info/?l=linux-scsi&m8463215810772&w=2
http://marc.info/?l=linux-scsi&m8462771422817&w=2

Untested, as I don't have the hardware.

Signature · 3 lines
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."