lkml.org 
[lkml]   [2009]   [Feb]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
Subject[PATCH] pcie_portdriver: FIX: pcie_port_device_remove (take 2)

pcie_port_device_remove currently calls the remove method of port
drivers twice. Ouch!

We are calling device_for_each_child multiple times for no apparent
reason.

So make it simple. Place put_device and device_unregister into
remove_iter, and throw out the rest. Only call device_for_each_child
once.

The code is simpler and actually works!

Changelog:
v2 rebase against the linux-next tree so I don't conflict with Rafael's
irq work, and remove the irq handling cleanups as Rafael's patch already
made them.

Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
---

drivers/pci/pcie/portdrv_core.c | 23 +++--------------------
1 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index 3aea92a..569af00 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -456,16 +456,9 @@ int pcie_port_device_resume(struct pci_dev *dev)

static int remove_iter(struct device *dev, void *data)
{
- struct pcie_port_service_driver *service_driver;
-
if (dev->bus == &pcie_port_bus_type) {
- if (dev->driver) {
- service_driver = to_service_driver(dev->driver);
- if (service_driver->remove)
- service_driver->remove(to_pcie_device(dev));
- }
- *(unsigned long*)data = (unsigned long)dev;
- return 1;
+ put_device(dev);
+ device_unregister(dev);
}
return 0;
}
@@ -480,18 +473,8 @@ static int remove_iter(struct device *dev, void *data)
void pcie_port_device_remove(struct pci_dev *dev)
{
struct pcie_port_data *port_data = pci_get_drvdata(dev);
- int status;
-
- do {
- unsigned long device_addr;

- status = device_for_each_child(&dev->dev, &device_addr, remove_iter);
- if (status) {
- struct device *device = (struct device*)device_addr;
- put_device(device);
- device_unregister(device);
- }
- } while (status);
+ device_for_each_child(&dev->dev, NULL, remove_iter);

switch (port_data->port_irq_mode) {
case PCIE_PORT_MSIX_MODE:
--
1.6.0.6


\
 
 \ /
  Last update: 2009-02-21 05:19    [W:1.377 / U:0.528 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site