public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] PCI hotplug : Switch to pci_get_bus_and_slot instead of deprecated pci_find_slot.
@ 2007-10-01  3:09 JoonwooPark
  2007-10-01  6:10 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: JoonwooPark @ 2007-10-01  3:09 UTC (permalink / raw)
  To: linux-kernel; +Cc: gregkh, kristen.c.accardi

This patch fixes these warnings:

drivers/pci/hotplug/cpqphp_pci.c: In function ‘cpqhp_configure_device’:
drivers/pci/hotplug/cpqphp_pci.c:92: warning: ‘pci_find_slot’ is deprecated (declared at include/linux/pci.h:481)
drivers/pci/hotplug/cpqphp_pci.c:102: warning: ‘pci_find_slot’ is deprecated (declared at include/linux/pci.h:481)
drivers/pci/hotplug/cpqphp_pci.c: In function ‘cpqhp_unconfigure_device’:
drivers/pci/hotplug/cpqphp_pci.c:126: warning: ‘pci_find_slot’ is deprecated (declared at include/linux/pci.h:481)
drivers/pci/hotplug/cpqphp_pci.c: In function ‘cpqhp_save_config’:
drivers/pci/hotplug/cpqphp_pci.c:420: warning: ‘pci_find_slot’ is deprecated (declared at include/linux/pci.h:481)

Signed-off-by: Joonwoo Park <joonwpark81@gmail.com>
---
 drivers/pci/hotplug/cpqphp_pci.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
diff --git a/drivers/pci/hotplug/cpqphp_pci.c b/drivers/pci/hotplug/cpqphp_pci.c
index fc7c74d..c05d34a 100644
--- a/drivers/pci/hotplug/cpqphp_pci.c
+++ b/drivers/pci/hotplug/cpqphp_pci.c
@@ -89,7 +89,7 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
 	int num;
 
 	if (func->pci_dev == NULL)
-		func->pci_dev = pci_find_slot(func->bus, PCI_DEVFN(func->device, func->function));
+		func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function));
 
 	/* No pci device, we need to create it then */
 	if (func->pci_dev == NULL) {
@@ -99,7 +99,7 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
 		if (num)
 			pci_bus_add_devices(ctrl->pci_dev->bus);
 
-		func->pci_dev = pci_find_slot(func->bus, PCI_DEVFN(func->device, func->function));
+		func->pci_dev = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, func->function));
 		if (func->pci_dev == NULL) {
 			dbg("ERROR: pci_dev still null\n");
 			return 0;
@@ -123,7 +123,7 @@ int cpqhp_unconfigure_device(struct pci_func* func)
 	dbg("%s: bus/dev/func = %x/%x/%x\n", __FUNCTION__, func->bus, func->device, func->function);
 
 	for (j=0; j<8 ; j++) {
-		struct pci_dev* temp = pci_find_slot(func->bus, PCI_DEVFN(func->device, j));
+		struct pci_dev *temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j));
 		if (temp)
 			pci_remove_bus_device(temp);
 	}
@@ -417,7 +417,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
 				new_slot->switch_save = 0x10;
 				// In case of unsupported board
 				new_slot->status = DevError;
-				new_slot->pci_dev = pci_find_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function);
+				new_slot->pci_dev = pci_get_bus_and_slot(new_slot->bus, (new_slot->device << 3) | new_slot->function);
 
 				for (cloop = 0; cloop < 0x20; cloop++) {
 					rc = pci_bus_read_config_dword (ctrl->pci_bus, PCI_DEVFN(device, function), cloop << 2, (u32 *) & (new_slot-> config_space [cloop]));
---

Thanks.
Joonwoo Park



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

* Re: [PATCH] PCI hotplug : Switch to pci_get_bus_and_slot instead of deprecated pci_find_slot.
  2007-10-01  3:09 [PATCH] PCI hotplug : Switch to pci_get_bus_and_slot instead of deprecated pci_find_slot JoonwooPark
@ 2007-10-01  6:10 ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2007-10-01  6:10 UTC (permalink / raw)
  To: JoonwooPark; +Cc: linux-kernel, kristen.c.accardi

On Mon, Oct 01, 2007 at 12:09:07PM +0900, JoonwooPark wrote:
> This patch fixes these warnings:
> 
> drivers/pci/hotplug/cpqphp_pci.c: In function ???cpqhp_configure_device???:
> drivers/pci/hotplug/cpqphp_pci.c:92: warning: ???pci_find_slot??? is deprecated (declared at include/linux/pci.h:481)
> drivers/pci/hotplug/cpqphp_pci.c:102: warning: ???pci_find_slot??? is deprecated (declared at include/linux/pci.h:481)
> drivers/pci/hotplug/cpqphp_pci.c: In function ???cpqhp_unconfigure_device???:
> drivers/pci/hotplug/cpqphp_pci.c:126: warning: ???pci_find_slot??? is deprecated (declared at include/linux/pci.h:481)
> drivers/pci/hotplug/cpqphp_pci.c: In function ???cpqhp_save_config???:
> drivers/pci/hotplug/cpqphp_pci.c:420: warning: ???pci_find_slot??? is deprecated (declared at include/linux/pci.h:481)
> 
> Signed-off-by: Joonwoo Park <joonwpark81@gmail.com>

Close, but you need to free the reference that you now have grabed.  As
is, this patch will cause a memory leak and cause bad things to happen
:(

Take a look at the documentation for the pci_get_bus_and_slot()
function, it's not as easy as a simple search-and-replace.

thanks,

greg k-h

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

* Re: [PATCH] PCI hotplug : Switch to pci_get_bus_and_slot instead of deprecated pci_find_slot.
@ 2007-10-01  8:05 Joonwoo Park
  0 siblings, 0 replies; 3+ messages in thread
From: Joonwoo Park @ 2007-10-01  8:05 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, kristen.c.accardi

Thank you so much for your check & advise.
This time, I've tried on ibmphp_core.c, is it OK?

Signed-off-by: Joonwoo Park <joonwpark81@gmail.com>
---
 drivers/pci/hotplug/ibmphp_core.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index 0316eea..2085023 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -761,10 +761,13 @@ static void ibm_unconfigure_device(struct pci_func *func)
 	debug("func->device << 3 | 0x0  = %x\n", func->device << 3 | 0x0);
 
 	for (j = 0; j < 0x08; j++) {
-		temp = pci_find_slot(func->busno, (func->device << 3) | j);
-		if (temp)
+		temp = pci_get_bus_and_slot(func->busno, (func->device << 3) | j);
+		if (temp) {
 			pci_remove_bus_device(temp);
+			pci_dev_put(temp);
+		}
 	}
+	pci_dev_put(func->dev);
 }
 
 /*
@@ -823,7 +826,7 @@ static int ibm_configure_device(struct pci_func *func)
 	if (!(bus_structure_fixup(func->busno)))
 		flag = 1;
 	if (func->dev == NULL)
-		func->dev = pci_find_slot(func->busno,
+		func->dev = pci_get_bus_and_slot(func->busno,
 				PCI_DEVFN(func->device, func->function));
 
 	if (func->dev == NULL) {
@@ -836,7 +839,7 @@ static int ibm_configure_device(struct pci_func *func)
 		if (num)
 			pci_bus_add_devices(bus);
 
-		func->dev = pci_find_slot(func->busno,
+		func->dev = pci_get_bus_and_slot(func->busno,
 				PCI_DEVFN(func->device, func->function));
 		if (func->dev == NULL) {
 			err("ERROR... : pci_dev still NULL\n");
---

Thanks.
Joonwoo Park

> On Mon, Oct 01, 2007 at 12:09:07PM +0900, JoonwooPark wrote:
> > This patch fixes these warnings:
> >
> > drivers/pci/hotplug/cpqphp_pci.c: In
> function ???cpqhp_configure_device???:
> > drivers/pci/hotplug/cpqphp_pci.c:92: warning: ???pci_find_slot??? is
> deprecated (declared at include/linux/pci.h:481)
> > drivers/pci/hotplug/cpqphp_pci.c:102: warning: ???pci_find_slot???
> is deprecated (declared at include/linux/pci.h:481)
> > drivers/pci/hotplug/cpqphp_pci.c: In
> function ???cpqhp_unconfigure_device???:
> > drivers/pci/hotplug/cpqphp_pci.c:126: warning: ???pci_find_slot???
> is deprecated (declared at include/linux/pci.h:481)
> > drivers/pci/hotplug/cpqphp_pci.c: In
> function ???cpqhp_save_config???:
> > drivers/pci/hotplug/cpqphp_pci.c:420: warning: ???pci_find_slot???
> is deprecated (declared at include/linux/pci.h:481)
> >
> > Signed-off-by: Joonwoo Park <joonwpark81@gmail.com>
> 
> 
> Close, but you need to free the reference that you now have grabed.
>  As
> is, this patch will cause a memory leak and cause bad things to happen
> :(
> 
> Take a look at the documentation for the pci_get_bus_and_slot()
> function, it's not as easy as a simple search-and-replace.
> 
> thanks,
> 
> greg k-h
> 



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

end of thread, other threads:[~2007-10-01  8:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-01  3:09 [PATCH] PCI hotplug : Switch to pci_get_bus_and_slot instead of deprecated pci_find_slot JoonwooPark
2007-10-01  6:10 ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2007-10-01  8:05 Joonwoo Park

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