• Johannes Erdfelt's avatar
    [PATCH] USB device reference counting fix for uhci.c and usb core · 25f04c13
    Johannes Erdfelt authored
    Earlier in the 2.5 development cycle a patch was applied that changed
    the reference counting behaviour for USB devices.
    
    There are a couple of problems with the change:
    - It made the USB code more complicated as a whole with the introduction
      of an additional cleanup path for devices. Using the traditional method
      of reference counting, cleanup is handled implictly
    - It reduces functionality by requiring a callback for all references to
      the device, but doesn't provide a method of providing callbacks for
      references. It relies on the hardcoded device driver ->disconnect and
      HCD ->deallocate method for callbacks
    
    The traditional method of using reference counting supports as many
    reference users as needed, without complicating it with mandatory
    callbacks to cleanup references.
    
    The change in 2.5 also only helps catch one subset of programming
    problem in device drivers, the case where it decrements too many times.
    That is of dubious debugging value.
    
    So, this patch reverts the change and makes the reference counting
    behave like it does in the rest of the kernel as well as how the USB
    code does in 2.4.
    
    This patch doesn't remove all of the superfluous code. Some drivers,
    like usb-ohci, ohci-hcd and ehci-hcd have some code that is no longer
    needed. I wanted to spend some more time with those drivers since the
    changes weren't as trivial as uhci.c and usb-uhci.c.
    
    I've tested with uhci and usb-ohci with no adverse effects.
    25f04c13
uhci.c 75.4 KB