Skip to contentSkip to conversation

drivers/char/ip2/ip2main.c : change pci_find_device by

PATCH In review trem 3 participants 4 messages May 16, 2006 – May 17, 2006

Subsystems (2)
lore
Share & tools
lore

trem

author
#0 lore raw

PATCH 1/1 drivers/char/ip2/ip2main.c : change pci_find_device by

From: trem <[email protected]>

This patch simply change pci_find_device by pci_get_device, because pci_find_device is deprecated. pci_dev_put has been added to decrement the counter, so unload could be done.

---

drivers/char/ip2/ip2main.c +2 -1
index 03db1cb..2acdfb2 100644
@@ -594,7 +594,7 @@ ip2_loadmain(int *iop, int *irqp, unsign
 #ifdef CONFIG_PCI
 			{
 				struct pci_dev *pci_dev_i = NULL;
-				pci_dev_i = pci_find_device(PCI_VENDOR_ID_COMPUTONE,
+				pci_dev_i = pci_get_device(PCI_VENDOR_ID_COMPUTONE,
 							  PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i);
 				if (pci_dev_i != NULL) {
 					unsigned int addr;
@@ -622,6 +622,7 @@ ip2_loadmain(int *iop, int *irqp, unsign
 //						pci_irq = 0;
 //					}
 					ip2config.irq[i] = pci_dev_i->irq;
+					pci_dev_put(pci_dev_i);
 				} else {	// ann error
 					ip2config.addr[i] = 0;
 					if (status == PCIBIOS_DEVICE_NOT_FOUND) {

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw

PATCH 1/1 drivers/char/ip2/ip2main.c : change pci_find_device by

From: trem <[email protected]>

This patch simply change pci_find_device by pci_get_device, because pci_find_device is deprecated. pci_dev_put has been added to decrement the counter, so unload could be done. I've added a pci_dev_put(pci_dev_i) before the break to avoid mising a device.

---

drivers/char/ip2/ip2main.c +3 -1
index 03db1cb..235f17e 100644
@@ -594,7 +594,7 @@ ip2_loadmain(int *iop, int *irqp, unsign
 #ifdef CONFIG_PCI
 			{
 				struct pci_dev *pci_dev_i = NULL;
-				pci_dev_i = pci_find_device(PCI_VENDOR_ID_COMPUTONE,
+				pci_dev_i = pci_get_device(PCI_VENDOR_ID_COMPUTONE,
 							  PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i);
 				if (pci_dev_i != NULL) {
 					unsigned int addr;
@@ -602,6 +602,7 @@ ip2_loadmain(int *iop, int *irqp, unsign
 					if (pci_enable_device(pci_dev_i)) {
 						printk( KERN_ERR "IP2: can't enable PCI device at %s\n",
 							pci_name(pci_dev_i));
+						pci_dev_put(pci_dev_i);
 						break;
 					}
 					ip2config.type[i] = PCI;
@@ -622,6 +623,7 @@ ip2_loadmain(int *iop, int *irqp, unsign
 //						pci_irq = 0;
 //					}
 					ip2config.irq[i] = pci_dev_i->irq;
+					pci_dev_put(pci_dev_i);
 				} else {	// ann error
 					ip2config.addr[i] = 0;
 					if (status == PCIBIOS_DEVICE_NOT_FOUND) {

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#2 lore raw

Re: [KJ] [PATCH] drivers/char/ip2/ip2main.c : change pci_find_device

In reply to trem
Quoted 6 lines · trem

From: trem <[email protected]>

This patch simply change pci_find_device by pci_get_device, because pci_find_device is deprecated. pci_dev_put has been added to decrement the counter, so unload could be done. I've added a pci_dev_put(pci_dev_i) before the break to avoid mising a device.

No, you are decrementing a reference while still holding a pointer to it. That's a bug.

thanks,

greg k-h

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#3 lore raw

Re: [KJ] [PATCH] drivers/char/ip2/ip2main.c : change pci_find_device

In reply to trem
Quoted 24 lines · trem

From: trem <[email protected]>

This patch simply change pci_find_device by pci_get_device, because pci_find_device is deprecated. pci_dev_put has been added to decrement the counter, so unload could be done.

---

drivers/char/ip2/ip2main.c +1 -1
index 03db1cb..2acdfb2 100644
@@ -594,7 +594,7 @@ ip2_loadmain(int *iop, int *irqp, unsign
 #ifdef CONFIG_PCI
 			{
 				struct pci_dev *pci_dev_i = NULL;
-				pci_dev_i = pci_find_device(PCI_VENDOR_ID_COMPUTONE,
+				pci_dev_i = pci_get_device(PCI_VENDOR_ID_COMPUTONE,
 							  PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i);
 				if (pci_dev_i != NULL) {
 					unsigned int addr;

drivers/char/ip2/ip2main.c ip2_loadmain(int *iop, int *irqp, unsign · line 625

Quoted 4 lines
drivers/char/ip2/ip2main.c +1 -0
@@ -622,6 +622,7 @@ ip2_loadmain(int *iop, int *irqp, unsign
 //						pci_irq = 0;
 //					}
 					ip2config.irq[i] = pci_dev_i->irq;
+					pci_dev_put(pci_dev_i);

Nope, you saved a reference and yet just released it. Not acceptable.

Please note that making these changes is very difficult. Numerous people have tried it in the past and generally just given up. See the archives for details on how to get it correct, and to keep from doing the same things that others did.

thanks,

greg k-h

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors