• Patrick Mochel's avatar
    driver model: and present field to struct device and implement device_unregister(). · c7a01052
    Patrick Mochel authored
    device_unregister() is intended to be the complement of device_register(), and assumes
    most of the functionality of the current put_device(). It should be called by the bus 
    driver when a device is physically removed from the system. 
    
    It should _not_ be called from a driver's remove() method, as that remove() method is called
    via device_detach() in device_unregister(). 
    
    dev->present is used to flag the physical presence of the device. It is set when the device
    is registered, and cleared when unregistered. get_device() checks this flag, and returns
    a NULL pointer if cleared. This prevents anyone from obtaining a reference to a device
    that has been unregistered (removed), but not yet been freed (e.g. if someone else is 
    holding a reference to it).
    
    put_device() BUG()s if dev->present is set. A device should be unregistered before it is 
    freed. This will catch people doing it in the wrong order. 
    c7a01052
core.c 7.11 KB