• Patrick Mochel's avatar
    Update device model locking · d8b2993c
    Patrick Mochel authored
    This updates the device model locking to use device_lock when accessing all
    lists (the global list, the bus' lists and the drivers' lists). Before the latter
    two would use their own rwlocks. 
    
    This also updates get_device() to return a pointer to the struct device if it 
    can successfully increment the reference count. 
    
    Between these two changes, this should prevent anything gaining an invalid 
    reference to a device that is in the process of being removed:
    
    If a device is being removed, it's reference count is 0, but it hasn't 
    necessarily hasn't been removed from its bus's list. If the bus list iterator
    attempts to access the device, it will take the lock, but will continue on to 
    the next device because the refcount is 0 (and drop the lock).
    
    Well, theoretically; the bus iterators still need to be changed, but that's 
    coming next..
    d8b2993c
base.h 878 Bytes