• Patrick Mochel's avatar
    driver model: exploit kobject contstructs. · b12cf4ff
    Patrick Mochel authored
    This makes the driver model core (for devices) exploit the kobject
    infrastructure more and make the resulting code quite a bit simpler. 
    
    For one, device_register() mimmicks kobject_register() in that it now only
    calls device_initialize() and device_add() back to back. Similarly, 
    device_unregister() calls device_del() and put_device() consecutively. 
    
    device_del() no longer removes and frees the device, it only removes them.
    It also removes the devices from the global and sibling lists. This was 
    previously done by device_put(), but moved here to be symmetrical with 
    device_add().
    
    The device's parent is now only incremented in device_add() and decremented
    in device_del(), fixing a bug in which the parent's refcount was incremented
    twice. 
    
    Because of these simplifications, the core can easily be converted to use 
    the kobject reference counting infrastructure. get_device() now simply 
    forwards the call to kobject_get() and ditto for put_device(). 
    device_release() is implemented to handle the freeing of devices once their
    reference count reaches 0.
    
    Since we're using the kobject refcounting model, we no longer need the 
    checking or setting of the device state field, so it has been removed. 
    The only users of it were the power routines. In those, it is implicit that
    we have a valid device, since we've already taken device_sem, and we're 
    walking the list (all modifications are protected by device_sem).
    
    struct device::lock, and the helpers to lock/unlock have been removed. No
    one has ever used them, and no one is likely to use them.
    b12cf4ff
power.c 2.52 KB