]> git.hungrycats.org Git - linux/commit
[PATCH] PCI: fix "pcibus_class" Device Class, release function
authorMatthew Dobson <colpatch@us.ibm.com>
Wed, 4 Feb 2004 02:03:35 +0000 (18:03 -0800)
committerGreg Kroah-Hartman <greg@kroah.com>
Wed, 4 Feb 2004 02:03:35 +0000 (18:03 -0800)
commitde56fa211483e077bc530a3e667a3539349d81a6
tree343f847fcf052797b493b82690839961068839dc
parent9a5c386eca2a272114eadcecca7061e2727b9085
[PATCH] PCI: fix "pcibus_class" Device Class, release function

John Rose wrote:
> The function release_pcibus_dev() in probe.c defines the release procedure for
> device class pcibus_class.  I want to suggest that this function be scrapped :)
>
> This release function is called in the code path of class_device_unregister().
> The pcibus_class devices aren't currently unregistered anywhere, from what I
> can tell, so this release function is currently unused.  The runtime removal of
> PCI buses from logical partitions on PPC64 requires the unregistration of these
> class devices.  The natural place to do this IMHO is in pci_remove_bus_device()
> in remove.c.

You're right that the class device isn't currently unregistered, and
that was an oversight in the patch I originally sent.  Attatched is a
patch that remedies that situation.  pci_remove_bus_device() *is* the
natural place to unregister the class_dev, and that's just what the
patch does.

> The problem is that this calls pci_destroy_dev(), which calls put() on the same
> "bridge" device that the release function does.  This should only be done once
> in the course of removing a pci_bus, and I doubt that we want to change
> pci_destroy_dev().   The kfree() of the pci_bus struct is also done in both
> pci_remove_bus_device() and release_pcibus_dev().

Yep.  The patch pulls the kfree() out of pci_remove_bus_device() and
calls class_device_unregister() in it's place.  This will put() the
bridge device and free the pci_bus as needed.  put() does need to be
called twice because the bridge device is get()'d twice: once when the
device is registered and once when it's bus device grabs a reference to it.
drivers/pci/remove.c