1. 17 Oct, 2002 6 commits
    • Patrick Mochel's avatar
      driver model: change struct device::present to enumerated value with multiple states. · be0b9c71
      Patrick Mochel authored
      Adapted from Greg KH: 
      
      - add multiple possible enumerated states a device can be in: UNINITIALIZED, INITIALIZED,
        REGISTERED, and GONE.
      - Check whether device is INITIALIZED or REGISTERED in device_present().
      - Change struct device::current_state to ::power_state to better reflect what it is.
      be0b9c71
    • Patrick Mochel's avatar
      driver model: power management/shutdown cleanup. · 6b1febf7
      Patrick Mochel authored
      - take device_sem around all global list walks.
      - don't modify refcount, as get_device()/put_device() also take device_sem
      - But, make sure we check device_present() to make sure device is still around.
      
      (Note device removal will block until device_sem is dropped, so list will remain
      intact.)
      
      - Separate out device_shutdown() walk from device_suspend() walk. Even though the
        code is nearly identical, it's a lot clearer as to what is going on when they 
        are autonomous. It was my bad for originally putting that FIXME in there, encouraging
        the consolidation. 
      
      - Add debugging hooks for my convenience. :)
      
      - Call ->shutdown() when shutting down device, instead of ->remove(). (See ChangeSet 
        1.799 for description and semantics).
      6b1febf7
    • Patrick Mochel's avatar
      driver model: introduce device_sem to protect global device list instead of device_lock. · 1e510b8f
      Patrick Mochel authored
      - device_sem is added to make the global list walks easier (for power mgmt and shutdown), so
        they don't have to take and drop device_lock a lot. 
      
      - Change list modifications to take device_sem instead of device_lock.
      
      - Ditto for device refcount modifications.
      
      - Kill get_device_locked(), as all the users are now gone. 
      1e510b8f
    • Patrick Mochel's avatar
      driver model: clean up bus_for_each_{dev,drv} · ec0a28d2
      Patrick Mochel authored
      - make sure we check what we get back from get_bus()
      - do down_read() instead of down_write(), so multiple people can do iterations
        concurrently.
      - Note that devices and drivers are removed from these while doing a down_write(), 
        so all removals will be stalled until the iterators are done.
       
      ec0a28d2
    • Patrick Mochel's avatar
      driver model: protect drivers' device list accesses with bus's rwsem. · 557aebd2
      Patrick Mochel authored
      Drivers must belong to bus, and each bus has an rwsem. Instead of mucking with
      the device_lock spinlock, and dropping it on each iteration of the loop, we take 
      the bus's lock (read, so multiple drivers can access their list at the same time)
      around the entire walk of the list.
      
      557aebd2
    • Patrick Mochel's avatar
      driver model: add struct device_driver::shutdown() method and device_present() helper. · de9d4fa4
      Patrick Mochel authored
      ->shutdown() is added to be explicitly called during reboot transitions by 
      device_shutdown(). Drivers implementing this method should use it solely to quiesce
      the device. Drivers do not have to free memory allocated by the driver, as it is 
      implied that the system is rebooting; and, they must not fuss with the reference
      counts. Devices are guaranteed not to disappear during the call, though their 
      validity may be checked using device_present().
      de9d4fa4
  2. 16 Oct, 2002 34 commits