Linux Operating System Source Code: IBM Patches

 
Device Model initialize rework
Description:
In working to clean up the usb device reference counting logic, I moved
all of the calls to usb_get_dev() and usb_put_dev() to get_device() and
put_device() as it does not make sense to have two reference counts in
the same structure.  But when doing that, I realized that the USB core
accesses devices before it calls device_register().  And calling
get_device() and put_device() before device_register() is called is not
a good thing :)

So here's a patch that adds a device_initialize() call, that can be done
when the device structure is created.  At that point, get_device() and
put_device() can be successfully called, as the USB core needs, and at a
later time, device_register() can be called.  It also replaces the
present flag with a device state, allowing 3 valid states for a device
(initialized, registered, and gone).

I know Al needs much the same thing for his gendisk cleanup, and has
implemented almost the same patch as I have, but I think mine solves his
problem of having to manipulate the device refcount variable himself.

Anyway, here's a patch against 2.5.42 that adds device_initialize() and
fixes up the USB core to use it.  It works for me, but I haven't stress
tested it much (with lots of device removals.)  Any comments would be
appreciated.
Developer:
Greg Kroah-Hartman
Status:
Submitted to project
Release Notes Date Files
20021014 Release Notes 2002-10-14  
  File Notes   device_init-2.5.42.patch.gz